Home › Forums › CDC Forums › Supporting Members Area — รวบรวมสูตร Downloads และระบบการเทรด › สูตร Candle Volume for Aminbroker › Reply To: สูตร Candle Volume for Aminbroker
31/12/2020 at 4:42 am
#37783
MondayDog
Participant
/*SetChartOptions(0,chartShowArrows|chartShowDates); GraphXSpace = 15;
SetChartBkGradientFill( colorSkyblue ,colorRose);
_N(Title = Date()+EncodeColor(colorBlack)+ " Edited by K.Riyashree"+ "Website: www.aflcode.in"+ EncodeColor(colorBlue)+" Free Code"
+" Afl Name : EquiVolume or CandleVolume charts, On Amibroker " + EncodeColor(colorGreen)
+ " Open:"+ Open+" ,"+"High:"+High+" ,"+"Low:"+Low+" , "+"Close:"+Close );*/
ChartType = ParamList ( "Chart Type", "CandleVolume,EquiVolume" );
Plot( C, "", 39, styleBar | styleNoDraw );
Maxy = Status( "axismaxy" );
Miny = Status ( "axisminy" );
pxchartheight = Status ( "pxchartheight" );
pxchartbottom = Status( "pxchartbottom" );
pxchartwidth = Status ( "pxchartwidth" );
pxchartleft = Status( "pxchartleft" );
fvb = Status ( "firstvisiblebar" );
Lvb = Status ( "lastvisiblebar" );
function yConvert( Value )
{
return pxchartbottom - floor( 0.5 + ( Value - Miny ) * pxchartheight / (
Maxy - Miny ) );
}
MinVolume = LowestVisibleValue( Volume );
MinVolume = Max ( Minvolume, 1 );
//printf ( "Min Visibe Bar volume = %.f\n", Minvolume );
sigma = 0 ;
for ( i = BarCount - 1 ; i > fvb - 1 ; i -- )
{
ratio = Volume[i] / MinVolume;
sigma += ratio;
}
//GfxSelectPen( colorBlack );
Space = 1; // space between candles
visiblebars = Lvb - fvb + 1;
totalspace = Visiblebars * space;
unitpx = ( pxchartwidth - totalSpace ) / sigma; // pixel
LastbarRatio = Volume [BarCount -1] / MinVolume;
delta = unitpx * Lastbarratio / 2;
start = pxchartleft + ( BarCount - fvb - 1 ) * pxchartwidth / Visiblebars +
delta;
Chg = C - O;
// Basic Parameter Setup //
Price = ParamField("Price",3);
FastPrd = Param("Fast MA Period",12);
SlowPrd = Param("Slow MA Period",26);
for ( i = BarCount - 1 ; i >= fvb && start > 0 ; i -- )
{
// From CDC Action ZOne Basic //
// 21st April 2017 //
// Main functions //
Fast = EMA(Price,FastPrd);
Slow = EMA(Price,SlowPrd);
Bullish = Fast > Slow;
Bearish = Fast < Slow;
// Bar Colors //
Green = Bullish AND Price[i] > Fast;
Yellow = Bullish AND Price[i] < Fast AND Price[i] > Slow;
Brown = Bullish AND Price[i] < Slow;
Red = Bearish AND Price[i] < Fast;
Aqua = Bearish AND Price[i] > Fast AND Price[i] < Slow;
Blue = Bearish AND Price[i] > Slow;
BarColor = IIf(Green,colorGreen,IIf(Yellow,colorYellow,IIf(Brown,colorOrange,IIf(Red,colorRed,IIf(Aqua,colorAqua,IIf(Blue,colorBlue,colorDefault))))));
//fillcolor = IIf ( Chg [i] > 0 , colorLime, colorRed );
fillcolor = IIf ( Chg [i] > 0 , colorWhite, BarColor[i] );
GfxSelectPen( BarColor[i] );
GfxSelectSolidBrush( fillcolor );
//////////////
ratio = Volume[i] / MinVolume;
width = unitpx * ratio ;
width = Min ( width , pxchartwidth / 5 ); // limit max bar width in pixel to chartwidh/5
if ( ChartType == "CandleVolume" )
{
x = start - width / 2;
}
y1 = yConvert ( High[i] );
y2 = yConvert ( Low[i] );
if ( ChartType == "CandleVolume" )
{
GfxMoveTo ( x, y1 );
GfxLineTo( x, y2 );
}
x1 = start - width;
x2 = start ;
if ( ChartType == "CandleVolume" )
{
y1 = yConvert ( Open[i] );
y2 = yConvert ( Close[i] );
}
// Un-comment these to enable optimization //
// Do not forget to set your own lower and upper limits //
// Do not forget to comment the FastPrd and SlowPrd lines above //
/*
SlowPrd = Optimize("Slow MA Period",26,12,125,2);
FastPrd = round(Optimize("Fast MA Period",0.1,0.1,0.6,0.05)*SlowPrd);
*/
Hgt = y2 - y1;
if ( Hgt == 0 )
Hgt = 1;
y2 = y1 + Hgt;
GfxRectangle( x1, y1, x2, y2 );
start = x1 - Space;
// printf ( "\n%.f\t %.f px" , i, hgt );
}
Title = Charttype;
RequestTimedRefresh( 1 );
SetChartOptions(0,chartShowArrows|chartShowDates);