Reputation: 37
I'm drawing boxes on my chart (Timeframe Daily) but I need those boxes plotted on H1 chart. In addition to having them pictured I need to get top and bottom values: This is the code I'm using:
217 box fiboL = box.new(na, na, na, na, color.new(color.green, show_fib ? 50 : 100), 2, bgcolor=color.new(color.green, show_fib ? 75 : 100))
218 var float fibo_topL = na
219 var float fibo_botL = na
220 var fibo_topL_D = security(syminfo.tickerid, "D", fibo_topL)
221 if new_max and val_ph_H1 > val_ph_H1[1]
222 box.set_top (fiboL, fiboL_61)
223 box.set_bottom (fiboL, fiboL_78)
224 box.set_left (fiboL, bar_index [piv_len])
225 box.set_right (fiboL, bar_index + extend_fib)
226 fibo_topL := box.get_top (fiboL)
227 fibo_botL := box.get_bottom(fiboL)
Upvotes: 1
Views: 503
Reputation: 1961
You cannot use mutable variables (defined as var
) inside security()
.
If fibo_topL
will be passed into security()
, it will be calculated in scope of other timeframe, i.e on another chart. So it is impossible to change this value inside any scopes than global of the current chart. Also, you wouldn't be able to pass the boxes itself into security()
. So now you error is that instead of
var float fibo_topL = na
should be
float fibo_topL = na
Upvotes: 1