Good evening,
i have an strange behavior from a sample code.
defparam drawonlastbaronly = true
once Count = 0
if Count = 0 then
Count = Count +1
MyTime = Time
MySecond = MyTime mod 100
drawtext("A-Seconds=#MySecond#-#Count#",barindex, low-4)
else
Count = Count +1
MyTime = Time
MySecond = MyTime mod 100
drawtext("B-Seconds=#MySecond#-Count=#Count#",barindex, 3200)
endif
return
use in SP500 in market open time, never plot the “A” string, which Count value zero, but plot “B” string from the else clause for Count not zero.
this is the image, but there are other two abnormal item:
– Seconds move (1,2,4,5,6,7,8,9,xxxx up to 59 then restart from zero)
– Count value always 1.295.
i dont understand: i expected that indicator plot either the A and B string, and that the B string have count growing from zero to xxxxx.
if i load less bars (Second image) then number showing from count is still fixed, but its another value.
may you help me? where i was wrong?
It’s because indicators always preload some bars before the one when it starts. So count will start many bars before your indicator starts and count will always be > 0.
As far as I know there’s no way to avoid this.
Bear in mind that, unless you will be using a N-second TF, seconds will always be 00 because candlesticks always close on a minute boundary.