extern string LotsProgression="0.1;0.1;0.2;0.3 ... double lots[]; // [0]=0.1 [1]=0.1 [2]=0.2 [3]=0.3 [34]=661.1 int plen; // 35 int init(){ ... }
Lo que mencionas está bien. El problema está en el resto del código. Me salen dos errores (sólo en el nuevo metaeditor).
'init' - function can be declared only in the global scope and 'init' - function already defined and has body
Sí, lo he entendido y corregido. Ahora se produce un error en el código del marco temporal.
//--- EA PARAMETERS extern int EA_TF=240; extern bool Forced_TF=True; bool TF; if(Forced_TF != True) TF = EA_TF; //These two lines i think, have error. else TF = Period(); //New metaeditor is not accepting "TF = EA_TF;" from above line.
Si Forced_TF es verdadero, entonces el EA debe operar y debe obtener señales del marco de tiempo mencionado solamente, incluso si el gráfico activo (en el que coloco el EA) se abre en un marco de tiempo diferente. Si el valor es falso, entonces debería funcionar en cualquier marco de tiempo.
Sí, lo he entendido y corregido. Ahora se produce un error en el código de marco de tiempo.
Si Forced_TF es verdadero, entonces el EA debe operar y debe obtener señales del marco de tiempo mencionado solamente, incluso si el gráfico activo (en el que coloco el EA) se abre en un marco de tiempo diferente. Si el valor es falso, entonces debería funcionar en cualquier marco de tiempo.
Usted tiene TF como un bool . .. pero está tratando de establecerlo como un int... intente esto ...
//--- EA PARAMETERS extern int EA_TF=240; extern bool Forced_TF=True; int TF; if(!Forced_TF) TF = EA_TF; //These two lines i think, have error. else TF = Period(); //New metaeditor is not accepting "TF = EA_TF;" from above line.
@RaptorUK Te tengo. y de nuevo todo bien con el viejo editor, pero el nuevo editor sigue dando una advertencia, citado en el código después de la línea de error,
//+------------------------------------------------------------------+ //| 01Multi_EA.mq4 | //| Copyright © 2004, MetaQuotes Software Corp. | //| http://www.metaquotes.net/ | //+------------------------------------------------------------------+ #property copyright "Copyright © 2004, MetaQuotes Software Corp." #property link "http://www.metaquotes.net/" #property version "1.00" #property strict //--- input parameters input int EA_TF=60; input bool Forced_TF=True; input int MagicNumber=12345; input int FastMA_Period=5; input int FastMA_Shift=0; input int FastMA_Method=1; input int FastMA_Price=0; input int SlowMA_Period=34; input int SlowMA_Shift=0; input int SlowMA_Method=1; input int SlowMA_Price=0; input string LotsProgression="0.01;0.02;0.03;0.04;0.05;0.06;0.07;0.08;0.09;0.10;0.11;0.12;0.13;0.14;0.15;0.16;0.17;0.18;0.19;0.20"; input bool NewCycle=True; input int Limit_TP=50; input bool Use_TP=False; input int Limit_SL=50; input bool Use_SL=False; input int MaxSlippage=3; input int OrderTries=10; int TF, Plen; double TP, SL, pips2dbl, pips2point, pipValue, Slippage, Lots[]; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //---- if(Forced_TF != True) TF = EA_TF; else TF = Period(); int i,j,k; string ls; while (true) { j=StringFind(LotsProgression,";",i); if(j>0) { ls=StringSubstr(LotsProgression,i,j-i); // <<<<<"possible use of uninitialized variable 'i' 01Multi_EA.mq4 46 38">>>>> i=j+1; k++; ArrayResize(Lots,k); Lots[k-1]=StrToDouble(ls); } else { ls=StringSubstr(LotsProgression,i); k++; ArrayResize(Lots,k); Lots[k-1]=StrToDouble(ls); break; } } Comment("Copyright © 2004, MetaQuotes Software Corp."); if (Digits == 5 || Digits == 3) { pips2dbl = Point*10; pips2point = 10; pipValue = (MarketInfo(Symbol(),MODE_TICKVALUE))*10; } else { pips2dbl = Point; pips2point = 1; pipValue = (MarketInfo(Symbol(),MODE_TICKVALUE))*1; } Slippage = pips2dbl*MaxSlippage; TP = pips2dbl*Limit_TP; SL = pips2dbl*Limit_SL; //---- return(INIT_SUCCEEDED); }
@WHRoeder Pegado todo el código.
@RaptorUK Te tengo. y de nuevo todo bien con el viejo editor, pero el nuevo editor sigue dando una advertencia, citado en el código después de la línea de error,
@WHRoeder Pegado todo el código.
No es un error, es una advertencia... para deshacerse de la advertencia inicialice la variable en lugar de declararla. En mql4 cuando declarabas una variable también se inicializaba, ahora con mql4.5 tienes que inicializar explícitamente la variable si quieres. . .
int i = 0, j, k; // i initialised to 0
pipValue = (MarketInfo(Symbol(),MODE_TICKVALUE))*10;No utilice el tickvalue por sí mismo https://www.mql5.com/en/forum/133792/page3#512466
- Aplicaciones de trading gratuitas
- 8 000+ señales para copiar
- Noticias económicas para analizar los mercados financieros
Usted acepta la política del sitio web y las condiciones de uso
Estoy tratando de codificar un EA basado en mi propia estrategia, con la ayuda del código de algunos otros EAs y indis. pero ahora atascado en una cosa.
No soy capaz de entender esta lógica o lo que realmente es.
PD: A un amigo le gustó mi estrategia y creó este EA. Pero perdí ambos (el EA y el contacto de ese amigo codificador) así que ahora estoy tratando de probar mis conocimientos muy básicos de codificación, ya que realmente quiero que esta Estrategia sea codificada de nuevo.