Error 4753: The Buy order request could not be completed

 

Hi!, i'm new in mql5. i'm trying to make an expert that sends a sell order depending of a trading signal, but i get the error 4753. Can someone help me?

This is the code. Thank´s for the help

This expert only makes an operation only if no exists open positions. 

//+------------------------------------------------------------------+
//|                                                   Estrategia.mq5 |
//|                        Copyright 2020, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2020, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#include <trade\trade.mqh> 
input int       MA8_Period = 8;                 // Media Movil de 40
input int       MA40_Period = 40;                 // Media movil de 8
input int       Stop_Loss = 30; //Factor_sl - Stop_Loss
input int       Take_Profit = 100;
int             EA_Magic = 31415;
int MA8_Handle;
int MA40_Handle;
//int Standard_Dev;
//int previous_bars = Bars(_Symbol, _Period);
int total_bars;
double Custom_Lot = 0.1; //Scale - Custom_Lot
double Stop, Take;
double Balance = AccountInfoDouble(ACCOUNT_EQUITY);
double Ratio = 1;
double Inversion = 0.05;


input double    Min_Neutral_Signal = 0.4;
input double    Max_Neutral_Signal = 0.6;

//int Factor_Stop = 100;
//double Inversion = 0.05;
//double Scale = 0.1;
//double Ratio = 1.0;
//double Stop_Loss_Price;
//double Breakeven = FLT_MAX;
//double Plusvalia = AccountInfoDouble(ACCOUNT_EQUITY);

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
    
    MA8_Handle = iMA(_Symbol,_Period,MA8_Period,0,MODE_EMA,PRICE_CLOSE);
    MA40_Handle = iMA(_Symbol,_Period,MA40_Period,0,MODE_EMA,PRICE_CLOSE);
    //Standard_Dev = iStdDev(NULL,0,8,0,MODE_EMA,PRICE_CLOSE);

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

   MqlTick latest_price;      // To be used for getting recent/latest price quotes
   MqlTradeRequest mrequest;  // To be used for sending our trade requests
   MqlTradeResult mresult;    // To be used to get our trade results
   MqlRates mrate;
   MqlTradeCheckResult check_the_result;

   static datetime Old_Bar;
   datetime New_Bar[1];
   bool Is_New_Bar = false;
   int Copied = CopyTime(_Symbol,_Period,0,1,New_Bar);
   
   if (Copied > 0) // ok, the data has been copied successfully
     {
         if( Old_Bar != New_Bar[0]) // if old time isn't equal to new bar time
         {
            Is_New_Bar = true;   // if it isn't a first call, the new bar has appeared
            if( MQL5InfoInteger(MQL5_DEBUGGING) ) 
            {
               //Print("Nueva: ",New_Bar[0]," Anterior: ",Old_Bar);
            }
            Old_Bar = New_Bar[0];            // saving bar time
        }
     }
     
   if(Is_New_Bar == false)
     {
      return;
     }
    
    bool Buy_Opened = false;
    bool Sell_Opened = false; 
        
    if(PositionSelect(_Symbol)==true)
    {
         if (PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_SELL)
         {
            Sell_Opened = true;
            Alert("Open Sell");
         }
         else if (PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_BUY)
         {
            Buy_Opened = true;
            Alert("Open Buy");
         }
    }
    double Trade_Signal = 0.3;
    
    double copy1[1];
    double Copy = CopyClose(_Symbol, _Period, 0, 1, copy1);
    double Price = copy1[0];
    if(Trade_Signal < Min_Neutral_Signal)
      {
         if(!Sell_Opened)
           {
               ZeroMemory(mrequest);
               ZeroMemory (mresult);   
               
               Stop = Price + 100*Stop_Loss * _Point;
               Take = Price - 100*Take_Profit* _Point;
               Alert("Price Close: ", Price, " ", "Stop: ", Stop, " ", "Take: ", Take);
               
                 mrequest.action = TRADE_ACTION_DEAL;
                 mrequest.price = NormalizeDouble(Price, _Digits);
                 mrequest.sl = NormalizeDouble(Price + Stop*_Point, _Digits);
                 mrequest.tp = NormalizeDouble(Price - Take*_Point, _Digits);      
                 mrequest.symbol = _Symbol;      
                 mrequest.volume = Custom_Lot;
                 mrequest.magic = EA_Magic;
                 mrequest.type = ORDER_TYPE_SELL;
                 mrequest.type_filling = ORDER_FILLING_FOK;
                 mrequest.deviation = 100.0;    
		 OrderSend(mrequest, mresult);

           
               if(mresult.retcode==10009 || mresult.retcode==10008) //Request is completed or order placed
               {
                  Alert("A Buy order has been successfully placed with Ticket#:",mresult.order,"!!");
               }
               else
               {
                  Alert("The Buy order request could not be completed -error:",GetLastError());
                  ResetLastError();           
                  return;
               
               }
           }
      }
       
     
} 
 
Where is the OrderSend() call ?
 
Alain Verleyen:
Where is the OrderSend() call ?

I'm sorry, i forgot put it. I edited the code with the OrderSend() function, however the problem follows. 

 
  1. 4753 is not " Buy order request could not be completed"
  2.                  mrequest.price = NormalizeDouble(Price, _Digits);
                     mrequest.sl = NormalizeDouble(Price + Stop*_Point, _Digits);
                     mrequest.tp = NormalizeDouble(Price - Take*_Point, _Digits);      
    
    You buy at the Ask and sell at the Bid. So for buy orders you pay the spread on open. For sell orders you pay the spread on close.
    1. Your buy order's TP/SL (or Sell Stop's/Sell Limit's entry) are triggered when the Bid reaches it. Not the Ask. Your SL is shorter by the spread and your TP would be longer. Don't you want the same/specified amount for either direction?
    2. Your sell order's TP/SL (or Buy Stop's/Buy Limit's entry) will be triggered when the Ask 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.)

 
it works!!. Thank's to all for the recommendations!. 
Reason: