My code is not ranking the worst ones. HAs anybody an idea?
this is my code:
SetTradeDelays (0,0,0,0);
SetOption( "InitialEquity", 50000 ); // Eigenkapital gesamt = 50000
SetPositionSize(10000,spsValue); // Eigenkapital pro Aktie = 10000
SetBacktestMode(backtestRotational);
SetOption("UsePrevBarEquityForPosSizing", True); // use previous bar opening equity to perform position sizing
SetOption("MinShares", 1); // minimum number of shares required to open the position in the backtester
SetOption("AllowPositionShrinking", True);
SetOption("AccountMargin",100); // Gewinnmarge 100 = keine Begrenzung
MaxOpenPositions = 5;
SetOption("WorstRankHeld", MaxOpenPositions ); // worst rank of symbol to be held in trading mode
SetOption("MaxOpenPositions", MaxOpenPositions);
SetOption("SeparateLongShortRank", True );
SetOption("MaxOpenLong", 5); // 5 beste Aktien raussuchen
newMonth = Month() != Ref(Month(), -1);
Nmonths = 1;
rotate = newMonth;
perf = TimeFrameGetPrice("O", inMonthly, -1); // get monthly Open price 1 month ago
perf1 = TimeFrameGetPrice("O", inMonthly, -2); // get monthly Open price 2 month ago
// Formel
score= 100*((perf- perf1)/perf1) + 100;
PositionScore = score;
PositionScore = IIf(rotate,PositionScore, scoreNoRotate);