Huge mt4 bug? - page 2

 
Drazen Penic:

Silly question, but did you press F3 in the terminal and check global variables before, during and after you run your EA?

Is it possible that another copy of the EA, running in another window, sets GV values?

Also, global variables are not destroyed after your EA exits. As it is stated in a documentation: "Global variables exist in the client terminal during 4 weeks since their last use, then they are automatically deleted."

If all above checks, than listen what Alain told you and debug your code.

Why the bitterness? I don't think you are understanding the question first of all. And no there are no other EAs running. Each gv is assigned a name based on the OrderTicket() so doesnt matter if other GVs exist as each will have a different name for different trades. Problem is the GV gets set immediately a trade opens even before the conditions are met. It does this from the first time I started testing both on strategy tester and on live test.

 
Tonny Obare:

Why the bitterness? I don't think you are understanding the question first of all. And no there are no other EAs running. Each gv is assigned a name based on the OrderTicket() so doesnt matter if other GVs exist as each will have a different name for different trades. Problem is the GV gets set immediately a trade opens even before the conditions are met. It does this from the first time I started testing both on strategy tester and on live test.

Hi Tonny,

Your function sets the global variable based on one of two conditions which we can see.  However, between each execution of the EA and Strategy tester runs the global variables are not deleted... is it possible that you are seeing the variable being set by a previous run and then assuming it has been set by the function again when in fact is hasn’t?  I.e. the condition wasn’t met, but the variable was still set from the previous run?  Check the date time of the last modified on the variable and see if it was set by the current run or a previous one...

Good luck!
 
Steve Mays:
Hi Tonny,

Your function sets the global variable based on one of two conditions which we can see.  However, between each execution of the EA and Strategy tester runs the global variables are not deleted... is it possible that you are seeing the variable being set by a previous run and then assuming it has been set by the function again when in fact is hasn’t?  I.e. the condition wasn’t met, but the variable was still set from the previous run?  Check the date time of the last modified on the variable and see if it was set by the current run or a previous one...

Good luck!

Does the same even with manual trades. Previous GVs dont matter because they are named and checked using the OrderTicket() function so only the value of the GV with the name that matches the open order's ticket number is fetched. Anyway, will do more tests tomorrow right now i need to clear my head besides its sunday. :-/

 
Done many tests today and its still doing the same. Must be mt4 bug. Could someone test the function on their side?
 
Tonny Obare:
Done many tests today and its still doing the same. Must be mt4 bug. Could someone test the function on their side?

Hi Tonny,

Been thinking about this problem and have also tested the code on my MT4 (build 1170).  I can't reproduce the bug.  However, thinking about it, you're looping over all open orders and then comparing the OrderOpenPrice to the Low of the previous bar (I.e. Low[1]) - should you perhaps be checking against the previous bar based on the order open time?  You can do this using IBarShift(NULL,0,OrderOpenTime()) to get the bar that that order was opened on and then simply deduct 1 to get the previous bar...

Or have I missed the point of your function?

Good luck!

Reason: