Hi to every one!
I'm finished with a system, and I get a series of codes wrong, could you help me?
-1 Parametization OK
-2 Initialization of variables Ok
-3 Calculation of different ROC and SMA value to the set of 5 Watchlist: I think I'm not doing it right.
-4 Collect all the ROC and SMA results from all the watchlists and make a purchase position score of the 10 best ROCs: I think I'm not doing well.
-5 Explorer: Add column number of 10 position, Add ROC organized by the top 10 of the 5 wachtlist I choose, Add column 1 = SMA> (SMA-1), 0 = SMA <(SMA-1)
Here the code:
///////////////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;
//Time frame
TimeFrameSet(inMonthly);
///////////////OPTIMIZACION VARIABLES ROC
//I need calculate a differents ROC for each wachtlist, inside batch of ETFs. After that raking the top 10 for buy.
ROC1periodo=Optimize("ROC1n",3,1,20,1);
ROC1= ROC(C,ROC1periodo);
Momentum1 = 100+ROC1;
ROC2periodo=Optimize("ROC2n",3,1,20,1);
ROC2= ROC(C,ROC2periodo);
Momentum2 = 100+ROC2;
ROC3periodo=Optimize("ROC3n",9,1,20,1);
ROC3= ROC(C,ROC3periodo);
Momentum3 = 100+ROC3;
ROC4periodo=Optimize("ROC4n",9,1,20,1);
ROC4= ROC(C,ROC4periodo);
Momentum4 = 100+ROC4;
ROC5periodo=Optimize("ROC5n",12,1,20,1);
ROC5= ROC(C,ROC5periodo);
Momentum5 = 100+ROC5;
ROC6periodo=Optimize("ROC6n",3,1,20,1);
ROC6= ROC(C,ROC6periodo);
Momentum6 = 100+ROC6;
///////////////OPTIMIZACION VARIABLE SMA
SMAPeriodo= Optimize("SMA Periodo",7,1,20,1);
SMA7= MA(C,SMAPeriodo); //Variable sma of montly close period
SMA7_UP=SMA7>(Ref(SMA7,-1));//calculate SMA sloping up
SMA7_OK=IIf(SMA7_UP,1,0); //to ssigment in explorer 1=SMA sloping up, 0=SMA no sloping down
///////////////RESEARCH WACHTLIST AND ASSIGMENT ROC
if(InWatchList(602))
{Momentum1;}//OPTIMIZACION GRUPO ETFs EQUITY USA
if(InWatchList(603))
{Momentum2;}//OPTIMIZACION GRUPO ETFs SECTORES USA
if(InWatchList(605))
{Momentum3;}//OPTIMIZACION GRUPO ETFs COMODITY
if(InWatchList(606))
{Momentum4;}//OPTIMIZACION GRUPO ETFs BOND_Fixed income
if(InWatchList(607))
{Momentum5;}//OPTIMIZACION GRUPO ETFs REAL ESTATE
if(InWatchList(603))
{Momentum6;}//OPTIMIZACION GRUPO ETFs EQUITY EX-USA
Momentum_OK= Momentum1 AND Momentum2 AND Momentum3 AND Momentum4 AND Momentum5 AND Momentum6;
///////////////BUY CRITERIA
//Momentum and Average medium simple sloping up
Ocean= Momentum_OK AND SMA7_OK;
// Monthly change criteria
EndofMonth = Month() != Ref( Month(), 1 ) ;
isRebalance = EndofMonth ;
// Ranking top 10 and calculate
PositionScore= IIf(isRebalance , Ocean, scoreNoRotate);
////////////EXPLORER
Filter =1;
AddColumn(momentum_OK,"ROC",1.3);
AddColumn(SMA7_OK,"SMA 7",1.3, IIf( SMA7_OK==1, colorGreen, colorRed));
SetSortColumns( 1 ); //sort by 1st column in increasing order