Amibroker has a unique backtesting mode for system such as this called Rotational - plenty of examples on this board if you do a search.
--- In [email protected], "googool123123" <bfall...@...> wrote: > > Hi, > > I would like to write a simple backtest that would rank a watchlist > based on a certain criteria and buys any neww addition at the end of the > month and sells any one that goes out of previous top 5, can someone > please help me to the right direction? Thanks > > something like this pseudo code assuming RSI is used for ranking > > maxPositions = 5 > minPositions = 5 > > stockArray = rankRSI(watchList) > rankArray = sort(stockArray) > > if( now is endOfMonth) > { > for i = rankArray[0] to rankArray[4] > { > if(rankArray[i] not in openPositionsArray > { > buy rankArray[i] > openPositionsArray.add(rankArray[i]) > } > } > > > for i = openPositionsArray[openPositionsArray.length] to > openPositionsArray[0] > { > if(openPositionsArray[i] is not in rankArray[0] to > rankArray[4] > { > sell(openPositionsArray) > openPositionsArray.remove[openPositionsArray[i]) > } > } > } >
