Bibliotecas: MT4Orders - página 37

 

Fórum sobre negociação, sistemas de negociação automatizados e teste de estratégias de negociação

Expert Advisors: Equity Tral

fxsaber, 2019.04.30 22:57

Converter este EA no MT5

#define  MT4_TICKET_TYPE // Obrigar o OrderSend e o OrderTicket a retornar um valor do mesmo tipo que no 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/pt/code/12354
 

Estou trabalhando nas peculiaridades da conversão de indicadores para a autoeducação. Aqui estão mais três indicadores.

#define  MT4_TICKET_TYPE // Obrigar o OrderSend e o OrderTicket a retornar um valor do mesmo tipo que no MT4 - int.
#include <KimIVToMT5.mqh> // https://c.mql5.com/3/263/KimIVToMT5.mqh

#define  MT4_OLD_EVENT_HANDLERS
#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)));
}

int WindowFind( const string ) { return(ChartWindowFind()); }
int Digits( void ) { return(_Digits); }
string StringTrimRight2( string Str ) { StringTrimRight(Str); return(Str); }
string StringTrimLeft2( string Str )  { StringTrimLeft(Str); return(Str); }
string ObjectDescription( const string name ) { return(ObjectGetString(0, name, OBJPROP_TEXT)); }

#define CORNER_LEFT_LOWER  2
#define CORNER_LEFT_UPPER  0
#define CORNER_RIGHT_LOWER 3
#define CORNER_RIGHT_UPPER 1
#define  CORNER(A) ((A) ? ((A) + 1) % 3 + 1 : 0)

bool ObjectSet2( const string name, const ENUM_OBJECT_PROPERTY_INTEGER property, const long value )
{
  return((property != OBJPROP_CORNER) ? ObjectSetInteger(0, name, property, value)
                                      : ObjectSetInteger(0, name, OBJPROP_CORNER, CORNER(value)) && 
                                        ObjectSetInteger(0, name, OBJPROP_ANCHOR, CORNER(value) << 1));
}

bool ObjectSet2( const string name, const ENUM_OBJECT_PROPERTY_DOUBLE property, const double value )
{  
  return(ObjectSetDouble(0, name, property, value));
}

#undef  CORNER

template <typename T>
bool ObjectCreate2(const string name, const T type, const int subwindow, const datetime time1, const double price1,
                                                                        const datetime time2 = NULL, const double price2 = NULL)
{
  return(ObjectCreate(0, name, (ENUM_OBJECT)type, subwindow, time1, price1, time2, price2));
};

template <typename T>
bool ObjectCreate2(const long chart_id, const string name, const T type, const int subwindow,
                   const datetime time1, const double price1, const datetime time2 = NULL, const double price2 = NULL)
{
  return(ObjectCreate(chart_id, name, (ENUM_OBJECT)type, subwindow, time1, price1, time2, price2));
};

#define  TRUE  true
#define  FALSE false

#define StringTrimRight   StringTrimRight2
#define StringTrimLeft    StringTrimLeft2
#define  ObjectSet ObjectSet2
#define ObjectCreate ObjectCreate2
#define StringConcatenate StringConcatenate2

string StringConcatenate2( const string Str1, const int Str2 ) { return(Str1 + (string)Str2); }
string StringConcatenate2( const double Str1, const string Str2, const string Str3 ) { return((string)Str1 + Str2 + Str3); }
string StringConcatenate2( 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 StringConcatenate2( const string Str1, const int Str2, const string Str3, 
                           const string Str4, const string Str5, const double Str6,
                           const string Str7,  const string Str8, const string Str9, const double Str10 )
{
  return(Str1 + (string)Str2 + Str3 + Str4 + Str5 + (string)Str6 + Str7 + Str8 + Str9 + (string)Str10);  
}

string StringConcatenate2( const string Str1, const int Str2, const string Str3, 
                           const string Str4, const string Str5, const double Str6,
                           const string Str7,  const string Str8, const string Str9,
                           const double Str10,  const string Str11, const double Str12 )
{
  return(Str1 + (string)Str2 + Str3 + Str4 + Str5 + (string)Str6 + Str7 + Str8 + Str9 + (string)Str10 + Str11 + (string)Str12);  
}

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

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

#property indicator_buffers 0
#property indicator_plots 0

#define  Symb  SymbTmp
#define NULL  ""

#property indicator_separate_window
#include "TradeInfo.mq4" // https://github.com/icefx/tradeinfo/blob/master/TradeInfo.mq4

// #property indicator_chart_window
// #include "ProfitInfo.mq4" // https://github.com/icefx/profitinfo/blob/master/ProfitInfo.mq4

// #property indicator_chart_window
// #include "IceFX.DrawProfit.mq4" // https://github.com/icefx/drawprofit/blob/master/IceFX.DrawProfit.mq4

Como de costume, o código original do MT4 não foi alterado.

Você pode ver claramente no código-fonte que os autores usam StringConcatenate em seus códigos. Isso é simplesmente estúpido!

 

Para: fxsaber

Obrigado, meu caro. Há muito trabalho a ser feito. Tiramos o chapéu para você.

Os dois últimos indicadores (ProfitInfo, IceFX.DrawProfit) realmente geraram 44 erros. Alguma coisa está faltando. Mas isso não importa.

O importante é que agora você pode traduzir rapidamente seus desenvolvimentos, se necessário, para o MKL5.

Boa sorte

PS: Talvez seja hora de mover seu trabalho para o GitHub?
Arquivos anexados:
Err.zip  229 kb
 
Vladimir Perervenko:

Os dois últimos indicadores (ProfitInfo, IceFX.DrawProfit) realmente geraram 44 erros. Algo está faltando.

Provavelmente, eles deixaram acidentalmente um caractere extra em algum lugar.

PS: Talvez seja hora de mover seus trabalhos para o GitHub?

Eu não sei como. E por que mover algo de um recurso com perfil?

 
Vladimir Perervenko:
PS: Talvez seja hora de transferir seu trabalho para o GitHub?

Eu venho sugerindo isso há muito tempo. Até mesmo iniciei um repositório e comecei a atualizá-lo periodicamente, mas depois o esgotei.


fxsaber:

E por que você deveria mover algo de um recurso com perfil?

1. É conveniente manter o controle das atualizações (todas as edições em uma lista, destaque nas fontes, ...). Especialmente importante, considerando os problemas com o arquivamento de todos os arquivos no kodobase (bug ainda não corrigido?).

2. Alternar para qualquer versão com um clique (no terminal de trabalho).

3. Sincronização em um novo PC com apenas alguns cliques.

4. ...

5. Liberdade do gerenciamento autocrático local. É comum excluir um comentário, código, artigo ou conta. E o banimento de dissidentes é um procedimento regular (não cabe a mim dizer a você).


Por exemplo, os desenvolvimentos da getch-a e da hrenfx agora são difíceis de encontrar, e alguns deles são impossíveis de encontrar. O que acontecerá com o fxsaber amanhã? ;)

 
fxsaber:


Na fonte, você pode ver claramente quais autores usam StringConcatenate em seus códigos. Isso é simplesmente estúpido!

Qual é a maneira correta?

Se você substituí-lo por "+", ele converte. Se houver dois parâmetros em StringConcatenate() - ele converte, se houver mais - não.

 
Vladimir Perervenko:

Qual é o caminho certo?

Str = Str1 + Str2 + Str3 + ....;
 
Andrey Khatimlianskii:

Estou sugerindo isso há algum tempo. Até mesmo iniciei um repositório e comecei a atualizá-lo periodicamente, mas depois o executei.


1. É conveniente manter o controle das atualizações (todas as edições em uma lista, destaque nos códigos-fonte, ...). Especialmente importante, considerando os problemas com o arquivamento de todos os arquivos no kodobase (bug ainda não corrigido?).

2. Mudar para qualquer versão com um clique (no terminal de trabalho).

3. Sincronização em um novo PC com apenas alguns cliques.

4. ...

5. Liberdade da arrogância local da gerência. A exclusão de um comentário, um código, um artigo ou uma conta é comum. E o banimento de dissidentes é um procedimento regular (não cabe a mim lhe dizer).

Obrigado pela lista de argumentos. Vou tentar pesquisar o tópico.

 
fxsaber:

Obrigado pela lista de argumentos. Tentarei pesquisar o tópico.

Houve uma discussão aqui no fórum.
BitBucket + codificação utf8 + SourceTree para sincronização = repositório pronto
 
Andrey Khatimlianskii:
Houve uma discussão aqui no fórum.
BitBucket + codificação utf8 + SourceTree para sincronização = repositório pronto

E até 5 pessoas podem ter direitos de edição ao mesmo tempo.