Hi
I am trying to update my indicator value only at a specific time of the day and then have that value carried until the next update same time next day – I have read the user manual but can’t workout why the below updates every bar instead of the time of 10am
—-
timestart = (Time = 100000)
lowprice = lowest[20]
highprice = highest[20]
Return timestart, lowprice as “lowprice”, highprice as “highprice”
——-
Any thoughts on where I am going wrong?
Thanks
To write code, please use the <> “insert PRT code” button to make your code easier to read. Thank you.
Line 1 will hold a logical value (either 0 or 1, False or True), not the time, you should write
timestart = 100000
to assign TIMESTART a constant (in this case you could even write the keyword ONCE before the name, but it’s not mandatory).
Since RETURN is executed at each bar, it will ALWAYS update your chart.
Lines 2 and 3 miss WHAT data the two functions should return, I assume you wanted to write
lowprice = lowest[20](low)
highprice = highest[20](high)
to have the lowest LOW and highest HIGH of the last 20 bars.
I think what you want is to draw a line at both the highest and lowest price at 10:00am and keep it till next day.
I’ll write something in a few minutes.
There you go
DEFPARAM DrawOnLastBarOnly = true
IF Time = 100000 THEN
lowprice = lowest[20](low)
highprice = highest[20](high)
MyBar = BarIndex
ENDIF
DRAWsegment(MyBar-20,highprice,barindex,highprice) coloured(0,0,255,255) //Blue segment
DRAWsegment(MyBar-20,lowprice,barindex,lowprice) coloured(255,0,0,255) //Red segment
RETURN
is that what you needeed?
Roberto
Hi Roberto
thanks so much – the draw segment wasn’t but the rest was – so modified to :
Much appreciated!!
IF Time= 100000 THEN
lowprice = lowest[20](low)
highprice = highest[20](high)
ENDIF
Return lowprice as "lowprice" , highprice as "highprice"