Errors, bugs, questions - page 1739

 

Do I understand correctly that modifying orders through SB will not work in an exchange?

//+------------------------------------------------------------------+
//| Modify specified pending order                                   |
//+------------------------------------------------------------------+
bool CTrade::OrderModify(const ulong ticket,const double price,const double sl,const double tp,
                         const ENUM_ORDER_TYPE_TIME type_time,const datetime expiration,const double stoplimit)
  {
//--- check stopped
   if(IsStopped(__FUNCTION__))
      return(false);
//--- clean
   ClearStructures();
//--- setting request
   m_request.action      =TRADE_ACTION_MODIFY;
   m_request.magic       =m_magic;
   m_request.order       =ticket;
   m_request.price       =price;
   m_request.stoplimit   =stoplimit;
   m_request.sl          =sl;
   m_request.tp          =tp;
   m_request.type_time   =type_time;
   m_request.expiration  =expiration;
//--- action and return the result
   return(OrderSend(m_request,m_result));
  }

It is not set.

 
SB on all trading servers
//+------------------------------------------------------------------+
//| Get the property value "ORDER_TYPE_FILLING"                      |
//+------------------------------------------------------------------+
ENUM_ORDER_TYPE_FILLING COrderInfo::TypeFilling(void) const
  {
   return((ENUM_ORDER_TYPE_FILLING)OrderGetInteger(ORDER_TYPE_FILLING));
  }

ALWAYS returnsENUM_ORDER_TYPE_FILLING::ORDER_FILLING_RETURN in the tester.

fxsaber:

The filling is not set.

So if you set filling in OrderModify via COrderInfo::TypeFilling(), then on RoboForexEU-MetaTrader 5 there will be a logical error [Unsupported filling mode]. However, this error doesn't occur in MetaQuotes-Demo - wrongly configured developer's server?


 
fxsaber:

Do I understand correctly that modifying orders through SB will not work in an exchange?

//+------------------------------------------------------------------+
//| Modify specified pending order                                   |
//+------------------------------------------------------------------+
bool CTrade::OrderModify(const ulong ticket,const double price,const double sl,const double tp,
                         const ENUM_ORDER_TYPE_TIME type_time,const datetime expiration,const double stoplimit)
  {
//--- check stopped
   if(IsStopped(__FUNCTION__))
      return(false);
//--- clean
   ClearStructures();
//--- setting request
   m_request.action      =TRADE_ACTION_MODIFY;
   m_request.magic       =m_magic;
   m_request.order       =ticket;
   m_request.price       =price;
   m_request.stoplimit   =stoplimit;
   m_request.sl          =sl;
   m_request.tp          =tp;
   m_request.type_time   =type_time;
   m_request.expiration  =expiration;
//--- action and return the result
   return(OrderSend(m_request,m_result));
  }

It does not.

Do not panic!

class CTrade : public CObject
  {
protected:
   MqlTradeRequest   m_request;         // request data
   MqlTradeResult    m_result;          // result data
   MqlTradeCheckResult m_check_result;  // result check data
   bool              m_async_mode;      // trade mode
   ulong             m_magic;           // expert magic number
   ulong             m_deviation;       // deviation default
   ENUM_ORDER_TYPE_FILLING m_type_filling;
   ENUM_ACCOUNT_MARGIN_MODE m_margin_mode;
   //---
   ENUM_LOG_LEVELS   m_log_level;

public:
 
Alexey Kozitsyn:

Don't panic!

//+------------------------------------------------------------------+
//| Modify specified pending order                                   |
//+------------------------------------------------------------------+
bool CTrade::OrderModify(const ulong ticket,const double price,const double sl,const double tp,
                         const ENUM_ORDER_TYPE_TIME type_time,const datetime expiration,const double stoplimit)
  {
//--- check stopped
   if(IsStopped(__FUNCTION__))
      return(false);
//--- clean
   ClearStructures();

//--- setting request
   m_request.action      =TRADE_ACTION_MODIFY;
   m_request.magic       =m_magic;
   m_request.order       =ticket;
   m_request.price       =price;
   m_request.stoplimit   =stoplimit;
   m_request.sl          =sl;
   m_request.tp          =tp;
   m_request.type_time   =type_time;
   m_request.expiration  =expiration;
//--- action and return the result
   return(OrderSend(m_request,m_result));
  }
 
fxsaber:
//+------------------------------------------------------------------+
//| Modify specified pending order                                   |
//+------------------------------------------------------------------+
bool CTrade::OrderModify(const ulong ticket,const double price,const double sl,const double tp,
                         const ENUM_ORDER_TYPE_TIME type_time,const datetime expiration,const double stoplimit)
  {
//--- check stopped
   if(IsStopped(__FUNCTION__))
      return(false);
//--- clean
   ClearStructures();

//--- setting request
   m_request.action      =TRADE_ACTION_MODIFY;
   m_request.magic       =m_magic;
   m_request.order       =ticket;
   m_request.price       =price;
   m_request.stoplimit   =stoplimit;
   m_request.sl          =sl;
   m_request.tp          =tp;
   m_request.type_time   =type_time;
   m_request.expiration  =expiration;
//--- action and return the result
   return(OrderSend(m_request,m_result));
  }

Wait, why specify the fill type when modifying at all?

From the documentation:

Trade order to modify StopLoss and/or TakeProfit levels. Requires 4 (jamb:)) fields to be specified:

  • action
  • symbol
  • sl
  • tp
  • position
 
Alexey Kozitsyn:

Wait, why specify the fill type when modifying at all?

From the documentation:

Don't believe everything it says. It MUST be specified. Otherwise it will not work.

I can't use SB. But you can try OrderModify on exchange to make sure of the bug.

 
fxsaber:

Don't believe everything that is written. You MUST specify. Otherwise it won't work.

I totally agree, but...

I don't know how to use SB. But you can try OrderModify on the exchange to make sure of the bug.

But MQ even added an example in the doc... It's not indicated there...

Also there is an Expert Advisor I wrote, which works on the exchange and uses such a piece of code:

         //--- Модифицируем ордер
         trade.OrderModify( order.Ticket(), order.PriceOpen(), newSl, newTp, order.TypeTime(), 0 );
 
Alexey Kozitsyn:

But MQ even added an example to the doc... It doesn't specify...

Wrong, people. We have to correct both doc and SB.

Alexey Kozitsyn:

Also, there's an EA I wrote that works on an exchange and uses such a piece of code:

         //--- Модифицируем ордер
         trade.OrderModify( order.Ticket(), order.PriceOpen(), newSl, newTp, order.TypeTime(), 0 );

And in the tester?

 
fxsaber:
Wrong, people. You have to correct both the doc and the SB.
Try to modify the order on the exchange first and then talk.
 
fxsaber:

Wrong, people. You have to correct both the doc and the SB.

And in the tester?

Works already with warrants installed. Didn't race in the tester.