Optimize Same data for some and not for others

Hi all,

Saw this in another post but had difficulty understanding. When I optimize it shows the same data. Not sure why.

My_ROC = Optimize("ROCPeriod",200,50,300,1);// This code does not work
My_ROC = ROC(C,Optimize("ROCPeriod", 20, 50, 300, 1));//This code works when optimze

However when doing the below code it does not work and it is identical except for the Average true range instead of Rate of change.

My_ATR = ATR(C,Optimize("ATRPeriod",200,50,300,1));Does not work yet same as ROC one. 

What am I doing wrong in the first one? Something to do with the brackets? Or is it need to put the ROC at the start as shown in the 2nd one? Because when I did that to the ATR Code it does not work but I swear it is the same code as the 2nd code displayed but different indicator.

@agsty, the ATR() one does not work because the ATR() function has only one parameter (the period).

Modify it to:

My_ATR = ATR(Optimize("ATRPeriod",200,50,300,1));

In the first code line you are simply invoking the optimize function to set the "period" variable and not actually using the result as the period argument to pass to the ROC() function.
The second one is correct and is the same as writing on separate lines:

My_ROC_period = Optimize("ROCPeriod",200,50,300,1);
My_ROC = ROC(C, My_ROC_period);
2 Likes

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