I'm trying to test a simple system that owns 75% SPY and then uses a momentum rule to buy an ETF with the remaining 25%. The 25% position should use rotational trading or maybe PositionScore for selection. I can't tell if the position sizes can be changed in the code but my test so far indicates that it cannot.
Ideally, the system would use Rotational Trading so worstrankheld can generate the exit of the non-SPY ETF but I can't figure out how to structure that. The code below is a poor attempt using PositionScore and never buys SPY as I planned.
Many thanks to all for your input.
SetOption("InitialEquity", 100000 ); // set initial equity = 100K
//Note position size is less than 100% with the rest used for SPY
SetTradeDelays(1,1,1,1);
BuyPrice = Open;
SellPrice = Open;
//Buy large position in SPY
SetForeign( "SPY" );
SetPositionSize(75,spsPercentOfEquity);
Buy = C>0;
RestorePriceArrays();
//Buy momentum based ETF position
SetPositionSize(25,spsPercentOfEquity);
SetOption( "MaxOpenPositions", 1 );
Mmtm = (ROC(C,13) + ROC(C,52))/2;
Trend_cond = MA(C,20) > Ref( MA(C,20), -2);
Buy = Trend_cond;
Sell = !Trend_cond;
PositionScore = IIf(Trend_cond, 1000+mmtm, 0); //1000+mmtm;
NumPos = 1; //Number of allowed positions
//Exit after 8 weeks and find new position based on momentum
bars = 8; // exit after 8 bars
ApplyStop( stopTypeNBar, stopModeBars, bars, True );