I am building a strategy that triggers orders based upon price interacting with an overlay indicator that generates moving average-like bands.
Like this...
The first entry at Y is valid because it touched the Y-1 line last.
The second entry at Y-1 is valid because it touched the Y line last.
The third entry is valid because is touched the Y line last (even though it didn't trade at the Y line last).
The fourth entry is NOT VALID and it would not be valid until it first touched the Y-1 line. Since Y1 was the last touched, only long at Y is valid, not Short!
The fifth entry is again NOT VALID because it is a short, and it didn't touch the line below it before it touched Y-1, therefore, within my paradigm, it is considered a continuation and not a reversal.
I apologize for the crude example, but I wanted to make it as clear as possible rather than have the concept muddled with chaotic price action.
The current instantiation of my automated strategy enters at every line where the entry conditions are met (Low[0] <= Line, Close[0] & Open[0] > Line for Long, for example)
So in logical terms using the Y-Line I want to say...
if entry conditions are met and price touched Y1 BEFORE Y-1, then enter Long, or for a short it would be... if entry conditions are met and price touched Y-1 BEFORE Y1 then enter Short. In other words, for each entry (at each line) a time condition would need to be set referencing the lines immediately above and below it).
My final word is that I am able to do this in a crude way by referencing the highest or lowest bar in the last 10 bars, or crossabove/crossbelow in the last 10 bars, but the problem with that is that it needs to be a generalized BEFORE rather than "in the last 10 bars" because sometimes it could be 10, sometimes it could be 50, and so using a specific lookback is really not a solution. I need to be able to specify the condition with respect to TIME.
Thank you for your time, I know this was a lot of information, but I wanted to be as detailed as possible, I hope you can be as detailed in your response.
Looking forward to hearing from you.
Comment