Download MetaTrader 5
To add comments, please log in or register
Having questions to the author of an article? Discuss them on the Forum!
mrgoodprice144
42
mrgoodprice144 2016.03.22 23:04 

Hi,

I'm trying to make a very simple code that will send 2 pending orders one BUYSTOP and one SELLSTOP ORDER every thing is working fine with the BUYSTOP order but when it come to the SELLSTOP

order i get : 2016.03.22 23:56:10.883    TEST88 EURUSD,M15: Error opening SELLSTOP order : 0

i dont understand why it does that here is the code :

 if(Count==1 )
 {

ticket=OrderSend("EURUSD",OP_BUYSTOP,0.01,Ask+3*Point,0,0, clrGreen );
 
}
else
{

Print("Error opening BUYSTOP order :", GetLastError());
}
 
if (Count==1 )
 {
  ticket=OrderSend("EURUSD",OP_SELLSTOP,0.01, Bid-10*Point, 0,0,clrGreen);
 
}
else
{
 
Print("Error opening SELLSTOP order : ", GetLastError());
}

AM'i doing something wrong here i do not understand why it wont work i dont even have a special ERROR number like 130, 128 etc.. all i get is a 0 .

Any suggestion

Keith Watford
Moderator
7990
Keith Watford 2016.03.22 23:26  

Your print statements are executed if Count does not equal 1. They are not related to the OrderSends.

You should be getting error prints for both

whroeder1
13644
whroeder1 2016.03.23 00:36  
You are looking at GLE when count != 1
if (Count==1 )
 {
  ticket=OrderSend("EURUSD",OP_SELLSTOP,0.01, Bid-10*Point, 0,0,clrGreen);
 
}
else
{
 
Print("Error opening SELLSTOP order : ", GetLastError());
}
Do NOT look at GLE unless you have an error.
if (Count==1 )
 {
  ticket=OrderSend("EURUSD",OP_SELLSTOP,0.01, Bid-10*Point, 0,0,clrGreen);
  if(ticket < 0) Print("Error opening SELLSTOP order : ", GetLastError());
}
mrgoodprice144
42
mrgoodprice144 2016.03.23 08:52  
Now i have a 130 ERROR : 2016.03.23 09:48:06.227    TEST88 EURUSD,M15: Error opening SELLSTOP order : 130
 at least it came out with a number instead of 0.
whroeder1
13644
whroeder1 2016.03.23 13:22  
Now compare your call
 ticket=OrderSend("EURUSD",OP_SELLSTOP,0.01, Bid-10*Point, 0,0,clrGreen);
with the documentation
I'm pretty sure that a take profit of clrGreen is probably a

130

ERR_INVALID_STOPS

Invalid stops

int  OrderSend(
   string   symbol,              // symbol
   int      cmd,                 // operation
   double   volume,              // volume
   double   price,               // price
   int      slippage,            // slippage
   double   stoploss,            // stop loss
   double   takeprofit,          // take profit
   string   comment=NULL,        // comment
   int      magic=0,             // magic number
   datetime expiration=0,        // pending order expiration
   color    arrow_color=clrNONE  // color
   );
/
To add comments, please log in or register