# Optimzing with a negative value?

I am using the Williams R oscillator in my entry criteria. I want to optimize this level but the William's r oscillator uses values from -100 to 0. When I run the optimization, I get an error that the optimization values can not be a negative. Does anyone know of a work around for this? Thank you in advance.

``````WR = ( ( HHV(H,5) - Close ) / ( HHV(H,5) - LLV(L,5) ) ) * -100 ; //Williams %R
Buy= WR<Optimize("WR Level" , -80, -80, -95, -5) AND RSI(5) < Optimize("rsi Level", 10,5,30,5) ;
Sell= 1;
sellPrice= Close ;
``````

@Rogerscott here are a couple of possible solutions for an indicator that runs from -100 to 0 (why did Williams decide to multiply by -100? ).

First, don't use Williams R, use the Stochastic K

Here would be a plot of your 5 bar William's vs the StochK(5,1)

Good luck and let us know how it goes.

2 Likes

You are calling Optimize() function incorrectly.

You CAN optimize negative values, but still minimum value needs to be less than maximum (in your code is reverse) and step must be postiive

``````x = Optimize("x", -80, -100, -50, 5 ); // values can be negative, but step > 0
``````
2 Likes

Thank you very much for the knowledge!

Thank you very much for the knowledge!