WHAT KIND OF BUG IS THIS ONE?!?!?!

 

I'm really a newbie but please have a look at this:

Every time i run a strategy testing the first time i obtain different result from the next ones without changing anything even if the platform is disconnected from the broker to avoid spred problems!!!
From the second pass everything goes ok. 

It seems that the first time a function in a "specific position" is called  in the code it returns 0  

double loww, highh, sll, tpp, atrr;
static bool once=false;

if (!once) {
          // ---- WHATEVER THE SECOND LINE IS (here HIGHH=iHigh), AT THE FIRST PASS OF TESTER RETURN VALUE=0. you can try exchangin lines eachother...
          //-- (DURING OPTIMIZATION EVERY FIRT PASS OF EVERY OPTIMIZATION CYCLE)
           loww  = iLow(Symbol(), 15, 1);Print("iLow=",loww);
           highh = iHigh(Symbol(), 15, 1);Print("iHigh=",highh);
           atrr  = iATR(Symbol(), 15, 20, 1) * 3; Print("iATR=",atrr);
          
            
          //------
          
           sll   = loww-atrr;
           tpp   = highh + atrr;
          
           OrderSend(Symbol(), OP_BUY, 0.10, Ask, 0, sll, tpp, "", 0);
          
           once = true;
           }

 

In fact the strange thing is that if you change the position of the variables like 

           loww  = iLow(Symbol(), 15, 1);Print("iLow=",loww);
           atrr  = iATR(Symbol(), 15, 20, 1) * 3; Print("iATR=",atrr);
           highh = iHigh(Symbol(), 15, 1);Print("iHigh=",highh);
          

you obtain this

 

 

 

You can replicate this behaviour with the EA attached if you run it just after you have opened the MT. At the second pass it will stop to return 0. But if you close and re-open the terminal it starts again.

I know, it's not a big deal if it happens just one time after you open your MT or at the first pass OnTick, but i have did some long optimization on my more complex EAs an i experienced at every optimization cycle
and the results are useless.. 

i had problems also in some EA i'm using in live and i resolved pre-loading all variables before filling them again and use them.

Please help me to understand if i'm missing somthing or not.. i'm going a bit crazy...

Thank you guys 

Files:
bugtest.mq4  3 kb
 
Could you post a code that compiles to reproduce you issue ? The file attached is useless.

You are using "Open prices" and MTF, do you have the same issue with "Every tick" ?

Anyway, that seems like an MT4 bug which should be reported to ServiceDesk.
 
Alain Verleyen:
Could you post a code that compiles to reproduce you issue ? The file attached is useless.

You are using "Open prices" and MTF, do you have the same issue with "Every tick" ?

Anyway, that seems like an MT4 bug which should be reported to ServiceDesk.

SORRY, i updated the file attacched above! 

YES, i have same issue with every tick an control points..

Here how it looks when you optimize:

 

but in my experience with more complex EA doesn't stop at the first cycle of optimization but it happens at the first pass inside every optimization cycle..

 
Davide Abate: but it happens at the first pass inside every optimization cycle..
loww  = iLow(Symbol(), 15, 1);Print("iLow=",loww);
highh = iHigh(Symbol(), 15, 1);Print("iHigh=",highh);
atrr  = NormalizeDouble( (iATR(Symbol(), 15, 20, 1) * 3),Digits);
  1. Of course it does. You're running on M1 but looking at M15 and not waiting for updates. Therefor your stops are invalid on the first pass. History data and error 4066 - MQL4 forum
  2. Don't mix apples and oranges. Get the M15 shift for Time[0] and add your one.
  3. Check your return codes What are Function return values ? How do I use them ? - MQL4 forum and Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
  4. Print out your variables, and find out why.
  5. Do NOT use NormalizeDouble, EVER. For ANY Reason. It's a kludge, don't use it. It's use is always wrong
 
whroeder1:
  1. Of course it does. You're running on M1 but looking at M15 and not waiting for updates. Therefor your stops are invalid on the first pass. History data and error 4066 - MQL4 forum
  2. Don't mix apples and oranges. Get the M15 shift for Time[0] and add your one.
  3. Check your return codes What are Function return values ? How do I use them ? - MQL4 forum and Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
  4. Print out your variables, and find out why.
Ok thank you! i have to study! ;-)
 
whroeder1:
  1. Of course it does. You're running on M1 but looking at M15 and not waiting for updates. Therefor your stops are invalid on the first pass. History data and error 4066 - MQL4 forum
  2. Don't mix apples and oranges. Get the M15 shift for Time[0] and add your one.
  3. Check your return codes What are Function return values ? How do I use them ? - MQL4 forum and Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
  4. Print out your variables, and find out why.

G‌ood News!

I just received this reply from MetaQuotes regard this bug!

"‌Fixed. Wait please for the next build

Thank You"

‌‌

 
Davide Abate:

G‌ood News!

I just received this reply from MetaQuotes regard this bug!

"‌Fixed. Wait please for the next build

Thank You"

‌‌

Thanks :-)
Reason: