Multiple trade per symbol

Dear all,

I do have a simple range strategy with long only set up below. This scales-in into multiple trades per each symbol. My requirement is to change this to multiple positions per symbol instead (Not scale-in but multiple positions per symbol) using backtestRegularRaw2Multi. I would greatly appreciate any support, advise, suggestion to achieve this. I know that low level CBI could be required to achieve this and it might not be practical to do that all from here but again any suggestion would be much appreciated.

Many thanks,

Kind regards,

AD



//Define Backtesting Mode
//SetBacktestMode(backtestRegularRaw2Multi);         
SetBacktestMode(backtestRegular);       

BuyLB						= Param("Entry LookBack",21,1,200,1);
SellLB						= Param("Exit LookBack",21,1,200,1);
BO_Buy 						= HHV(H , BuyLB);
BO_Sell 						= LLV(L, SellLB);


BuySigna					= Cross(H, Ref(BO_Buy, -1)) ;
SellSigna					= Cross(Ref(BO_Sell, -1), L);
BuyTriggerPrice			= Ref(BO_Buy,-1);
SellTriggerPrice 			= Ref(BO_Sell,-1); 



ATRLB					= Param("ATR  LookBack", 10, 10, 100, 1);
InitialStopATR				= ATR(ATRLB);
LongStopLoss				= Null;
ShortStopLoss			= Null;
InitialStopMultiplier	= Param("Initial Stop Multiplier", 3, 1, 100, 1);


ATRPeriod 				= 14;
RiskPerTrade 		        	= 1;
TotalEquity				= 100*1000;
ATRCcy 					= Ref(ATR(ATRPeriod),-1); 

ATRPercent 				= (ATRCcy / MA(C, ATRPeriod)) * 100;
PosSizeY 				= (TotalEquity*(RiskPerTrade / 100) ) / ATRPercent;

SetOption("InitialEquity", TotalEquity);
SetPositionSize(PosSizeY, spsValue);
 FractionATR = Param("Scaling ATR Multiplier", 1, 0.1, 10, 0.1);
ATRV = Nz(Ref(ATR(ATRLB), -1)) * FractionATR; 


Buy = Sell = Null;
LongTrade = 0;
qty=0; netq=0;


LastBuyPrice				= Null;
LongScaleEntryPrice 		= Null;
LongEntryNumber 			= 0;
ScaleMax 				= 3;
NextLongScalePrice 		= 0;


Test = Test2 = 0;
for( i = 1; i < BarCount; i++)
{

	if (LongTrade) 
		Netq[i]= Netq[i - 1]; 
	
	if (BuySignal[i] AND !LongTrade) 
	{
		Buy[i] 					= True; 
		BuyPrice 					= LastBuyPrice = BuyTriggerPrice[i]; 
		LongTrade 				= 1;
		LongEntryNumber 			= 1;
		NextLongScalePrice 		= LastBuyPrice + (LongEntryNumber * ATRV[i]);
		Qty[i] 					= 1;
		Netq[i] 					= LongEntryNumber;
		LongStopLossPrice 		= BuyTriggerPrice[i] - InitialStopMultiplier * InitialStopATR[i];
		LongEntryBar 				= True;
	}
	
	else	
		LongEntryBar = False;
	
	if (LongTrade AND LongEntryNumber <= ScaleMax AND !LongEntryBar)
	{
		if (H[i] > NextLongScalePrice)
		{
			Buy[i] 					= sigScaleIn;
			BuyPrice[i] 				= LastBuyPrice = Max(O[i], NextLongScalePrice);
			Qty[i] 					= 1; 
			Netq[i] 					= LongEntryNumber;
			NextLongScalePrice	 	= LastBuyPrice + (LongEntryNumber * ATRV[i]);
			LongStopLossPrice 		=  LastBuyPrice- InitialStopMultiplier * InitialStopATR[i]; 
			LongEntryNumber++;
		}
	}

	if (LongTrade AND !LongEntryBar) 
	{
		LongStopLoss[i] 			= LongStopLossPrice;
		LongScaleEntryPrice[i] 		= NextLongScalePrice;
	}
		
	
	if (SellSignal[i] AND LongTrade == 1 )

	{
		Sell[i] 						= 1; 
		SellPrice[i] 					= Min(O[i], SellTriggerPrice[i]);
	}
			
	
	if (L[i] < LongStopLoss[i])
	{
		Sell[i] 						= 1; 
		SellPrice[i] 					= Min(O[i], LongStopLoss[i]);
	}
		
	if (Sell[i])
	{
		Netq[i]					= 0;
		LongTrade 				= 0;
	}

}