Post
by abacaba » Sat Feb 23, 2019 4:45 pm
sbank -- hope this helps.
Todd
# Barcounter
# Use a "hotspot" to locate a swing H or L bar.
# Displays the "count" from that bar at setup time
# AND displays current bar counts from that bar forward.
# color, text size, and space from chart H or chart L may be changed
# adjuster sets variable to alter the bar count by a fixed amount
input adjuster(0),spacer(.50),mycolor(purple),textsize(12),textHL("H"), dotwidth(4);
If (barnum==barsback)
{
textref1=0; TDC=0;
bar1 = hotspot_to_bar(1);
pricepoint=hotspot_to_price(1);
ref=plot_dot(bar1-1,pricepoint,mycolor,dotwidth);
}
If (barnum>=updating_bar-3)
{
barcnt=updating_bar-bar1+1+adjuster;
showtext=to_string(barcnt);
If (textHL=="H")
{ If (textref1!=0)text_delete(textref1);
If (TDC==0)
{
textref1=text(bar1,pricepoint,barcnt,mycolor,tx_left,textsize);
}
else
{
textref1=text(updating_bar+5,chart_high-spacer,showtext,mycolor,tx_left,textsize);
}
}
If (textHL=="L")
{
If (textref1!=0)text_delete(textref1);
If (TDC==0)
{
textref1=text(bar1,pricepoint,barcnt,mycolor,tx_left,textsize);
}
else
{
textref1=text(updating_bar+1,chart_low+spacer,showtext,mycolor,tx_left,textsize);
}
}
}
If (barnum>bar1)
{
IF ( (H==H[1])and (L==L[1])and (O==O[1])and (C==C[1]) ) bar1=bar1+1; #holiday filter
If ( (barnum-bar1+1)/3 == int((barnum-bar1+1)/3) )
{ref=plot_dot(barnum,pricepoint,mycolor,dotwidth);
}
}
TDC=TDC+1;