Monday 21 October 2019

Live bar counting on chart. for Amibroker (AFL)



This afl will help to know the number of bars in a (selected) range for a ‘up’, ‘down’ or ‘sideways’ trend or in other applications.

This is how the graph will look like.

Count between Red and Green line is displayed at the left top last line, ‘Range Bars No.’



_SECTION_BEGIN("Live Bar Counting on Chart");
/*   This is a active chart for counting BARs. You will get number of bars instantly between two bars (Range of selected Bars).
Simply select and double click on a Bar and then select another Bar and double click on it too.
You will get two beatiful verticle lines. The bar counting of selected range will be displayed at the left top.
This afl will help to know the number of bars in a (selected) range for a “up”, “down” or “sideways” trend or in other app;ications. To remove verticle lines double click on them. 
*/

SetBarsRequired(100000,0);
GraphXSpace = 15;
SetChartOptions(0,chartShowArrows|chartShowDates);

Title = EncodeColor(colorCustom11)+" live Bar Counting on Chart - compiled by CNBondre" + "---" + Name()+ "--" + EncodeColor(colorYellow)+ Interval(2) + EncodeColor(colorWhite) +
 "  - " + Date() +" - " + EncodeColor(colorRose) +"\nOp-"+O+"  "+"\nHi-"+H+"  "+"\nLo-"+L+"  "+
"\nCl-"+C+"  "+ "\nVol = "+ WriteVal(V)+"\n" + EncodeColor(colorYellow); 


SetChartBkColor(ColorRGB(23,23,23));

priceStyle = IIf( (Interval(0) == -900), styleLine, styleBar);

if (BeginValue(BarIndex()) != 0 AND EndValue(BarIndex()) != BarCount-1) {
    range = EndValue(BarIndex())-BeginValue(BarIndex());
    Title += StrFormat("\nRange Bars No.: %g", range);
}

CandleBorder = ParamColor("Candle Border Color", colorBlack );
UpCandleColor = ParamColor("Up Candle Color", colorGreen );
DownCandleColor = ParamColor("Down Candle Color", colorRed );


Graph0BarColor = IIf( C > O,UpCandleColor ,DownCandleColor);

Plot( C, "Close", CandleBorder, styleNoTitle | ParamStyle("Style") | priceStyle );
_SECTION_END();

1 comment:

Thanks