Why is this possible...? An EA problem.

 

Hi. My first post and I would like to notice, that I am so new to MQL4 and Meta Editor, that I need some help with my EA problem.

Firstly I need to say, I created my first EA with an online EA builder, because I didn't know the language (I just know only a bit of Pascal, which I was taught in High School <yeah funny :P>). But then, I noticed some similarity between those languages and I also am a bit of self-teaching guy, so I started to write some lines of my own, but only in the part of making conditions when to enter/exit a trade. This includes of course calling variables and some indicators. I've been searching a good combination of those conditions, according to my strategy, to make this EA profitable, which I did and was pretty happy and proud of myself. And then I deleted 'the crap part of the code'. I mean: indicators, conditions, variables, that weren't used to tell the EA how to trade and of course things I 'blanked out' from the code with '//'. And then I saved it and quit Meta Editor, so I can't get my old 'dirty' version of my EA back. And there started my problem...

Tell me, why the heck the EA Tester keeps showing me different results with a strategy that contains 'the crap part of the code' in it, and totally different results when the code is 'clean'?? It is insane... I have created 2 the same EAs, but put inside some inessential variables, indicators and blanked code (with '//' before it) which of course are NOT in use, when it comes to tell the EA how to trade. Trading conditions are identical inside the code of these EAs. But somehow, th EA Tester gives me so much different results with the same properties, pairs and timeframes for these EAs.

How is this thing even possible? Is it my fault, or is it just the EA Tester bugging or what else?


P.S. Sorry for my English, if you didn't understand what I meant, please ask. I really need some help with this problem.

 

Probably because of this in the expert properties.

 
Thanks for your answer, Ickyrus. Unfortunately, that is not the point... Doesn't matter if I tick or untick it. The results of those EAs are still different... I really don't understand this thing o_O Shouldn't EA be taking care only about conditions about entering or exiting a trade when it's initialized? I don't get it... Can anyone help?
 
rafios:

Hi. My first post and I would like to notice, that I am so new to MQL4 and Meta Editor, that I need some help with my EA problem.

Tell me, why the heck the EA Tester keeps showing me different results with a strategy that contains 'the crap part of the code' in it, and totally different results when the code is 'clean'??.......

But somehow, th EA Tester gives me so much different results with the same properties, pairs and timeframes for these EAs.

P.S. Sorry for my English, if you didn't understand what I meant, please ask. I really need some help with this problem.

MetaEditor

Look to the place where your file is going if you choose

File ==> Save as....

It can be that it is to a different folder then your MetaTrader Experts

In that case if you decompile again and you do again with strategytester a test you have still your old program there

The decompiled file has also gone into the different folder then your MetaTrader Experts

If you do the testing on an account that is still connected to broker then the test is done with latest spread

If your broker doesn't have fixed spread results will become different For testing scalping systems it can become very huge

 

Thanks, deVries, but the files are saving to experts folder. When I was writing this EA, every change took an effect in Tester, so it's ok with the files saving place.

Someone else has an idea, what's wrong in this case?

 
rafios:

Thanks, deVries, but the files are saving to experts folder. When I was writing this EA, every change took an effect in Tester, so it's ok with the files saving place.

Someone else has an idea, what's wrong in this case?

When you run the 2 versions of your code is the spread the same each time ?
 
rafios:

Thanks, deVries, but the files are saving to experts folder. When I was writing this EA, every change took an effect in Tester, so it's ok with the files saving place.

Someone else has an idea, what's wrong in this case?


If you do the testing on an account that is still connected to broker then the test is done with latest spread

If your broker doesn't have fixed spread results will become different For testing scalping systems it can become very huge

...........................

You can trie also

Close your metatrader after compiling and restart test then again

 
Well, I think something is going on with those spreads. When I test it on demo account both strategies ('clean' and 'dirty') give me losses, but when I test it on the live account one of them ('dirty' one) is profitable and the 'clean' one looses all money. But this is the same pattern - both strategies have identical trade conditions, pairs, timeframes, settings, and still the 'dirty' one is profitable and the 'clean' one is not. No matter how many times I run it with Tester the results for these strategies are too much different...
 

If the 2 sets of code are the same (one with commented out code the other with the code removed) and the spread is the same . . but the results are very different then something isn't as you suspect it to be. My guess is that you still have something in your code that you think is the same but isn't . . .

If you want more specific help you will need to post your code.

 

I found out that this part of the code causes the 'dirty 'EA to trade differently than the 'clean' one:

   //stoch
      for(int p = 0;p < 4;p++)
   {
    kline[p] = iStochastic(NULL, Period(), 5, 3, 3, MODE_SMA, 0, MODE_MAIN, p);
    dline[p] = iStochastic(NULL, Period(), 5, 3, 3, MODE_SMA, 0, MODE_SIGNAL, p);
   }
   if ((kline[0] > dline[0])&& (kline[3] <= dline[3])) crosseddown = true;
   else if ((kline[0] < dline[0]) && (kline[3] >= dline[3])) crossedup = true;
   else return(0);
     
   //ma
   if ((cenap < map) && (cenac > mac)) kma = true;
   else if ((cenap > map) && (cenac < mac)) sma = true;
   else return(0);

And this, later unused part of the code is just before the conditions about when to enter a trade. I'm guessing that the lines 'else return(0)' are the problem. But I don't understand, what do they do to my EA causing different transactions?

 
rafios:

I found out that this part of the code causes the 'dirty 'EA to trade differently than the 'clean' one:

And this, later unused part of the code is just before the conditions about when to enter a trade. I'm guessing that the lines 'else return(0)' are the problem. But I don't understand, what do they do to my EA causing different transactions?

I have had this kind of if else cause issues for me before . . . .

Try this instead.

 if ((kline[0] > dline[0])&& (kline[3] <= dline[3])) crosseddown = true;
   else 
      {
      if ((kline[0] < dline[0]) && (kline[3] >= dline[3])) crossedup = true;
      else return(0);
      }
     
   //ma
   if ((cenap < map) && (cenac > mac)) kma = true;
   else 
      {
      if ((cenap > map) && (cenac < mac)) sma = true;
      else return(0);
      }