Im writing this to get a variable from 1W timeframe to use in a lower timeframe.
I draw a line with 2 points in history, and then I get the value of line at the current bar.
I draw the line on timeframe 1W, it connects 2 points from the bar_index[2] to the bar_index[1] and so I can get the value of that line at the current bar_index (all 3 bar_index are on 1W timeframe).
//@version=4
msma = sma(close, 14)
var msma_line = line.new(bar_index[1], high[1], bar_index, low, extend = extend.right)
line.set_xy1(msma_line, bar_index[2], msma[2])
line.set_xy2(msma_line, bar_index[1], msma[1])
msma_point = line.get_price(msma_line,bar_index)
W_1 = security(syminfo.tickerid, "1W", msma_point, barmerge.gaps_off, barmerge.lookahead_on)
Now I get that value (V) at the current week, I go to the timeframe 4H, and I want to see that (V) value, store it in a variable, so I can compare it with the current close.
if (close > W_1)
// here is what to do with the comparaison
But I have got the error
'expression' argument of security function should have no side effects
What does that mean?
How I can use the W_1 variable at lower timeframe ?