I am currently trying to work out a system, and can't seem to get a formula that works for me. My system has pretty reliable signals for entering positions, but it's not too clear on the exits, So, I am trying to formulate like this:
GoLongSig: reliable signal to enter Long
GoShortSig: reliable signal to enter Short
Then, to exit the long position, I use a variety of conditions such as
BlueMoon, FredSaysTo, WitchyDay.
Also, since the entry signals are reliable, a GoShortSig is also
appropriate to close out the long position;
I have found that the best action is to delay it a day so that:
StopLong:= If(RedMoon OR PatSaysTo OR AbnormalDay OR
Ref(GoShortSig,-1), 1, 0);
StopShort:= If(BlueMoon OR FredSaysTo OR WitchyDay OR
Ref(GoLongSig,-1), 1, 0);
Now, I want to define EnterLong, EnterShort, ExitLong, ExitShort, and here it seems to get tricky.
EnterLong needs to be defined such that it is OK to follow GoLongSig during BlueMoon OR FredSaysTo OR WitchyDay, since these can happen when there has been no GoShortSig for them to close out. But it needs to be delayed a day IF it is closing out a short position in order to avoid simultaneous long and short positions.
I've tried (BarsSince(GoShortSig) < BarsSince(StopShort)) AND Ref(GoLongSig,-1) and various combinations of logical statements I can think of, and I always end up either skipping those times the GoLongSig is
causing the delayed short close out, or I end up with double EnterLong signals (Two days in a row), or situations where every signal is delayed a day, etc, etc, but never finding the right combo to do what seems to me to be very simple to conceive, but impossible to implement.
I know I am missing something here; This does not seem like a circular logic problem, and I am hoping somebody can point out what it is.