I have been working on a binary backtest using a simple 0, 1, 2, 3 logic, where 0 = Cash and as the numbers increase the S&P 500 leverage corresponds accordingly, but I am getting overlapping trades with the signals and am wondering if I have structured my Entry or Exit logic incorrectly.
My general binary criteria is scripted in the bottom clip below:
Entry signals are when the model changes into a new position and then becomes 100% of the new allocation.
Model = SCRIPT(SCRIPTNAME=Cash and S&P 500 Allocation) ;
Model ChangeTo 0 and ISTICKER(CODE=SHV:US) or
Model ChangeTo 1 and ISTICKER(CODE=SPY:US) or
Model ChangeTo 2 and ISTICKER(CODE=SSO:US) or
Model ChangeTo 3 and ISTICKER(CODE=UPRO:US)
Exit signals are generated when the model changes from anything other than the current signal. IE, if the model is currently +1 (SPY), and moves to 0 or +2 or +3, either SHV, SSO, or UPRO becomes the new allocation.
Model = SCRIPT(SCRIPTNAME=Cash and S&P 500 Allocation) ;
( Model ChangeTo 1 and ISTICKER(CODE=SHV:US) ) or
( Model ChangeTo 0 or Model ChangeTo 2 or Model ChangeTo 3 ) and ISTICKER(CODE=SPY:US) or
( Model ChangeTo 0 or Model ChangeTo 1 or Model ChangeTo 3 ) and ISTICKER(CODE=SSO:US) or
( Model ChangeTo 2 or Model ChangeTo 1 or Model ChangeTo 0 ) and ISTICKER(CODE=UPRO:US)
However when looking at the trade list, multiple ETFs are being purchased during periods when only one asset should be chosen.
For instance on 2/10 and 2/16 there are two entries for SPY and SSO without a corresponding sell of SPY and then a subsequent buy into SSO.
I am assuming that I have scripted the Entries and Exits wrong, but not sure of a better way to approach.
I sincerely appreciate the assistance as always.
EK