I'm working on a strategy that I'm trying to get setup. So basically what I have is when price crosses a certain threshold (whether it be an EMA, etc) I want it to look back at the last X amount of bars and if where the current price is IS NOT less than the lowest price of the last X amount of bars don't trigger.
Current I'm using something such as this as I found it in the the docs but it seems like its not quite right all the time.
if(Close[0] < Low[LRO(() => Close[0] > Open[0], 1, X)]) { Enter Short here}
I'm honestly not quite understanding the `Close[0] > Open[0]` part of it but truly not quite sure if its actually looking back at the last X amount of bars because in the strategy analyzer the first time it hits its seems to work but I think its because of the time I'm actually using for a small sample test but when I see it run again it definitely is not working because it shouldn't have entered into a short if the price was not lower than the last X amount of bars I'm using.
Then I'm also looking at my exit strategy where once its in a short I want it to look at the current price (bar) and if at X amount of bars back (not looking at all the bars behind it but at a specific bar behind the current bar if the price is higher than that bars HIGH I want it to exit.
For that I was using something like:
if(Close[0] > High[X]) { Exit short here }
For some reason this isn't working correctly either b/c its exiting sooner than the X value of the High parameter for that bar at that index.
Comment