I am trying to code an EA based on my own strategy, with the help of code from some other EAs and indis. but now stuck in one thing.
<removed>
Please use the SRC button to post code . . .
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(){ ... }
The thing that you mentioned is ok. problem is in the rest of the code. I get two errors (in new metaeditor only).
'init' - function can be declared only in the global scope and 'init' - function already defined and has body
yes i've got that and corrected. Now getting error in timeframe code.
//--- 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.
If Forced_TF is true, then EA should trade and should get signals from mentioned timeframe only, even if active chart (on which i place EA) is opened in different timeframe. If value false, then it should work on any timeframe.
yes i've got that and corrected. Now getting error in timeframe code.
If Forced_TF is true, then EA should trade and should get signals from mentioned timeframe only, even if active chart (on which i place EA) is opened in different timeframe. If value false, then it should work on any timeframe.
You have TF as a bool . .. but you are trying to set it to an int . . . try this . . .
//--- 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 I've got you. and again everything ok with old editor, but new editor still giving one warning, quoted in code after error line,
//+------------------------------------------------------------------+ //| 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 Pasted the whole code.
@RaptorUK I've got you. and again everything ok with old editor, but new editor still giving one warning, quoted in code after error line,
@WHRoeder Pasted the whole code.
It's not an error it's a warning . . . to get rid of the warning initialise the variable rather than just declaring it. In mql4 when you declared a variable it was also initialised, now with mql4.5 you have to explicitly initialise the variable if you want to . . .
int i = 0, j, k; // i initialised to 0
pipValue = (MarketInfo(Symbol(),MODE_TICKVALUE))*10;Don't use tickvalue by itself https://www.mql5.com/en/forum/133792/page3#512466
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I am trying to code an EA based on my own strategy, with the help of code from some other EAs and indis. but now stuck in one thing.
I am unable to understand this logic or what actually it is.
PS: A friend liked my strategy and created this EA. But i lost both (EA and that coder friend's contact) so now i am trying to test my very basic coding knowledge, as i really want this Strategy to be coded again.