TRADE_RETCODE_REJECT error by server

 

Hi All


 I am new to expert programming and need to setup my Metatrader 5 up & running .

 So I wrote a simple expert and when I am trying it server will send 

 retcode 10014 in result and error number 4756 is returned by GetLastError() function

 I add the expert script here , please don't laugh at my always true condition I am aware of it it is only for testing

 I am sure my price is OK and account is a real account I am able to send this order manually to the server

 Any ideas what is wrong ? or similar problem?

  Appreciate it

 Regards

Mosn

 


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

        {
        MqlTradeRequest mrequest;  // To be used for sending our trade requests
        MqlTradeResult mresult;    // To be used to get our trade results
         ZeroMemory(mrequest);
         mrequest.action = TRADE_ACTION_DEAL;                                  // immediate order execution
         mrequest.type = ORDER_TYPE_BUY;                                        // Buy Order
         mrequest.symbol = _Symbol;                                            // currency pair
         mrequest.deviation=0;                                                // Deviation from current price
         mrequest.price = 1395;
         mrequest.volume = 1000;                                                 // number of lots to trade
         mrequest.tp=0;
         mrequest.sl=0;
         mrequest.type_filling = ORDER_FILLING_RETURN;                             // Order execution type        
         //--- send order
         OrderSend(mrequest,mresult);
         // get the result code
         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());
            Alert("The Buy order request could not be completed -error:",mresult.retcode);
            ResetLastError();          
            return;
           }
           }

  }
//+------------------------------------------------------------------+

Automated Trading and Strategy Testing
Automated Trading and Strategy Testing
  • www.mql5.com
MQL5: language of trade strategies built-in the MetaTrader 5 Trading Platform, allows writing your own trading robots, technical indicators, scripts and libraries of functions
 

Hi


I think your traded volume is incorrect, the lotsize is too high (1000).

https://www.mql5.com/en/docs/constants/errorswarnings/enum_trade_return_codes


Change 1000 to 1 and check it again.

Documentation on MQL5: Standard Constants, Enumerations and Structures / Codes of Errors and Warnings / Trade Server Return Codes
Documentation on MQL5: Standard Constants, Enumerations and Structures / Codes of Errors and Warnings / Trade Server Return Codes
  • www.mql5.com
Standard Constants, Enumerations and Structures / Codes of Errors and Warnings / Trade Server Return Codes - Reference on algorithmic/automated trading language for MetaTrader 5
 

Hi snelle_moda

 My target market is my country stock exchange market not Forex. As I mention I am able to send manual buy order from meta trader with volume=1000

 and server will execute it. So I think volume is not the issue


Cheers

Mosn