Range Bar Counting 1-2 2-3 & 1-3

#1
Hello TraderJi

I the formula below+
Selecting Point 1 a vertical Green line is Drawn
Selecting Point 2 a vertical Red Line is Drawn
Then Displayed in the Top Left hand corner the Chart
the Bar Count between the two lines is displayed

Would you please tell me how to extend the code below so that
you can Select a Third Point on the Chart and a Vertical Line is Drawn in Say (cyan color)

Then in say top Left corner (or elsewhere)
WriteVal "Barcount Point 1 to Point 2"
& WriteVal "Barcount Point 2 to Point 3"
& WriteVal "Barcount Point 1 to Point 3""

Finaly the Ratio of the bar counts
"Barcount Point 1 to Point 2 (Divided by) Barcount Point 1 to Point 3

Thanking you in advance
Derek

Code:
//Live bar counting on chart

//http://www.wisestocktrader.com/indicators/489-live-bar-counting-on-chart

_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);

// Background color
SetChartBkColor(ColorRGB(23,23,23));
// Display line chart for tick data automatically
priceStyle = IIf( (Interval(0) == -900), styleLine, styleBar);
// Quick counting of bars by range selector
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 );

// set amibroker to display colored bars
Graph0BarColor = IIf( C > O,UpCandleColor ,DownCandleColor);

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

Similar threads