Hi Amibroker Code Helpers!
In a sentence, my issue is that in a Rotational System, a Position with a higher score is not replacing position with a lower score.
Im trying to start super simple so I have this:
BuyPrice = SellPrice = ShortPrice = CoverPrice = Close; SetTradeDelays( 1, 1, 1, 1); Totalpositions = 10; SetOption("WorstRankHeld", 1); SetOption("MaxOpenPositions", Totalpositions ); PositionSize = -100 / Totalpositions ; LastDayOfMonth = IIf( (Month() == Ref( Month(), 1) AND (Month() != Ref( Month(), 2)) ), 1, 0); TradeDay = LastDayOfMonth; Score = ROC(Close, 180); PositionScore = IIf(Score < 0, 0, Score ); // Long only PositionScore = IIf(TradeDay , PositionScore, scoreNoRotate);
This seems to work, as in it seems to rotate some positions every month, however on closer inspection, there was an open trade that as of 31/10/18 it had a NEGATIVE score (the ROC was -8.22). If i run the backtester now, its still saying that it still has that postion open, however if I run the exploration as of the 31/10/18 (last day of month when i thought it should have rotated) there are plenty of positions with a higher ROC/Score.
Can anyone see from the code why it didnt rotate into a better or higher ranked position?
Do you need any more info? Thanks soo much in advance!