Optimize One Variable at a Time


I am using the below and it generally producing good metrics. The code optimizes all variables as the related to each other.

How would I change it that optimizes "weight1", then optimizes "weight2" independently of "weight1". Just sequence through each weight.

I realize there are advantages to optimizing all variable at the same time but am looking at this alternative method as well.



OptimizerSetOption("Runs", 3 );
OptimizerSetOption("MaxEval", 200 ); // 5000 evaluations max

weight1 =optimize("Weight1",1.0,-1.5,1.5,0.01);
weight2 =optimize("Weight2",1.0,-1.5,1.5,0.01);
weight3 =optimize("Weight3",1.0,-1.5,1.5,0.01);
weight4 =optimize("Weight4",1.0,-1.5,1.5,0.01);

There is no such thing as "optimizing one variable at a time" the way you think.

Imagine that you have CHESS playfield 8 x 8 fields. The only way to visit entire search space is to visit 64 fields. You go by rows visiting every column in every row and that is precisely how optimization (exhaustive) works.

If you want to optimize only ONE variable, remove 3 Optimize() calls, replacing them with CONSTANT, and run optimization for one variable, by leaving only one Optimize() call.

Hi Tomasz,

Thank you for your reply. I do agree with your comments. My initial thought was if I want to do what you suggest to Optimize only one variable, could it be done be making the the call to Optimize each variable sequentially as in the below code but now see the problem. Even if i Optimize one variable and then move to the next variable, the value I first optimized will not be saved so the final results would be inaccurate. As usual you are correct. I guess I need to create 4 strategies and then composite then for a single score.

Thank you,


OptimizerSetOption("Runs", 3 );
OptimizerSetOption("MaxEval", 200 ); 

weight1 =optimize("Weight1",0.0,-1.5,1.5,0.01);
weight2 =optimize("Weight2",0.0,-1.5,1.5,0.01);
weight3 =optimize("Weight3",0.0,-1.5,1.5,0.01);
weight4 =optimize("Weight4",0.0,-1.5,1.5,0.01);

@ES#C_60_COMP_60_1	=mROC("@RTY#C_60","CC1" )*weight1;
@ES#C_60_COMP_60_2	=mROC("@TY#C_60","CC1" )*weight2;
@ES#C_60_COMP_60_3	=mROC("@ES#C_60","CC1" )*weight3;
@ES#C_60_COMP_60_4	=mROC("@NQ#C_60","CC1" )*weight4;

@ES#C_60_COMP_60_5= IIf(@ES#C_60_COMP_60_1>=0.01,1,IIf(@ES#C_60_COMP_60_1<=-0.01,-1,0));
@ES#C_60_COMP_60_6= IIf(@ES#C_60_COMP_60_2>=0.01,1,IIf(@ES#C_60_COMP_60_2<=-0.01,-1,0));
@ES#C_60_COMP_60_7= IIf(@ES#C_60_COMP_60_3>=0.01,1,IIf(@ES#C_60_COMP_60_3<=-0.01,-1,0));
@ES#C_60_COMP_60_8= IIf(@ES#C_60_COMP_60_4>=0.01,1,IIf(@ES#C_60_COMP_60_4<=-0.01,-1,0));

@ES#C_60_COMP_60_10	=@ES#C_60_COMP_60_5+@ES#C_60_COMP_60_6+@ES#C_60_COMP_60_7+@ES#C_60_COMP_60_8;

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