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

 
peterc005:


MT4\Experts\Logs folder:

17:28:48 FapTurbo50 EURUSDFXF,M5: open #2662451 buy 0.20 EURUSDFXF at 1.2909 ok

17:28:49 FapTurbo50 EURUSDFXF,M5: modify #2662451 buy 0.20 EURUSDFXF at 1.2909 sl: 1.2407 tp: 1.2929 ok


What are the next few lines in this log? All lines please and not "filtered" by what you deem important or not, just plain raw log entries. Especially all those with the same or almost the same timestamps on all the other terminals too.


Maybe also some weird FIFO automatism going on? I have already seen brokers automatically moving existing stoplosses around without notice, maybe some are even closing existing trades when other trades are opened? In this case you would have to thank the regulation authorities for successfully "protecting" your money.


And how are your free margin levels when this happens? anywhere near dangerously low?

 
Still not conclusively proven, but I suspect the problem is Probability EA

Here are the reasons:

1) I've turned Probability EA off and on a few times on various accounts, the the times that Probability EA was running appear to correspond with the times I had all these deals closed incorrectly.

2) I noticed that FAP Turbo writes Open and Close records to the Experts Log normally (thank you for the suggestion 7bit).

3) I noticed that the 50 of so FAP Turbo deals that closed after a couple of seconds had an Open record, but no Close record in the Expert log.

4) I observer that Probability EA appears not to write to the Expert log.

5) This implies that FAP Turbo opened the deals ok, writing a record to the Expert log. Probability EA then closed the deal, but didn't write anything to the Expert log. Based on the signal, FAP Turbo then opened another deal, repeating the loop many times.

The evidence is mounting, but it is still too early to draw conclusions. I've contacted the Probability EA vendor for more information. I will also decompile the EA to see if there are any obvious logic errors.

 

Do the red arrows (left pointing triangles or arrows) appear in the Probability-EA chart at the times when the FAP trades are closed?

When you hover your mouse over these arrows in the ProbabilityEA chart so that the small yellow hint window appears do the ticket numbers in these hints correspond to the wrongly closed FAP trades? (for example in the chart from the screenshot you posted in the FF forum)

 
peterc005: I will also decompile the EA to see if there are any obvious logic errors.

Insert a Print() before every OrderClose() and OrderCloseBy(), compile the modified code and run this instead of the original.


Look for the presence (or absence) of a call to OrderMagicNumber() near any OrderClose() or OrderCloseBy() in the code.

Also look out for anything between the check and the closing that might change the currently selected order (like for example another loop over all orders to find an offsetting or otherwise related order, this would change the current selection to something completely unpredictable and a following OrderClose(OrderTicket(),...) would then inevitably wreak havoc in the account). Every order must be checked against the magic number before it may be closed. Failing to do this check or doing it wrong will provoke this type of error because every EA has always access to all trades on the account and is responsible for carefully filtering them.

There exists no implicit filter mechanism by MT4 that would somehow automatically shield an EA from other trades on other charts, every EA must implement this completely on its own (and can miserably fail).

 
7bit:

Insert a Print() before every OrderClose() and OrderCloseBy(), compile the modified code and run this instead of the original.


Look for the presence (or absence) of a call to OrderMagicNumber() near any OrderClose() or OrderCloseBy() in the code.

Also look out for anything between the check and the closing that might change the currently selected order (like for example another loop over all orders to find an offsetting or otherwise related order, this would change the current selection to something completely unpredictable and a following OrderClose(OrderTicket(),...) would then inevitably wreak havoc in the account). Every order must be checked against the magic number before it may be closed. Failing to do this check or doing it wrong will provoke this type of error because every EA has always access to all trades on the account and is responsible for carefully filtering them.

There exists no implicit filter mechanism by MT4 that would somehow automatically shield an EA from other trades on other charts, every EA must implement this completely on its own (and can miserably fail).

Hi 7bit,

sounds like a good idea, I'll give it a go.

Regards

Peter

 

With regard to a couple of earlier questions:

1) I don't think using an ECN broker (specifically GoMarkets) makes a difference with this problem. Had the same problem with forex.com. In general, I like GoMarkets and think they are good.

2) I don't think it was margin or equity related. The reason for this is "s/o" is added to the comments when a deal is closed because of insufficient equity.

Peter

 

Turns out the problem was in version 7.1 of Probability EA. Here is the vendor response:

peterc005,

This issue was fixed with v7.1.1 (as opposed to v7.1). I initially decreased the Magic Number by 1 each time a cycle was closed (which notified the EA to close the cycle). This works well if the EA is the only one running, but when people wanted to use this EA in addition to other EAs, I modified the code so that the Magic Number stays constant, and the EA uses other ways of closing the cycle.

I'll send you a copy of v7.1.1 and let me know if you are still having the problem.

Michael

I appreciate the vendors honesty and frankness, but this problem with the EA cost me about $5,000 and wrecked 3 accounts over a few months.

 

"I initially decreased the Magic Number by 1 each time a cycle was closed"

It seems the developer of this EA does not know what is the purpose of magic numbers. This means he is in his early experimenting stages but is already selling his flawed and buggy beginner code for money. This totally confirms everything I have said about the code quality of these commercial EAs. I would not trust these things any money.


The lesson to be learned here must be: Don't trust any closed-source EAs. The unavailability of the source guarantees bad code quality.

 

Dear Peterc005

I had a similar problem on my VPS it tours out that another instance of metatrader form the same directory has runnig on the backround and closing the trades open by the first metatrader.

Try this closed all the MetaTraders and then opent TaskManager and check to see if there is any instances on Terminal.exe runnig, if so restart your machine and the problem will be solved

You can search for Ghost detector on google to find out more about this problem.