Can anybody please edit this code for numbering alternate like 2,4,6,8 ......... and move the numbers little more to the downside.
SetBarsRequired( 1500, 1500 );
dn = DateNum();
newday = dn != Ref( dn, -1 );
BarsOfDay = BarsSince( newday ) /*+ 1*/;
printf( "Bars since new day: %g", BarsOfDay );
Plot( C, "Price", colorDefault, styleCandle );
bi = Barindex();
fvb = FirstVisibleValue( bi );
lvb = LastVisibleValue( bi );
yoffset = -20;
for( i = fvb; i <= lvb; i++ ) {
PlotText( " " + barsofday[i] , i , L[i], colorGreen, -1, yoffset );
}
... numbering alternate like 2,4,6,8
text_cond = BarsOfDay % 2 == 0 AND BarsOfDay > 0;
And add upper text_cond variable to an if statement placed inside loop before your Plottext line.
if ( text_cond[ i ] )
PlotText(...);
and move to the downside little more.
Modify your yoffset variable.
Or what else is meant by "move to downside"?
1 Like
nsm51
July 6, 2020, 11:51am
3
You can also try and increase the step count in the loop by 2 like this if it serves the purpose but may not consistently output even numbers.
for( i = fvb; i <= lvb; i+=2 )
1 Like
Thank you for the replay.
But it is not starting from first bar. What to do?
Thank you for the replay. I meant the same. I modified the yoffset.
??
You wrote this one:
So you were looking for excluding first bar of day.
If you want to output first bar too then comment AND BarsOfDay > 0
SetBarsRequired( 1500, 1500 );
dn = DateNum();
newday = dn != Ref( dn, -1 );
BarsOfDay = BarsSince( newday ) /*+ 1*/;
text_cond = BarsOfDay % 2 == 0 /*AND BarsOfDay > 0*/;
printf( "Bars since new day: %g", BarsOfDay );
Plot( C, "Price", colorDefault, styleCandle );
bi = Barindex();
fvb = FirstVisibleValue( bi );
lvb = LastVisibleValue( bi );
yoffset = -20;
for( i = fvb; i <= lvb; i++ ) {
if ( text_cond[i] )
PlotText( " " + barsofday[i] , i , L[i], colorGreen, -1, yoffset );
}
2 Likes
I think it will be best if counting starts from first bar itself. (Actual count instead of starting from zero)
So what are you looking for now?
Display of sequence 1, 3, 5, 7,...?
SetBarsRequired( 1500, 1500 );
dn = DateNum();
newday = dn != Ref( dn, -1 );
BarsOfDay = BarsSince( newday ) + 1;
text_cond = (BarsOfDay-1) % 2 == 0 /*AND BarsOfDay > 1*/;
printf( "Bars since new day: %g", BarsOfDay );
Plot( C, "Price", colorDefault, styleCandle );
bi = Barindex();
fvb = FirstVisibleValue( bi );
lvb = LastVisibleValue( bi );
yoffset = -20;
for( i = fvb; i <= lvb; i++ ) {
if ( text_cond[i] )
PlotText( " " + barsofday[i], i , L[i], colorGreen, -1, yoffset );
}
Or still 2, 4, 8, ...?
SetBarsRequired( 1500, 1500 );
dn = DateNum();
newday = dn != Ref( dn, -1 );
BarsOfDay = BarsSince( newday ) + 1;
text_cond = BarsOfDay % 2 == 0 /*OR newday*/;
printf( "Bars since new day: %g", BarsOfDay );
Plot( C, "Price", colorDefault, styleCandle );
bi = Barindex();
fvb = FirstVisibleValue( bi );
lvb = LastVisibleValue( bi );
yoffset = -20;
for( i = fvb; i <= lvb; i++ ) {
if ( text_cond[i] )
PlotText( " " + barsofday[i], i , L[i], colorGreen, -1, yoffset );
}
3 Likes
Thank you.
It can be 1,3,5... .. OR 2,4,6,8 ......
I only wanted the counting from first bar itself. Earlier first bar counted as Zero. I follow Mr. AL BROOKS. So it will be really helpful me to trade.
Thank you once again