I am setting up a system in AMI that really is quite simple, but when it comes to join it, I have doubts in the code. I explain to you to see if there is luck:
- I need to calculate differents Wachtlist with differents ROC periods and the same SMA.
- After that, ranking the TOP10 for buy in a monthly rotational systmem.
Here my poor code with errors, i don't know to continue validate...
///////////////TRADING SYSTEM PARAMETERS
//Parametros and Setup of rotacional
SetBacktestMode(backtestRotational); //Se activa el backtes rotational
SetOption( "InitialEquity", 50000 );
SetOption("CommissionMode", 2);
SetOption("CommissionAmount", 7);
SetOption( "AllowPositionShrinking", True );
SetOption("WorstRankHeld", 1);
SetOption("MaxOpenPositions", 10 );
PositionSize=-100/10;
///////////////OPTIMIZACION VARIABLES ROC and SMA
//I need calculate a differents ROC for each wachtlist, inside batch of ETFs. After that raking the top 10 for buy.
if(InWatchList(602))
{ROC1periodo=Optimize("ROC1periodo",1,1,20,1);
ROC1= ROC(C,ROC1periodo);}//OPTIMIZACION GRUPO ETFs EQUITY USA
if(InWatchList(603))
{ROC2=Optimize("ROC2",1,1,20,1);
ROC2= ROC(C,ROC2periodo);}//OPTIMIZACION GRUPO ETFs SECTORES USA
if(InWatchList(605))
{ROC3=Optimize("ROC3",1,1,20,1);
ROC3= ROC(C,ROC3periodo);}//OPTIMIZACION GRUPO ETFs COMODITY
if(InWatchList(606))
{ROC4=Optimize("ROC4",1,1,20,1);
ROC4= ROC(C,ROC4periodo);}//OPTIMIZACION GRUPO ETFs BOND_Fixed income
if(InWatchList(607))
{ROC5=Optimize("ROC5",1,1,20,1);
ROC5= ROC(C,ROC5periodo);}//OPTIMIZACION GRUPO ETFs REAL ESTATE
if(InWatchList(603))
{ROC6=Optimize("ROC6",1,1,20,1);
ROC6= ROC(C,ROC6periodo);}//OPTIMIZACION GRUPO ETFs EQUITY EX-USA
Momentum=ROC1=ROC2=ROC3=ROC4=ROC5=ROC6;
///////////////OPTIMIZACION VARIABLE SMA
SMAPeriodo= Optimize("SMA Periodo",1,1,20,1);
SMA7= MA(C,SMAPeriodo); //Variable la media simple del precio de ciere
///////////////BUY CRITERIA
//Average medium simple sloping up
SMA7_UP=SMA7>(Ref(SMA7,-1));//Calculo media ascendente
SMA7_OK=IIf(SMA7_UP,1,0); //Para seƱalar en el explorer 1=media ascendente, 0=madia no ascendente
OCEAN=Momentum AND SMA7_UP;
// Monthly change criteria
EndofMonth = Month() != Ref( Month(), 1 ) ;
isRebalance = EndofMonth ;
// Ranking top 10 and calculate
PositionScore= IIf(isRebalance , OCEAN, scoreNoRotate);
////////////EXPLORER
Filter = Momentum AND SMA_OK
AddColumn(Momemtum,"Momemtum",1.3);
AddColumn(SMA_OK,"SMA_OK",1.3,IIf( SMA7==1, colorGreen, colorRed);
SetSortColumns( 1 ); //sort by 1st column in increasing order