compare a double with a value in an array

 

hola

plz i need your helps.

i have an array withe a price of n(number) open orders and i want compare a new price withe this n price if it s different so open a new orders.the code that i use it s

for(int i=0;i<=n;i++)

{

if(new_price=open[i]) ; {OrderSend(Symbol(),OP_BUY,lot,new_price,3,0,profit,"buy",N,0,Olive);}

}

EXAMPLE

my array is :

op[1.2000 1.2300 1.2400 1.5000]

the price that i wanna compare is 1.2400

this price is different for op[0], op[1],op[3] but it's equal at op[2]

the problem is when the EA is open it s send 3 order withe the same price 1.2400

if it's possible to write a code how cheek all the price in the array and then if it s different open a order withe this new price

 
  1. Doubles rarely compare equal Working with Doubles in MQL4 - MQL4 Articles
    if( MathAbs(new_price - open[i]) < pips2dbl)

  2. Your code with formatting
    for(int i=0;i<=n;i++)
    {
       if(new_price=open[i]) ; 
       {
          OrderSend(Symbol(),OP_BUY,lot,new_price,3,0,profit,"buy",N,0,Olive);
       }
    } 
    Or
    for(int i=0;i<=n;i++)
    {
       if(new_price=open[i]) /*DO NOTHING*/; 
       /*Useless brace {*/
       OrderSend(Symbol(),OP_BUY,lot,new_price,3,0,profit,"buy",N,0,Olive);
       /*Useless brace }*/
    } 
    Delete the extra semicolon.
  3. Your looping from 0 to N. If N is the count you must use i < n not i <= n.
  4. If you only want to open one order, add a break after the orderSend.


 
WHRoeder:
  1. Doubles rarely compare equal Working with Doubles in MQL4 - MQL4 Articles
  2. Your code with formatting Or Delete the extra semicolon.
  3. Your looping from 0 to N. If N is the count you must use i < n not i <= n.
  4. If you only want to open one order, add a break after the orderSend.


Thank you i m resolving the probleme withe your help.

4.If you only want to open one order, add a break after the orderSend.

that's what i need.

thank youuuuuu

Reason: