New option to my EA. Help required.
-
Hi all,
I successfully created this semiautomatic EA designed to partially close a trade when the TP is reached, then the SL is moved to break even and finally the EA itself is terminated. Lot size, price level (pending order only) and TP/SL distances are manually inserted.
https://fxdreema.com/shared/5nQEv0R9e
I want to add a new feature but I don't know how to deal with it. When I designed it I didn't take into account a situation that happened to me recently. When the price reaches the SL before having reached the TP, a new trade is immediately launched but I don't want that to be done. I would like the EA is terminated when that situation is done.
I tried to use the "For each closed trade" globe, but it doesn't work. A new trade is launched and the EA is terminated immediately after!
Any suggestion?
-
Your project has all input parameters to 0, so instead of putting pending orders it gives tons of errors. I don't want to assume what your input parameters are. There is also no real TP.
But be careful in "pips-away from the open price" block. This block can behave very differently with different settings. The first parameter is described (click on its title). "Pips away" is also important, its value can be positive, or negative if you want to detect movement in the other direction (when the price is going towards SL).
Also "Open price belongs to" is important when the block is working with trade that was result from partial close or it was added to another trade.Look for errors! Again, this EA doesn't work for me, but not because of the way blocks are connected.
-

-
@fxDreema said in New option to my EA. Help required.:
Your project has all input parameters to 0, so instead of putting pending orders it gives tons of errors. I don't want to assume what your input parameters are. There is also no real TP.
But be careful in "pips-away from the open price" block. This block can behave very differently with different settings. The first parameter is described (click on its title). "Pips away" is also important, its value can be positive, or negative if you want to detect movement in the other direction (when the price is going towards SL).
Also "Open price belongs to" is important when the block is working with trade that was result from partial close or it was added to another trade.Look for errors! Again, this EA doesn't work for me, but not because of the way blocks are connected.
Let me explain. All input parameters are 0 because I change them manually case by case. This is why I call it a semiautomatic EA. The truth is that is is a trade launcher with a moving SL, no more than that. And I can tell you it works perfectly with no errors so far. I agree there is no real TP. I call it so as an internal way to structure it. It's just a partial close. Once the partial close is reached, the SL is moved and the EA is terminated.
What you suggest about pips away accepting negative values is very interesting. Can I insert an integer negative number at that parameter? If so this can be what I'm looking for.
Thank you.
-
I'm sorry, but I cant find that "Trade closed" block. Where can I find it? Additionally, I guess there can be an additional problem by using it. What will happen when previous closed trades are listed at the platform? Will this block find them immediatey after launching my order and then will rapidly close it?
Thank you
-
try it in tester, it is best what you can do for answer to your question
....
and block Trade closed appear when you click into "on Trade" section -
It worked!!! Thank you very much.

-
An unexpected problem has appeared. I did what su siggested:
https://fxdreema.com/shared/LTMBdKgZ
I don't know why but now a weird thing happens when the partial close is executed. According to the EA, the SL should be moved and the EA terminated, but none of it happens. Once the first TP is reached, the SL is not moved, the EA is not terminated but the popping message saying it's terminated appears!!

I can't see why this is happening. It's an easy EA and all conditions are apparently correctly ordered. Could someone please help me?
-
it is closed on SL
because your SL is same value as pips away from open-price ....
next problem can be this On Trade section ... where trade is closed, it is terminated ... -
Sorry, I didn't explian myself properly. When blocks at the "On trade" section are erased, the EA works well except when the price reaches the SL BEFORE touching the TP (a new trade is created when I don't want that). This is why I added those blocks there. But now not only that problem is still active but the new one has appeared. So the situation is:
Problem 1. When price reaches TP, the SL is not moved at all now, whereas it was correctly moved before the "On trade" blocks were added. If I remove them it runs well, but then problem 2 happens.
Problem 2. If "On trade" blocks are erased, then a new trade is created if price touches the SL befor having touched the TP. As I said, this is not what I want.
So is there any way to fix both of them?
Thank you very much in advance.
-
problem 1 ... if you switch these blocks (modify stops and close) like this?

problem 2 ...
if you change this to fully closed?

-
I will try it, but I don't understand two details:
Problem 1. As far as I know, changing the order of both blocks just modifies the order in whch both actions will be executed. If it didn't work befor, why should it work now?
Problem 2. What is the difference between the original "No matter how" option and this one? Does it include my partial close? Then I think this would be the reason it didn't work properly.
-
- because "on Trade" is called with your purple "close" block ... and it terminates EA before "modify stops" block is in action ...
- this one you need play in deepness and test it because I have not test it at all
when you find solution, post it here
-
As far as I tested it, it works well. More than ten trades including all possibilities (good and bad buy/sell) have been confirmed. So once more, tank you very much for your help.
