Rotational Trading with complicated entry and exit rules

Hello everyone. Previously I had done a backtest using strictly loop mode, something like:

if (Fast[i-1] > Slow[i-1] AND Fast[i-2] <= Slow[i-2]  AND Entered_flag[i] != 1 AND forbid_period[i-1] == 0 AND aux1[i-1] < VIX_Choice AND flag_after_vix_trigger[i-1] == 0 AND buy_stage[i-1] == 0 AND flag_previous_win[i-1] == 1 AND Close[i-1] > tracker_SL[i-1]) {
							 Buy[i] = sigScaleIn;
							 BuyPrice[i] = Open[i] ;
							 //BuyPrice[i] = Open[i];
							 Entered_flag[i] = 1;
							 //stop_loss_level[i] = BuyPrice[i] * (1-((stop_loss_percent)/100));
							 buy_stage[i] = 1;

For now, as I would like to add a rotational trading mode onto the previous system, so that whenever I attained the maximum position limit and in the meantime there is a new buy signal from a stock with higher rank score than the one with lowest rank score in my current portfolio, I would be able to exit the lowest score stock and buy the new stock. After some searching I was not able to find a good article as reference to create the desired program. Would someone point me a direction so that I may achieve the purpose? Thanks.

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.