I have a Relative Strength strategy that buys the ETF from a data-set of 24 ETFs if the ETF has relative strength compared to SPY, else buys SPY in its position (using SetContext/RestoreContext).
- Position is sold after 20 days.
- Position size is 10% of Equity (so, 10 positions). Capital is $100K, 1:1 Margin.
I'm seeing 2 strange behaviors
1) Only 7-8 positions are held instead of 10 (as i observe positions in the Portfolio Inspector tab). As a result, my exposure is only 69% instead of ~100% - Buy code below ..
CODE:
Please log in to see this code.
2) If i add a Position Priority (i.e. uncomment the BuyAtClose statement in the code above), SPY is never bought - i don't see SPY in Trades tab, Symbol tab, Portfolio Inspector tab and # of Trades and Exposure also go down.
i.e. the SetContext/RestoreContext doesnt seem to work.
Pl advise how to address these two issues