Why this code gives operator precedence error?

To add comments, please log in or register
rod777
108
rod777  
        if(NormalizeDouble(price_140-Move_step*pm*Point,Digits)>NewPrice
         && NewPrice<=NormalizeDouble(price_116-Distance_between_orders*pm*Point,Digits)
         || price_116==0.0
         || Open_order_on_trend && CountBuys==0 
         || NewPrice>=NormalizeDouble(price_108+Distance_between_orders*pm*Point,Digits)
         || NewPrice<=NormalizeDouble(price_116-Distance_between_orders*pm*Point,Digits))
nicholi shen
1851
nicholi shen  
rod777:
        if(NormalizeDouble(price_140-Move_step*pm*Point,Digits)>NewPrice
         && NewPrice<=NormalizeDouble(price_116-Distance_between_orders*pm*Point,Digits)
         || price_116==0.0
         || Open_order_on_trend && CountBuys==0 
         || NewPrice>=NormalizeDouble(price_108+Distance_between_orders*pm*Point,Digits)
         || NewPrice<=NormalizeDouble(price_116-Distance_between_orders*pm*Point,Digits))

You're missing a set of parenthesis. I can't tell you where because it's your logic so you need to determine the correct precedence. 

whroeder1
17949
whroeder1  
rod777:
 if(A && B || C || D && E || F || G)
Don't mix ands and ors together. Add parentheses to make it specific.
bool A = NormalizeDouble(price_140-Move_step*pm*Point,Digits)>NewPrice;
bool B = NewPrice<=NormalizeDouble(price_116-Distance_between_orders*pm*Point,Digits);
bool C = price_116==0.0;
bool D = Open_order_on_trend;
bool E = CountBuys==0;
bool F = NewPrice>=NormalizeDouble(price_108+Distance_between_orders*pm*Point,Digits);
bool G = NewPrice<=NormalizeDouble(price_116-Distance_between_orders*pm*Point,Digits);

if(A && (B || C || D) && (E || F || G) )
// or
if( (A && B) || C || (D && E) || F || G)
rod777
108
rod777  
thanks
rod777
108
rod777  
it works, was the first one
To add comments, please log in or register