ERROR CODE: Return value of 'OrderSend' should be checked!

 

Hey Guys


I'm receiving this error "Return value of 'OrderSend' should be checked! " in my code, on Lines 49 and 65 which are the "OrderSend" for Buy or Sell, what is wrong?


thanks!


//+------------------------------------------------------------------+
//|                                                          123.mq4 |
//|                                                        @VALENPTY |
//|                                                                . |
//+------------------------------------------------------------------+
#property copyright "@VALENPTY"
#property link      "."
#property version   "1.00"
#property strict
double AskPr = 0.74505;
// Define a variable for the previous week low
double BidPr = 0.73105;
// Define a variable for the previous week high
 

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {

 
   // If we have no open orders
   if (OrdersTotal()==0)
   
   // If the price is above pwh  
   if (Ask > AskPr)
   
   // Open a sell position
   {
      OrderSend (_Symbol,OP_SELL,0.10,Ask,3,Ask+20*_Point,Bid-60*_Point,NULL,0,0,Green);
        
   Comment(
            "PWH: ",AskPr,"\n",
            "PWL: ",BidPr,"\n",
            "Price: ",Ask,"\n",
            "Price is above PWH: ",AskPr
            );
             }
 
        else if (Bid<BidPr)
   // If the price is below pwl 
   
   
   // Open a buy position
   {
      OrderSend (_Symbol,OP_BUY,0.10,Bid,3,Bid-20*_Point,Ask+60*_Point,NULL,0,0,Green);
         
   Comment(
            "PWH: ",AskPr,"\n",
            "PWL: ",BidPr,"\n",
            "Price: ",Bid,"\n",
            "Price is below PWL: ",BidPr
            );
   }
   
}
 
int ticket = OrderSend (_Symbol,OP_BUY,0.10,Bid,3,Bid-20*_Point,Ask+60*_Point,NULL,0,0,Green);

Analyze if the call was successful or not.

 
  1. Why did you post your MT4 question in the MT5 EA section instead of the MQL4 section, (bottom of the Root page?)
              General rules and best pratices of the Forum. - General - MQL5 programming forum?
    Next time post in the correct place. The moderators will likely move this thread there soon.

  2. Check your return codes.

    Don't look at GLE/LE unless you have an error. Don't just silence the compiler, it is trying to help you.
              What are Function return values ? How do I use them ? - MQL4 programming forum
              Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles

  3. You buy at the Ask and sell at the Bid.
    1. Your buy order's TP/SL (or Sell Stop's/Sell Limit's entry) are triggered when the Bid / OrderClosePrice reaches it. Using the Ask±n, makes your SL shorter and your TP longer, by the spread. Don't you want the specified amount used in either direction?

    2. Your sell order's TP/SL (or Buy Stop's/Buy Limit's entry) will be triggered when the Ask / OrderClosePrice reaches it. To trigger at a specific Bid price, add the average spread.
                MODE_SPREAD (Paul) - MQL4 programming forum - Page 3 #25

    3. The charts show Bid prices only. Turn on the Ask line to see how big the spread is (Tools → Options (control+O) → charts → Show ask line.)
      Most brokers with variable spread widen considerably at end of day (5 PM ET) ± 30 minutes. My GBPJPY (OANDA) shows average spread = 26 points, but average maximum spread = 134.
 

thanks!


sorry I didint see I was in wrong forum

William Roeder:
  1. Why did you post your MT4 question in the MT5 EA section instead of the MQL4 section, (bottom of the Root page?)
              General rules and best pratices of the Forum. - General - MQL5 programming forum?
    Next time post in the correct place. The moderators will likely move this thread there soon.

  2. Check your return codes.

    Don't look at GLE/LE unless you have an error. Don't just silence the compiler, it is trying to help you.
              What are Function return values ? How do I use them ? - MQL4 programming forum
              Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles

  3. You buy at the Ask and sell at the Bid.
    1. Your buy order's TP/SL (or Sell Stop's/Sell Limit's entry) are triggered when the Bid / OrderClosePrice reaches it. Using the Ask±n, makes your SL shorter and your TP longer, by the spread. Don't you want the specified amount used in either direction?

    2. Your sell order's TP/SL (or Buy Stop's/Buy Limit's entry) will be triggered when the Ask / OrderClosePrice reaches it. To trigger at a specific Bid price, add the average spread.
                MODE_SPREAD (Paul) - MQL4 programming forum - Page 3 #25

    3. The charts show Bid prices only. Turn on the Ask line to see how big the spread is (Tools → Options (control+O) → charts → Show ask line.)
      Most brokers with variable spread widen considerably at end of day (5 PM ET) ± 30 minutes. My GBPJPY (OANDA) shows average spread = 26 points, but average maximum spread = 134.
 
what do I do with this code???
Marco vd Heijden:

Analyze if the call was successful or not.