I want to get the price action for a certain candle that is determined by an event.
Lets say you have exp mov avg 8 and 20. And the event is 8 crosses the 20 up.
Simple to "find" that event. And I can even get the bars ago count. 100% correct.
But what I cant get is the price action on that candle (like the low).
lets say the event happened 10 candles ago. I use bn fo the bar number of the event.
And then I try low[bn] - the low from bn ago.
I get an Only constants expected here error.
I can addlabel on the bn - so it is a valid number.... so why not get the price data?
Any idea how to get it to work?
xlow is where it fails
Thanks
Lets say you have exp mov avg 8 and 20. And the event is 8 crosses the 20 up.
Simple to "find" that event. And I can even get the bars ago count. 100% correct.
But what I cant get is the price action on that candle (like the low).
lets say the event happened 10 candles ago. I use bn fo the bar number of the event.
And then I try low[bn] - the low from bn ago.
I get an Only constants expected here error.
I can addlabel on the bn - so it is a valid number.... so why not get the price data?
Any idea how to get it to work?
xlow is where it fails
Thanks
Code:
def e8 = MovingAverage(AverageType.EXPONENTIAL, close, 8);
def e20 = MovingAverage(AverageType.EXPONENTIAL, close, 20);
def go = e8 crosses above e20;
def gogobn = if IsNaN(go) then gogobn[1] + 1 else if go then 1 else gogobn[1] + 1;
def bn = gogobn;
addlabel(1,"bn="+bn);
#this will show how many bars ago the event (e8 x up e20) happened. 100% correct.
def xlow = low[bn];