Bibliotecas: MT4Orders - página 36

 
fxsaber:

Este es un ejemplo del uso más primitivo.

Hay algo que no entiendo: en tu ejemplo no hay ninguna llamada a una nueva función. ¿En la última librería funcionará el historial como en MT4 por defecto? O todavía es necesario hacer algo con la entrada recibida

 
fxsaber:

Os doy las gracias a vosotros, @Andrey Khatimlianskii e @Igor Makanu por "terminar". Las tareas que se plantearon no venían a cuento.

Gracias por vuestro duro trabajo y apoyo

 
Ilya Malev:

Hay algo que no entiendo: en tu ejemplo no hay ninguna nueva llamada a función. ¿En la última librería el historial funcionará como en MT4 por defecto? ¿O todavía necesitas hacer algo con el ticket recibido?

No necesitas hacer nada con el ticket recibido. El alcance de las tareas que se pueden resolver fácilmente ahora se ha ampliado. A modo de ejemplo.


Este script

#property script_show_inputs

#include <MT4Orders.mqh>

input TICKET_TYPE inTicket = 0;

// Salida conveniente
template <typename T>
T MyPrint( const T Value, const string Str ) { Print(Str + " = " + (string)Value); return(Value); }
#define _P(A) MyPrint(A, __FUNCSIG__ ", Line = " + (string)__LINE__ + ": " + #A)

// Salida de todos los datos del billete
void Test( const TICKET_TYPE Ticket )
{
  _P(Ticket);
  
  if (_P(OrderSelect(Ticket, SELECT_BY_TICKET)))
  {
    OrderPrint();
    
    _P(OrderTicket());
    _P(OrderTicketOpen());
    _P(OrderTicketID());
  }
  
  Print("");
}

void OnStart()
{    
  Test(inTicket);
  
  if (OrderSelect(OrdersHistoryTotal() - 1, SELECT_BY_POS, MODE_HISTORY))
    Test(OrderTicket());
}


producirá algo como esto

void Test(const long), Line = 15: Ticket = 0
void Test(const long), Line = 17: OrderSelect(Ticket,1) = false

void Test(const long), Line = 15: Ticket = 1753321
void Test(const long), Line = 17: OrderSelect(Ticket,1) = true
#1753321 2019.03.13 16:15:07 buy 1.00 EURUSD 1.13119 0.00000 0.00000 2019.03.13 16:15:08 1.13118 -4.52 0.00 -1.00 0
void Test(const long), Line = 21: OrderTicket() = 1753321
void Test(const long), Line = 22: OrderTicketOpen() = 1753320
void Test(const long), Line = 23: OrderTicketID() = 2532884

La selección de cualquiera de los tickets seleccionados dará el mismo resultado.

 
fxsaber:

La selección por cualquiera de los tickets seleccionados dará el mismo resultado.

Por lo tanto, es completamente normal cuando la selección por Ticket tiene éxito y OrderTicket() != Ticket.

 

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

Expertos: TradePanel

fxsaber, 2019.04.10 22:28

Convertir a MT5:
#include <KimIVToMT5.mqh> // https://www.mql5.com/ru/forum/93352/page32#comment_10603352

#define  ERR_NO_CONNECTION 6
#define  ERR_TRADE_NOT_ALLOWED 4109
#define  ERR_TRADE_EXPERT_DISABLED_BY_SERVER 4112

int ObjectsTotal() { return(ObjectsTotal(0)); }
string ObjectName( const int Pos ) { return(ObjectName(0, Pos)); } 
bool IsConnected() { return((bool)TerminalInfoInteger(TERMINAL_CONNECTED)); }

#define NULL _Symbol // redefinición de la macro

#include "TradePanel.mq4" // https://www.mql5.com/en/code/19752
 
Otro ejemplo de conversión

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

Indicadores: gráfico de la renta variable

fxsaber, 2019.04.25 11:25 AM.

Parece que ha funcionado

#define  MT4_TICKET_TYPE // Obligar a OrderSend y OrderTicket a devolver un valor del mismo tipo que en MT4 - int.
#include <KimIVToMT5.mqh> // https://c.mql5.com/3/263/KimIVToMT5.mqh

// https://www.mql5.com/en/blogs/post/681230
#include "ind4to5.mqh" // https://c.mql5.com/3/277/ind4to5.mqh

#property indicator_separate_window
#property indicator_buffers 6
#property indicator_plots 2
#property indicator_color1 SteelBlue
#property indicator_color2 OrangeRed
#property indicator_color3 SlateGray
#property indicator_color4 ForestGreen
#property indicator_color5 Silver
#property indicator_color6 Gray
#property indicator_width1 1
#property indicator_width2 1
#property indicator_width3 1
#property indicator_width4 1
#property indicator_width5 1
#property indicator_width6 1

#define  TotalOrders TotalOrdersTmp
#define  Ticket TicketTmp
#define  StartTime StartTimeTmp
#define  Type TypeTmp
#define  Margin MarginTmp
#define  Magic MagicTmp

bool ObjectSetText( const string name, const string text,
                    const int font_size = 0, const string font_name = NULL )
{
  return(ObjectSetString(0, name, OBJPROP_TEXT, text) &&
         (!font_size || ObjectSetInteger(0, name, OBJPROP_FONTSIZE, font_size)) &&
         ((font_name == NULL) || ObjectSetString(0, name, OBJPROP_FONT, font_name)));
}

string StringConcatenate( const string Str1, const string Str2, const string Str3 )
{
  return(Str1 + Str2 + Str3);
}

string StringConcatenate( const string Str1, const string Str2, const string Str3, const string Str4)
{
  return(Str1 + Str2 + Str3 + Str4);
}

string StringConcatenate( const string Str1, const string Str2, const string Str3, const string Str4, const string Str5 )
{
  return(Str1 + Str2 + Str3 + Str4 + Str5);
}

string StringConcatenate( const string Str1, const string Str2, const int Str3, const string Str4, const int Str5 )
{
  return(Str1 + Str2 + (string)Str3 + Str4 + (string)Str5);
}

string StringConcatenate( const string Str1, const string Str2, const string Str3, const string Str4, const string Str5, const string Str6 )
{
  return(Str1 + Str2 + Str3 + Str4 + Str5 + Str6);
}

string StringConcatenate( const string Str1, const int Str2, const string Str3, const double Str4, const string Str5, const string Str6 )
{
  return(Str1 + (string)Str2 + Str3 + (string)Str4 + Str5 + Str6);
}

string StringConcatenate( const string Str1, const string Str2, const string Str3, const string Str4, const string Str5, const string Str6, const string Str7 )
{
  return(Str1 + Str2 + Str3 + Str4 + Str5 + Str6 + Str7);
}

string StringConcatenate( const int Str1, const string Str2, const ENUM_TIMEFRAMES Str3, const string Str4)
{
  return((string)Str1 + Str2 + EnumToString(Str3) + Str4);
}

// Comente la línea con el error de compilación: 'Import_History' - constant cannot be modified Equity-Monitor.mq4 734 7
#include "Equity-Monitor.mq4" // https://www.mql5.com/es/code/13242

 

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

Conversor de código de MT4 a MT5

fxsaber, 2019.04.29 10:47 AM

#property indicator_chart_window 
#property indicator_buffers 6
#property indicator_plots 6
#property indicator_color1 White 
#property indicator_color2 White 
#property indicator_color3 DodgerBlue
#property indicator_color4 DodgerBlue
#property indicator_color5 Lime
#property indicator_color6 Red
 
#property indicator_width1 5
#property indicator_width2 5
#property indicator_width3 3
#property indicator_width4 3
#property indicator_width5 1
#property indicator_width6 1

#include <KimIVToMT5.mqh> // https://c.mql5.com/3/263/KimIVToMT5.mqh

// https://www.mql5.com/en/blogs/post/681230
#define  MT4_OLD_EVENT_HANDLERS
#include "ind4to5.mqh" // https://c.mql5.com/3/277/ind4to5.mqh

#define  digits digits2
#undef MODE_LOW
#undef MODE_HIGH

#include "Chaos_Semafor_-_3_Mod.mq4" // https://c.mql5.com/3/277/Chaos_Semafor_-_3_Mod__1.mq4
 
Si necesita mantener el uso de MT4Orders en su producto tácito, puede cortar las partes relevantes del código fuente de la librería o ponerle un stub universal
// Mediante macros cortamos cualquier indicio sobre la presencia de MT4Orders.
#define Alert PrintTmp
#define Print PrintTmp
  void PrintTmp( string ) {}
  
  #include <MT4Orders.mqh> // https://www.mql5.com/es/code/16006
#undef  Print
#undef  Alert
 

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

Expertos: Daily Chart Trader

fxsaber, 2019.04.30 12:08 AM

MT5-versión
#define  MT4_TICKET_TYPE // Obligar a OrderSend y OrderTicket a devolver un valor del mismo tipo que en MT4 - int.
#include <KimIVToMT5.mqh> // https://c.mql5.com/3/263/KimIVToMT5.mqh

#include "ind4to5.mqh" // https://c.mql5.com/3/277/ind4to5.mqh

bool ObjectSetText( const string name, const string text,
                    const int font_size = 0, const string font_name = NULL, const color Color = clrNONE )
{
  return(ObjectSetString(0, name, OBJPROP_TEXT, text) &&
         ((font_name == NULL) || ObjectSetInteger(0, name, OBJPROP_FONTSIZE, font_size)) &&
         ((font_name == NULL) || ObjectSetString(0, name, OBJPROP_FONT, font_name)) &&
         ((Color == clrNONE) || ObjectSetInteger(0, name, OBJPROP_COLOR, Color)));
}

#define NULL ""

#include "AEROSPINE.mq4" // https://www.mql5.com/en/code/24903
 

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

Asesores expertos: Equity Tral

fxsaber, 2019.04.30 22:57

Convertir este EA bajo MT5

#define  MT4_TICKET_TYPE // Obligar a OrderSend y OrderTicket a devolver un valor del mismo tipo que en MT4 - int.
#include <KimIVToMT5.mqh> // https://c.mql5.com/3/263/KimIVToMT5.mqh

#include "ind4to5.mqh" // https://c.mql5.com/3/277/ind4to5.mqh

bool ObjectSetText( const string name, const string text,
                    const int font_size = 0, const string font_name = NULL, const color Color = clrNONE )
{
  return(ObjectSetString(0, name, OBJPROP_TEXT, text) &&
         ((font_name == NULL) || ObjectSetInteger(0, name, OBJPROP_FONTSIZE, font_size)) &&
         ((font_name == NULL) || ObjectSetString(0, name, OBJPROP_FONT, font_name)) &&
         ((Color == clrNONE) || ObjectSetInteger(0, name, OBJPROP_COLOR, Color)));
}

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

#include "Equity_Tral.mq4" // https://www.mql5.com/es/code/12354