Strange EA behaviour

 

Hi

I'm programmer. But I'm new to MQL5. I've created an EA. Seems everything is OK with it. But when I test it with strategy tester, something weird happens. It opens an opposite position instantly when SL is hit. It's not done by the EA. It's not in my code! any idea?

 
Robert hofer:

Hi

I'm programmer. But I'm new to MQL5. I've created an EA. Seems everything is OK with it. But when I test it with strategy tester, something weird happens. It opens an opposite position instantly when SL is hit. It's not done by the EA. It's not in my code! any idea?

You must show your MQL5 code. Or the relevant statements at least.

 
Dr Matthias Hammelsbeck:

You must show your MQL5 code. Or the relevant statements at least.

Hey thanks for response

it's hard to show full source code here. But I'm 100% sure it's not in my code. As you can see in the picture, second position is opened instantly when the first one is closed by SL. When I hover the mouse on first trade, it shows "Placed by expert". When I hover on second one, it shows "Placed on SL". Also comment is different. I don't set such comment for my positions.

Files:
Untitled.png  15 kb
 
Robert hofer: it's hard to show full source code here. But I'm 100% sure it's not in my code. As you can see in the picture, second position is opened instantly when the first one is closed by SL. When I hover the mouse on first trade, it shows "Placed by expert". When I hover on second one, it shows "Placed on SL". Also comment is different. I don't set such comment for my positions.

If it is in the Strategy Tester, then I can 100% GUARANTEE, that the problem is in the EA that you are testing, and it needs to be addressed as such.

If you are are not able to attach your source code file in order to receive help, then you will have to either resolve the issue on your own or create a new simpler EA that causes the exact same issue so that we can analyse it.

 
Robert hofer:

Hey thanks for response

it's hard to show full source code here. But I'm 100% sure it's not in my code. As you can see in the picture, second position is opened instantly when the first one is closed by SL. When I hover the mouse on first trade, it shows "Placed by expert". When I hover on second one, it shows "Placed on SL". Also comment is different. I don't set such comment for my positions.

There is no problem at all, only your understanding. What do you think is done when a sell position is closed ? It's a buy, and that's it.
 
Alain Verleyen:
There is no problem at all, only your understanding. What do you think is done when a sell position is closed ? It's a buy, and that's it.
Thanks. Yes. It was a misunderstanding of concept
Reason: