AMP MT5 version 5 build 3037 Can't send pending order

 

I have an EA that works fine in AMP future MT5 platform demo account. However, it won't send buy limit and sell limit order in their live account. Contact AMP trade desk they said they received  order as a Fill or Kill order and I need to remove that setting. I don't know where I need to change in following code so that the pending limit order will be accepted. Please help.


void PendingOrderSend(ENUM_ORDER_TYPE inOrderType, double inPrice,double inLot,int inStopLoss,int inTakeProfit, int inMagic, int inTrailing)
{
  MqlTradeRequest request={0};
  MqlTradeResult  result={0};
  //--- 请求的参数
  request.action   = TRADE_ACTION_PENDING;                  
  request.symbol   = _Symbol;                              
  request.type     = inOrderType;                          
  request.price    = inPrice;
  request.volume   = inLot;                              
  
  if(inOrderType == ORDER_TYPE_BUY_LIMIT || inOrderType == ORDER_TYPE_BUY_STOP)
  {
    if(inStopLoss > 0)
    {
      request.sl = inPrice -  inStopLoss * _Point;
    }
    else
    {
      request.sl = 0;
    }
    if(inTakeProfit > 0)
    {
      request.tp = inPrice +  inTakeProfit * _Point;
    }
    else
    {
      request.tp = 0;
    }
  }
  else if(inOrderType == ORDER_TYPE_SELL_LIMIT || inOrderType == ORDER_TYPE_SELL_STOP)
  {
    if(inStopLoss > 0)
    {
      request.sl = inPrice +  inStopLoss * _Point;
    }
    else
    {
      request.sl = 0;
    }
    if(inTakeProfit > 0)
    {
      request.tp = inPrice -  inTakeProfit * _Point;
    }
    else
    {
      request.tp = 0;
    }
  }
  
  request.deviation = 5;                                 
  request.magic = inMagic;                              
  
  
  //---
  if(!OrderSend(request,result))
  {
     PrintFormat("OrderSend error %d",GetLastError());     
  }
  else //--- 
  {
    PrintFormat("OrderSend success.");
    GVSet("Trailing value" + IntegerToString(result.order), inTrailing);
  }  
}
 
XIn Li:

I have an EA that works fine in AMP future MT5 platform demo account. However, it won't send buy limit and sell limit order in their live account. Contact AMP trade desk they said they received  order as a Fill or Kill order and I need to remove that setting. I don't know where I need to change in following code so that the pending limit order will be accepted. Please help.


You haven't yet detected the reference of MQL5 and the easy way to use it? Just place the cursor on MqlTradeRequest and press F1 then start reading the example. There you'll find all you need!
 
Carl Schreiber #:
You haven't yet detected the reference of MQL5 and the easy way to use it? Just place the cursor on MqlTradeRequest and press F1 then start reading the example. There you'll find all you need!

Thanks Carl for your reply. Is the example in the page you referred to

https://www.mql5.com/en/docs/constants/structures/mqltraderequest?  still can't find out why it won't send limit orders.

Documentation on MQL5: Constants, Enumerations and Structures / Data Structures / Trade Request Structure
Documentation on MQL5: Constants, Enumerations and Structures / Data Structures / Trade Request Structure
  • www.mql5.com
Trade Request Structure - Data Structures - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 

You have to set request.type_filling  - Have another look at the documentation  mentioned.

 
Douglas Prager #:

You have to set request.type_filling  - Have another look at the documentation  mentioned.

Thank you. I got it.