Disqualifying a pre-existing Flip once entered long

I have a top channel and a bottom channel that I must touch before I can qualify to go long on the next bar. Once it touches either of the top or bottom channel, I set the bOkToTrade to true. It must remain true until I enter long. Once I go long, I want bOkToTrade to turn false so that my next long entry must wait until hitting the top or bottom channel again to be able to qualify for the next trade. This bOkToTrade is part of my LongEntryCondition, which has many other conditions in it too. I am struggling to figure out how to make it turn to false once in a trade, without knowing that info BEFORE the trade condition.

bOkToTrade = Flip( High >= Ref(HHslow,-1) OR Low <= Ref(LLslow,-1), ?EnteredLong?) );

You can see that the ?EnteredLong? disqualification to my flip here won't work because I do not know if I've entered long until further down in the code.

What about something like this:

bOkToTrade =  High >= Ref(HHslow,-1) OR Low <= Ref(LLslow,-1);
bEntrySig = /* your logic here */
Buy = BarsSince(bOkToTrade) < BarsSince(bEntrySig );

The last line says that you must have touched the channel more recently than you had a (potential) entry signal.

1 Like