Australian (ASX) Stock Market Forum

Buy 5 worst stocks

xxx

Joined
21 October 2016
Posts
31
Reactions
0
Hello,
I want to try a system which says that I would like to buy the 5 worst stocks every month with rotational trading.

All in all I now how roational trading works.
But my code I wrote does not calculate the 5 worst stocks.

The 5 worst stocks are the 5 stocks which have the worst performance.

Does anybody know how I could do this?

Thanks for you help
 
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);
 
Top