Cannot get negative optimize range

Posted By: bigsmack

Cannot get negative optimize range - 05/05/23 04:54

I am trying this conceptually - Zorro 2.5.3

Optimize for negative range with min=-135 and max=-45
so that would look like this if allowed:
var LowerThreshold = optimize(-90,-135,-45,9);

But that throws a compile error and the manual says:
For optimizing negative parameter ranges, subtract an offset or add a minus sign to the optimize call.

So I tried this with a minus sign to the optimize call and it compiles but the value set is still positive (is this the right syntax as described from the manual?):
var LowerThreshold = -optimize(90,45,135,9);

The .par file shows positive for parameter 4 in this example = 90.4 and not -90.4 as expected (Is this possibly a bug?)
USD/JPY 13.13 34.1 98.7 90.4 18.00=> 2.504

I don't know how to "subtract an offset" as the manual says - can somebody help me understand that please?

I tried some things but always get positive parameter value.

Thanks!
Posted By: Grant

Re: Cannot get negative optimize range - 05/05/23 17:24

I've never tried it myself, but I guess it should be

Code
var LowerThreshold = -optimize(-90,-135,-45,9);


subtract an offset simply means something like

Code
LowerThresholdFinal = 0 - LowerThreshold;


or simply use

Code
LowerThresholdFinal = -LowerThreshold;
Posted By: bigsmack

Re: Cannot get negative optimize range - 05/06/23 00:44

I appreciate the help Grant but your suggestions are giving the same results. No negative optimization.

Error 011: invalid optimize range -135.0--45.0

I tried all the suggestions. I multiplied by negative 1 and tried offset too.

Does anybody have this working?
Posted By: Grant

Re: Cannot get negative optimize range - 05/06/23 00:52

OK, so 'var LowerThreshold = -optimize(-90,-135,-45,9);' isn't working, then why not use:

Code
var LowerThreshold = optimize(90,135,45,9);
var LowerThresholdFinal = -LowerThreshold;


So you're only using 'LowerThresholdFinal' within your trading rule(s).

This is what I meant with the 2nd & 3rd code example.


Posted By: bigsmack

Re: Cannot get negative optimize range - 05/06/23 01:13

You, sir, are a genius!

Thank you so much!

Thanks for clarifying the obvious using the negative in the trading rule.

I was trying to force the negative to show up in the .par file but obviously that is just my brain not letting go.
Posted By: Grant

Re: Cannot get negative optimize range - 05/06/23 10:46

You're welcome.

I made a small typo, I meant:

Code
var LowerThreshold = optimize(90,45,135,9);
© 2024 lite-C Forums