Trading system toolbox
| When placed on the top of system formula it turns on
rotational-trading (aka. fund-switching) mode of the backtester.
Note: this function is now marked as obsolete. Use SetBacktestMode( backtestRotational ) in new formulas.
IMPORTANT NOTE: Unless you specifically want to implement fund-switching/rotational trading system you should NOT use this mode.
Rotational trading is popular method for trading mutual funds. It is also known as fund-switching or scoring&ranking. Its basic permise is to rotate symbols all the time so only top N issues ranked according to some user-definable score are traded. The number of positions open depend on "Max. open positions" setting and available funds / position size. Once position is entered in remains in place until security's rank drops below WorstRankHeld (settable via SetOption("WorstRankHeld", 5 ) ). Regular buy/sell/short/cover signals are not used at all.
The rotational mode uses only score variable (PositionScore) to rank and rotate securities. This idea has been implemented earlier in PortfolioTrader AFL formula written by Fred Tonetti with GUI written by Dale Wingo.
To enter this mode you have to call EnableRotationalTrading() function at the very beginning of your formula. From then on using of buy/sell/short/cover variables is not allowed. Only PositionScore variable will be used to rank securities and trade top N securities..
A simple rotational trading formula (stocks with high RSI are best candidates for shorting while stocks with low RSI are best candidates for long positions):
The score (PositionScore) for all securities is calculated first. Then all scores are sorted according to absolute value of PositionScore. Then top N are choosen to be traded. N depends on available funds and "max. open positions" setting. Backtester successively enters the trades starting from highest ranked security until the number of positions open reaches "max. open positions" or there are no more funds available. The score has the following meaning:
Exits are generated automatically when security's rank drops below "worst rank held". There is no real control over when exits happen except of setting low score to force exits. You can also set the score on any (at least one) security to value of scoreNoRotate to prevent rotation (so already open positions are kept). But this is global and does not give you individual control.
The EnableRotationalTrading function is used in the following formulas in AFL on-line library:
See updated/extended version on-line.