Problem with MT4 Opening a Deal, then Closing it again straight away - page 4

 

It's a tricky problem because of difficulties finding a consistent pattern.

This problem only happens sometimes and cannot be replicated consistently.

I've considered the Magic Numbers suggestion, and while it was initially a possibility, further observations suggest it is not likely.

I'm tearing my hair out here, and hope someone else has seen this problem before.

 
peterc005:

I've considered the Magic Numbers suggestion, and while it was initially a possibility, further observations suggest it is not likely.

Which observations in detail are it that definitely rule out a different EA closing trades that don't belong to it? There are many EAs out there that allow the input of a magic number but internally don't use it or even worse use it sometimes but not always, only for certain exit conditions, only in a few branches of their dozens of nested ifs and duplicated order iterating loops.

This google search

"OrderSymbol() == Symbol()" -OrderMagicNumber

will find loads of them, it starts already with the third one on the list (earlybird1, gridmaster_03, and so on, the whole search result is full of them) they claim to use a magic number but internally simply ignore it. You will find plenty of them. This faulty code pattern is all over the forums and ends up copy-pasted in many EAs.

 
7bit:

its about a defect in the sold product, not about criminal intent.

Sure, defect, no problem.

"Sabotage" has a different meaning though, and hardly of a technical nature, and is not a substitute for the word "defect".

I'm sure those whose first language is not English can be excused.

 
blogzr3:

"Sabotage" has a different meaning though, and hardly of a technical nature, and is not a substitute for the word "defect".

The defect manifests itself as the one robot sabotaging the other. Since it is the robot who sabotages I cannot see how a robot can have an intent. The robot is defective and this causes it to sabotage other trades. Nothing else did I write or mean. And the seller is selling defective products.
 
7bit:
The defect manifests itself as the one robot sabotaging the other. Since it is the robot who sabotages I cannot see how a robot can have an intent. The robot is defective and this causes it to sabotage other trades. Nothing else did I write or mean. And the seller is selling defective products.

Most of these EAs seem to use the ZigZag indicator, which is a likely culprit.

When it happened the first time with an EA called "Caliber" I decompiled the EA to look at the code. It was a crappy EA, but there was nothing that looked suspicious and the Magic Number logic seemed fine.

I added extra logic to prevent the EA trading more than once every 90 minutes.

As a coincidence, this also improved the overall performance of the EA, because it had a tendency to hit a SL after a short while, then enter a new trade in the same direction. You'd think with a 30 pip SL it would be a safe EA, but if it hit that SL 4 times in an hour it's not good.

Restricting trades like this really improved the performance of the EA in back tests, and after I sent the code changes to the vendor, they later released an update with my changes.

Anyway, at the time I was testing my changes to Calibre on a Demo account and the same thing happened. I could see trades being opened and closed straight away. It was only a Demo account so I just sat there and watched it happen.

In this instance it was a new demo account with only one EA running. This makes mt think it is a MT4 platform problem, rather than MQL4 problem.

I now know MT4 and MQL4 well and can figure most problems out myself. This problem has me stuffed and I'm asking others for suggestions.


 

i bet it's an indicator/calculation problem. maybe a division by 0 which happens only in some specific cases..

if you can repeat the error in tester this would be half the rent.

since you know which EA was causing this problem and also when it happend it should be easy to check if it's repeatable.

afterwards if you was able to repeat the error, it should not be that hard to find the piece of code which causes the error.


//z

 

Here is one of the older log files. The problem is obvious from the number of trades opened and closed.

In the log file you can see that MT4 and the broker are receiving instructions to open and close the Orders, but why?

Files:
 
peterc005:


One thing I noticed in one log file for a relevant date was thousands of error that say:

09:36:58 HistoryBase: not enough memory for 'EURCHF1' in AddTick()

09:36:58 Memory handler: cannot allocate 160308896 bytes of memory

Instead of the log file being say 10k, it was 7Mb

 
peterc005:

Here is one of the older log files. The problem is obvious from the number of trades opened and closed.

In the log file you can see that MT4 and the broker are receiving instructions to open and close the Orders, but why?

Do you also have the other log (the one from the experts/logs folder)? This one will contain the name of the offending EA.
 
zzuegg:

since you know which EA was causing this

It is still not known which EA is causing this.


All that we have seen so far are the symptoms (trades of several different EAs are closed immediately after opening) and a few theories. It is still not known which EA is actually closing these trades. We need the experts logs in the folder experts/logs from all 4 terminals covering the same time span to make any further conclusions. These logs could support or dismiss my theory and they will ultimately show who is sending all the close orders.

Reason: