Hi,
I have a list of stocks in watchlist 0, a different list in WL 1 and another list in WL2.
I am testing the buying and selling of 10 stocks in each watchlist at the year start and end - using RSI values as a positionscore.
SetBacktestMode( backtestRegular );
SetTradeDelays(0,0,0,0);
SetOption( "InitialEquity", 10000);
SetOption("CommissionMode",2);
SetOption("CommissionAmount",10);
SetOption("FuturesMode" ,False);
SetOption("MinShares",1);
SetOption("MaxOpenPositions", 10);
PositionSize = -10;
Buy=Month()==1 AND Ref(Month(), -1)==12;
Sell = Ref(Buy, 1);
xx = 14;
PositionScore = 100-RSI(xx);
This works if I use Apply to > Filter > Watchlist 0 and a date range of 2018-2019.
But if I want to optimize the formula for different RSI values for all the dates:
2012 - 2015 --- using WL#2
2016 - 2018 --- WL#1
2018 - 2019 --- WL#0
I tried Apply to > All Stocks and Optimising, with these changes:
xx = Optimize("RSI",14,2,20,1);
PositionScore = 100-RSI(xx);
PositionScore = IIf(Year()>=2012 AND Year()<2016 AND !InWatchList(2), -999999, PositionScore);
PositionScore = IIf(Year()>=2016 AND Year()<2018 AND !InWatchList(1), -999999, PositionScore);
PositionScore = IIf(Year()>=2018 AND !InWatchList(0), -999999, PositionScore);
-999999 was to exclude the current stock from positionscore ranking if it wasn't in the required WL.
But this didn't work. And I'm not sure what to do next.
Suggestions welcome.....
Thanks