Bibliotecas: MT4Orders - página 16

 

Foro sobre negociación, sistemas automatizados de negociación y ensayo de estrategias de negociación

Características del lenguaje mql4, sutilezas y técnicas de trabajo

fxsaber, 2017.09.11 20:29

A continuación se tocará el tema, que se refiere no sólo MT4, sino también MT5 con otras plataformas. Pero para una fácil percepción, la lógica será escrito en MQL4, por lo que en este hilo.

Discusión directamente relacionada con la biblioteca.

 

posición abierta son aceptados por el servidor de trading, se genera la orden de mercado correspondiente, que está en la tabla de órdenes abiertas de MT5 hasta que se ejecuta.


Por lo tanto, en MT5, incluso en MQL5 puro, la modificación/eliminación de dichas órdenes es imposible y la lógica de trading de MT5 requiere comprobar si una orden abierta está realmente congelada o no.


A continuación se muestra la condición para identificar este tipo de órdenes al escribir la lógica de trading en MT4Orders y un ejemplo de su activación

// Activar SL/TP/SO
void OnTradeTransaction ( const MqlTradeTransaction &Trans, const MqlTradeRequest &Request, const MqlTradeResult &Result )
{ 
  if ((Trans.type == TRADE_TRANSACTION_ORDER_ADD) && OrderSelect(Trans.order))
  {
    const ENUM_ORDER_REASON Reason = (ENUM_ORDER_REASON)OrderGetInteger(ORDER_REASON);
    
    if (Reason == ORDER_REASON_TP)
      Print("Position #" + (string)Trans.position + " - triggered TP.");    
    else if (Reason == ORDER_REASON_SL)
      Print("Position #" + (string)Trans.position + " - triggered SL.");    
    else if (Reason == ORDER_REASON_SO)
      Print("Position #" + (string)Trans.position + " - triggered StopOut.");    
  }
}

#include <MT4Orders.mqh>

#define Bid SymbolInfoDouble(_Symbol, SYMBOL_BID)
#define Ask SymbolInfoDouble(_Symbol, SYMBOL_ASK)

void OnInit()
{
  EventSetMillisecondTimer(1);
  
  OrderSend(_Symbol, OP_BUY, 1, Ask, 100, Bid - _Point, Ask + _Point);    
}

// Mostrar que las órdenes SL/TP/SO están presentes en la tabla actual de órdenes abiertas de MT5
void OnTimer()
{
  for (int i = OrdersTotal() - 1; i >= 0; i--)
    if (OrderSelect(i, SELECT_BY_POS) &&
        (OrderCloseReason() >= (int)ORDER_REASON_SL)) // Si se activa esta condición, ¡no podrá modificar/borrar el pedido!
    {
      OrderPrint();
      
      const long Position = OrderGetInteger(ORDER_POSITION_ID); // Posiblemente, ya que MT4Orders está configurado para trabajar en paralelo con la API de trading MQL5
      
      const ENUM_ORDER_REASON Reason = (ENUM_ORDER_REASON)OrderCloseReason();
      
      if (Reason == ORDER_REASON_TP)
        Print("Position #" + (string)Position + " - in the process of execution TP.");    
      else if (Reason == ORDER_REASON_SL)
        Print("Position #" + (string)Position + " - in the process of execution SL.");    
      else if (Reason == ORDER_REASON_SO)
        Print("Position #" + (string)Position + " - in the process of execution StopOut.");
    }
}


Resultado

2017.09.14 09:35:11.565 Position #1060283 - triggered TP.
2017.09.14 09:35:11.575 #1060284 2017.09.14 09:36:14 sell 1.00 EURUSD 1.18838 0.00000 0.00000 1.18838 0.00 0.00 0.00 [tp 1.18838] 0
2017.09.14 09:35:11.575 Position #1060283 - in the process of execution TP.
2017.09.14 09:35:11.595 #1060284 2017.09.14 09:36:14 sell 1.00 EURUSD 1.18838 0.00000 0.00000 1.18838 0.00 0.00 0.00 [tp 1.18838] 0
2017.09.14 09:35:11.595 Position #1060283 - in the process of execution TP.
2017.09.14 09:35:11.607 #1060284 2017.09.14 09:36:14 sell 1.00 EURUSD 1.18838 0.00000 0.00000 1.18838 0.00 0.00 0.00 [tp 1.18838] 0
2017.09.14 09:35:11.607 Position #1060283 - in the process of execution TP.
2017.09.14 09:35:11.617 #1060284 2017.09.14 09:36:14 sell 1.00 EURUSD 1.18838 0.00000 0.00000 1.18838 0.00 0.00 0.00 [tp 1.18838] 0
2017.09.14 09:35:11.617 Position #1060283 - in the process of execution TP.
2017.09.14 09:35:11.637 #1060284 2017.09.14 09:36:14 sell 1.00 EURUSD 1.18838 0.00000 0.00000 1.18838 0.00 0.00 0.00 [tp 1.18838] 0
2017.09.14 09:35:11.637 Position #1060283 - in the process of execution TP.
2017.09.14 09:35:11.657 #1060284 2017.09.14 09:36:14 sell 1.00 EURUSD 1.18838 0.00000 0.00000 1.18838 0.00 0.00 0.00 [tp 1.18838] 0
2017.09.14 09:35:11.657 Position #1060283 - in the process of execution TP.
2017.09.14 09:35:11.667 #1060284 2017.09.14 09:36:14 sell 1.00 EURUSD 1.18838 0.00000 0.00000 1.18838 0.00 0.00 0.00 [tp 1.18838] 0
2017.09.14 09:35:11.667 Position #1060283 - in the process of execution TP.
2017.09.14 09:35:11.680 #1060284 2017.09.14 09:36:14 sell 1.00 EURUSD 1.18838 0.00000 0.00000 1.18838 0.00 0.00 0.00 [tp 1.18838] 0
2017.09.14 09:35:11.680 Position #1060283 - in the process of execution TP.
2017.09.14 09:35:11.700 #1060284 2017.09.14 09:36:14 sell 1.00 EURUSD 1.18838 0.00000 0.00000 1.18838 0.00 0.00 0.00 [tp 1.18838] 0
2017.09.14 09:35:11.700 Position #1060283 - in the process of execution TP.
2017.09.14 09:35:11.710 #1060284 2017.09.14 09:36:14 sell 1.00 EURUSD 1.18838 0.00000 0.00000 1.18838 0.00 0.00 0.00 [tp 1.18838] 0
2017.09.14 09:35:11.710 Position #1060283 - in the process of execution TP.
2017.09.14 09:35:11.730 #1060284 2017.09.14 09:36:14 sell 1.00 EURUSD 1.18838 0.00000 0.00000 1.18838 0.00 0.00 0.00 [tp 1.18838] 0
2017.09.14 09:35:11.730 Position #1060283 - in the process of execution TP.
2017.09.14 09:35:11.757 #1060284 2017.09.14 09:36:14 sell 1.00 EURUSD 1.18838 0.00000 0.00000 1.18838 0.00 0.00 0.00 [tp 1.18838] 0
2017.09.14 09:35:11.757 Position #1060283 - in the process of execution TP.
2017.09.14 09:35:11.760 #1060284 2017.09.14 09:36:14 sell 1.00 EURUSD 1.18838 0.00000 0.00000 1.18838 0.00 0.00 0.00 [tp 1.18838] 0
2017.09.14 09:35:11.760 Position #1060283 - in the process of execution TP.
2017.09.14 09:35:11.780 #1060284 2017.09.14 09:36:14 sell 1.00 EURUSD 1.18838 0.00000 0.00000 1.18838 0.00 0.00 0.00 [tp 1.18838] 0
2017.09.14 09:35:11.780 Position #1060283 - in the process of execution TP.
2017.09.14 09:35:11.790 #1060284 2017.09.14 09:36:14 sell 1.00 EURUSD 1.18838 0.00000 0.00000 1.18838 0.00 0.00 0.00 [tp 1.18838] 0
2017.09.14 09:35:11.790 Position #1060283 - in the process of execution TP.
2017.09.14 09:35:11.810 #1060284 2017.09.14 09:36:14 sell 1.00 EURUSD 1.18838 0.00000 0.00000 1.18838 0.00 0.00 0.00 [tp 1.18838] 0
2017.09.14 09:35:11.810 Position #1060283 - in the process of execution TP.
2017.09.14 09:35:11.820 #1060284 2017.09.14 09:36:14 sell 1.00 EURUSD 1.18838 0.00000 0.00000 1.18838 0.00 0.00 0.00 [tp 1.18838] 0
2017.09.14 09:35:11.820 Position #1060283 - in the process of execution TP.


Se puede ver que la orden TP estuvo colgada entre las órdenes abiertas durante más de un cuarto de segundo. Cualquier intento de modificarla/eliminarla provocaba errores.

Tenga en cuenta esta característica de MT5 (no sólo cuando trabaje con MT4Orders).

 
fxsaber:

posición abierta son aceptados por el servidor de trading, se genera la orden de mercado correspondiente, que está en la tabla de órdenes abiertas de MT5 hasta que se ejecuta.


Por lo tanto, en MT5, incluso en MQL5 puro, la modificación/eliminación de dichas órdenes es imposible y la lógica de trading de MT5 requiere comprobar si una orden abierta está realmente congelada o no.

A continuación puede ver la condición para identificar este tipo de órdenes al escribir la lógica de trading en MT4Orders y un ejemplo de su activación

Puede ver que la orden TP estuvo colgada entre las órdenes abiertas durante más de un cuarto de segundo. Cualquier intento de modificarla/eliminarla provocaría errores.

Tenga en cuenta esta característica de MT5 (no sólo cuando trabaje con MT4Orders).

La comprobación de esta condición está ahora integrada en la librería, puede trabajar como en MT4

// Lista de cambios:
// 14.09.2017:
// Fix: Ahora la libreria no ve las ordenes actuales de MT5 que no tienen el estado ORDER_STATE_PLACED..
// Para que la librería vea todas las órdenes abiertas de MT5, se debe escribir la siguiente línea ANTES de la librería
//
// #define MT4ORDERS_SELECTFILTER_OFF // Haz que MT4Orders.mqh vea todas las órdenes actuales de MT5
 
Era necesario crear tanto con estas posiciones/órdenes en mt5, en ninguna otra plataforma no he conocido tal variedad )
 
Maxim Dmitrievsky:
Nunca he visto tal variedad en ninguna otra plataforma).

El parámetro ORDER_STATE juega un papel aún más importante. Para órdenes SL/TP es ORDER_STATE_STARTED. Pero nunca se debe ignorar todo ORDER_STATE_STARTED (lleva mucho tiempo explicarlo). Por eso es un error confiar en ORDER_STATE, pero se necesita ORDER_REASON.

ORDER_STATE es otra historia. Supongamos que una posición se abre parcialmente a partir de una orden pendiente, y el resto de la orden sigue pendiente. Entonces hay una operación en el Historial, pero la Orden en sí todavía no está ahí. Si la orden se llena completamente, entonces para entender que la primera operación generada por ella se abrió parcialmente, no puedes mirar el ORDER_STATE de la orden de la que se originó.


De todos modos, hay tantas situaciones con este STATE en realidad..... Es necesario introducir OrderOpenState() y OrderCloseSate() humanos, pero es un rompe cabezas (y sólo unos pocos lo usarán). Y, por supuesto, sigue siendo un simple rompecabezas. Hay muchos, y algunos ni se sospechan. Con todo, es bueno ser capaz de desentrañar parcialmente a un estado de trabajo y la forma humana con casi ninguna pérdida de productividad. Más de la mitad de las necesidades, creo, la biblioteca cumple.

 
fxsaber:

El parámetro ORDER_STATE desempeña un papel aún más importante. Para órdenes SL/TP es ORDER_STATE_STARTED. Pero nunca se debe ignorar todo ORDER_STATE_STARTED (lleva mucho tiempo explicarlo). Por eso es un error confiar en ORDER_STATE, pero se necesita ORDER_REASON.

ORDER_STATE es otra historia. Supongamos que una posición se abre parcialmente a partir de una orden pendiente, y el resto de la orden sigue pendiente. Entonces hay una operación en el Historial, pero la Orden en sí todavía no está ahí. Si la orden se llena completamente, entonces para entender que la primera operación generada por ella se abrió parcialmente, no puedes mirar el ORDER_STATE de la orden de la que se originó.


De todos modos, hay tantas situaciones con este STATE en realidad..... Es necesario introducir OrderOpenState() y OrderCloseSate() humanos, pero es un rompe cabezas (y sólo unos pocos lo usarán). Y, por supuesto, sigue siendo un simple rompecabezas. Hay muchos, y algunos ni se sospechan. Con todo, es bueno ser capaz de desentrañar parcialmente a un estado de trabajo y la forma humana con casi ninguna pérdida de productividad. Creo que la biblioteca satisface más de la mitad de mis necesidades.

Yo lo uso en bots, ni en el probador ni en el real, no se han producido errores todavía, como parece, en Forts en la apertura y forex. Hubo un problema cuando de repente el dts empezó a ejecutar órdenes lentamente (plugin contra arbitraje), no me acuerdo, no me acuerdo, creo que a la liba no le daba tiempo a calcular si la posición ya está en el mercado o no, (un problema con la sincronización del histórico, que yo recuerde) y estampaba un montón de órdenes seguidas, pero luego hacías una actualización y se ponía como un reloj. Así que más de la mitad por lo menos :)
 

Foro sobre negociación, sistemas automatizados de negociación y ensayo de estrategias de negociación

Asesores Expertos: Quantum 103

fxsaber, 2017.09.26 09:55 pm.

Variante multiplataforma del asesor experto.
// Código MQL4&5

#ifdef __MQL5__

bool RefreshRates( void ) { return(true); }

double MarketInfo( const string Symb, const ENUM_SYMBOL_INFO_DOUBLE Property )  { return(SymbolInfoDouble(Symb, Property)); }
int    MarketInfo( const string Symb, const ENUM_SYMBOL_INFO_INTEGER Property ) { return((int)SymbolInfoInteger(Symb, Property)); }

bool IsTesting(void)            { return(MQLInfoInteger(MQL_TESTER) || MQLInfoInteger(MQL_OPTIMIZATION)); }
bool IsTradeContextBusy( void ) { return(false); }
bool IsTradeAllowed(void)       { return(MQLInfoInteger(MQL_TRADE_ALLOWED)); }
bool IsExpertEnabled(void)      { return(AccountInfoInteger(ACCOUNT_TRADE_EXPERT)); }

int    ObjectFind( const string Name )   { return(ObjectFind(0, Name)); }
int    ObjectsTotal( void )              { return(ObjectsTotal(0)); }
bool   ObjectDelete( const string Name ) { return(ObjectDelete(0, Name)); }
string ObjectName( const int Pos )       { return(ObjectName(0, Pos)); }

double AccountFreeMarginCheck(const string Symb,const int Cmd,const double dVolume)
{
 double Margin;

 return(OrderCalcMargin((ENUM_ORDER_TYPE)Cmd, Symb, dVolume,
        SymbolInfoDouble(Symb, (Cmd == ORDER_TYPE_BUY) ? SYMBOL_ASK : SYMBOL_BID), Margin) ?
        AccountInfoDouble(ACCOUNT_MARGIN_FREE) - Margin : -1);
}

#define False false
#define True  true

#define Digits _Digits
#define Point  _Point

#define MODE_BID       SYMBOL_BID
#define MODE_ASK       SYMBOL_ASK
#define MODE_POINT     SYMBOL_POINT
#define MODE_DIGITS    SYMBOL_DIGITS
#define MODE_STOPLEVEL SYMBOL_TRADE_STOPS_LEVEL
#define MODE_SPREAD    SYMBOL_SPREAD

#define StrToTime    StringToTime
#define StrToInteger StringToInteger
#define TimeToStr    TimeToString
#define DoubleToStr  DoubleToString

#define Bid SymbolInfoDouble(_Symbol, SYMBOL_BID)
#define Ask SymbolInfoDouble(_Symbol, SYMBOL_ASK)

#define   MT4_TICKET_TYPE // Obligar a OrderSend y OrderTicket a devolver un valor del mismo tipo que en MT4 - int.
#include <MT4Orders.mqh> // https://www.mql5.com/es/code/16006

// Necesario para los gráficos de los informes
// #include <TypeToBytes.mqh> // https://www.mql5.com/es/code/16280

#define  REPORT_TESTER // El comprobador registrará automáticamente los informes
#include <Report.mqh> // https://www.mql5.com/es/code/18801

#endif // __MQL5__

#include "Quantum 103.mq4" // https://www.mql5.com/es/code/19133

Resultado del backtest sobre ticks reales en MT5

Informe estándar MT5

Informe personalizado (estilo MT4)


He adjuntado el informe backtest MT5 estilo MT4 porque el informe estándar es difícil de leer - ver ambos en el trailer.

Puede ver claramente el impacto de los deslizamientos y las comisiones en el resultado del backtest MT5 de este EA.

 

Форум по трейдингу, автоматическим торговым системам и тестированию торговых стратегий

Советники: Quantum 103

fxsaber, 2017.09.26 09:55

Versión multiplataforma del asesor experto.
// Código MQL4&5

#ifdef __MQL5__

bool RefreshRates( void ) { return(true); }

double MarketInfo( const string Symb, const ENUM_SYMBOL_INFO_DOUBLE Property )  { return(SymbolInfoDouble(Symb, Property)); }
int    MarketInfo( const string Symb, const ENUM_SYMBOL_INFO_INTEGER Property ) { return((int)SymbolInfoInteger(Symb, Property)); }

bool IsTesting(void)            { return(MQLInfoInteger(MQL_TESTER) || MQLInfoInteger(MQL_OPTIMIZATION)); }
bool IsTradeContextBusy( void ) { return(false); }
bool IsTradeAllowed(void)       { return(MQLInfoInteger(MQL_TRADE_ALLOWED)); }
bool IsExpertEnabled(void)      { return(AccountInfoInteger(ACCOUNT_TRADE_EXPERT)); }

int    ObjectFind( const string Name )   { return(ObjectFind(0, Name)); }
int    ObjectsTotal( void )              { return(ObjectsTotal(0)); }
bool   ObjectDelete( const string Name ) { return(ObjectDelete(0, Name)); }
string ObjectName( const int Pos )       { return(ObjectName(0, Pos)); }

double AccountFreeMarginCheck(const string Symb,const int Cmd,const double dVolume)
{
 double Margin;

 return(OrderCalcMargin((ENUM_ORDER_TYPE)Cmd, Symb, dVolume,
        SymbolInfoDouble(Symb, (Cmd == ORDER_TYPE_BUY) ? SYMBOL_ASK : SYMBOL_BID), Margin) ?
        AccountInfoDouble(ACCOUNT_MARGIN_FREE) - Margin : -1);
}

#define False false
#define True  true

#define Digits _Digits
#define Point  _Point

#define MODE_BID       SYMBOL_BID
#define MODE_ASK       SYMBOL_ASK
#define MODE_POINT     SYMBOL_POINT
#define MODE_DIGITS    SYMBOL_TRADE_STOPS_LEVEL
#define MODE_STOPLEVEL SYMBOL_TRADE_STOPS_LEVEL
#define MODE_SPREAD    SYMBOL_SPREAD

#define StrToTime    StringToTime
#define StrToInteger StringToInteger
#define TimeToStr    TimeToString
#define DoubleToStr  DoubleToString

#define Bid SymbolInfoDouble(_Symbol, SYMBOL_BID)
#define Ask SymbolInfoDouble(_Symbol, SYMBOL_ASK)

#define   MT4_TICKET_TYPE // Обязываем OrderSend и OrderTicket возвращать значение такого же типа, как в MT4 - int.
#include <MT4Orders.mqh> // https://www.mql5.com/ru/code/16006

// Нужно для графиков в отчетах
// #include <TypeToBytes.mqh> // https://www.mql5.com/ru/code/16280

#define  REPORT_TESTER // В тестере будут автоматически записываться отчеты
#include <Report.mqh> // https://www.mql5.com/ru/code/18801

#endif // __MQL5__

#include "Quantum 103.mq4" // https://www.mql5.com/ru/code/19133

Resultado del backtest sobre ticks reales en MT5

Informe estándar de MT5

Informe personalizado (estilo MT4)


Adjunto informe estilo MT4 MT5-backtest, porque el informe estándar se lee con dificultad - ver ambos en el adjunto.

Se puede ver claramente el impacto en el resultado de MT5-backtest de este asesor deslizamiento y comisión.

 

Foro sobre negociación, sistemas automatizados de negociación y ensayo de estrategias de negociación

Asesores expertos: Mostrar órdenes

fxsaber, 2017.10.09 13:22

Variante de plataforma cruzada
// Código MQL4&5

#ifdef __MQL5__

bool RefreshRates( void ) { return(true); }

double MarketInfo( const string Symb, const ENUM_SYMBOL_INFO_DOUBLE Property )  { return(SymbolInfoDouble(Symb, Property)); }

string AccountCurrency( void ) { return(AccountInfoString(ACCOUNT_CURRENCY)); }
double AccountProfit( void )   { return(AccountInfoDouble(ACCOUNT_PROFIT)); }
double AccountBalance( void )  { return(AccountInfoDouble(ACCOUNT_BALANCE)); }

bool ObjectSet( const string Name, const ENUM_OBJECT_PROPERTY_INTEGER Index, long Value ) { return(ObjectSetInteger(0, Name, Index, Value)); }
bool ObjectDelete( const string Name )   { return(ObjectDelete(0, Name)); }

bool ObjectCreate( const string Name, const ENUM_OBJECT Type, const int SubWindow, const datetime Time1, const double Price1 )
{
  return(ObjectCreate(0, Name, Type, SubWindow, Time1, Price1));
}

bool ObjectSetText( const string Name, const string Text, const int FontSize = 0, const string FontName = NULL, const color TextColor = clrNONE )
{
  return(ObjectSetString(0, Name, OBJPROP_TEXT, Text) && ObjectSetString(0, Name, OBJPROP_FONT, FontName) && ObjectSetInteger(0, Name, OBJPROP_COLOR, TextColor));
}

void OnInit( void ) { init(); }
void OnDeinit( const int Reason ) { deinit(); }

#define extern input

#define MODE_BID       SYMBOL_BID
#define MODE_ASK       SYMBOL_ASK
#define MODE_POINT     SYMBOL_POINT
#define MODE_TICKVALUE SYMBOL_TRADE_TICK_VALUE

#define DoubleToStr DoubleToString

#define  DEFINE_TIMESERIE(NAME,FUNC,T)                                                                         \
  class CLASS##NAME                                                                                           \
  {                                                                                                           \
  public:                                                                                                     \
    static T Get(const string Symb,const int TimeFrame,const int iShift)                                      \
    {                                                                                                         \
      T tValue[];                                                                                             \
                                                                                                              \
      return((Copy##FUNC((Symb == NULL) ? _Symbol : Symb, _Period, iShift, 1, tValue) > 0) ? tValue[0] : -1); \
    }                                                                                                         \
                                                                                                              \
    T operator[](const int iPos) const                                                                        \
    {                                                                                                         \
      return(CLASS##NAME::Get(_Symbol, _Period, iPos));                                                       \
    }                                                                                                         \
  } NAME;                                                                                                     

DEFINE_TIMESERIE(Time,Time,datetime)

#define   MT4_TICKET_TYPE // Obligar a OrderSend y OrderTicket a devolver un valor del mismo tipo que en MT4 - int.
#include <MT4Orders.mqh> // https://www.mql5.com/es/code/16006

#endif // __MQL5__

#include "Display orders.mq4"
 

Foro sobre trading, sistemas automatizados de trading y prueba de estrategias de trading

Asesores Expertos: Xarax

fxsaber, 2017.10.11 13:44

Variante multiplataforma

// Código MQL4&5

#ifdef __MQL5__

bool RefreshRates( void ) { return(true); }

double MarketInfo( const string Symb, const ENUM_SYMBOL_INFO_DOUBLE Property )  { return(SymbolInfoDouble(Symb, Property)); }
int    MarketInfo( const string Symb, const ENUM_SYMBOL_INFO_INTEGER Property ) { return((int)SymbolInfoInteger(Symb, Property)); }

bool IsTesting(void)            { return(MQLInfoInteger(MQL_TESTER) || MQLInfoInteger(MQL_OPTIMIZATION)); }
bool IsTradeContextBusy( void ) { return(false); }
bool IsTradeAllowed(void)       { return(MQLInfoInteger(MQL_TRADE_ALLOWED)); }
bool IsExpertEnabled(void)      { return(AccountInfoInteger(ACCOUNT_TRADE_EXPERT)); }

double AccountFreeMarginCheck(const string Symb,const int Cmd,const double dVolume)
{
 double Margin;

 return(OrderCalcMargin((ENUM_ORDER_TYPE)Cmd, Symb, dVolume,
        SymbolInfoDouble(Symb, (Cmd == ORDER_TYPE_BUY) ? SYMBOL_ASK : SYMBOL_BID), Margin) ?
        AccountInfoDouble(ACCOUNT_MARGIN_FREE) - Margin : -1);
}

#define False false
#define True  true

#define Digits _Digits
#define Point  _Point

#define MODE_BID       SYMBOL_BID
#define MODE_ASK       SYMBOL_ASK
#define MODE_POINT     SYMBOL_POINT
#define MODE_DIGITS    SYMBOL_DIGITS
#define MODE_STOPLEVEL SYMBOL_TRADE_STOPS_LEVEL
#define MODE_LOTSTEP   SYMBOL_VOLUME_STEP

#define Bid SymbolInfoDouble(_Symbol, SYMBOL_BID)
#define Ask SymbolInfoDouble(_Symbol, SYMBOL_ASK)

#define   MT4_TICKET_TYPE // Obligar a OrderSend y OrderTicket a devolver un valor del mismo tipo que en MT4 - int.
#include <MT4Orders.mqh> // https://www.mql5.com/es/code/16006

#endif // __MQL5__

#include "Xarax.mq4"