ECN broker - remove pending order on tp hit
-
Edit: changed topic title, now corresponding with actual contents of last posts.
Hello, as of yesterday i began experimenting a bit with FxDreema. I must say i am really impressed by the ease of use. However, despite checking the help and searching section for more information on #group and magic numbers i am still facing a problem.
Right now i have pending orders on multiple pairs/charts and what i would like to do is removing specific pending orders when another pending order is triggered and reached its TP. This should be per pair/chart. It should not remove each and every other pending order from other pairs.
I am trying to post #group and magic number info on the comment section (ontrade & and inloop) but it does not come up with any information regarding this information. Am i looking at the wrong blocks?
This is what I have made so far
-
Very good, for someone new you already know how to use those pink blocks. Well... almost. I don't like this (on trade) in the Comment block under "on Tick", but anyway.
The moment when TP is triggered can be detected under "on Trade". But this will be one time event, so it can't be repeated.
Manual trades and orders have magic number 0, the chart does not matter here, no specific chart information is added to the trade/order.
-
__Very good, for someone new you already know how to use those pink blocks. Well... almost. I don't like this (on trade) in the Comment block under "on Tick", but anyway.
The moment when TP is triggered can be detected under "on Trade". But this will be one time event, so it can't be repeated.
Manual trades and orders have magic number 0, the chart does not matter here, no specific chart information is added to the trade/order.[/quote:zxinx2r3]
Ok, i added a "on-trade: Trade Closed" -> delete pending orders (as shown below).
I noticed unfortunately that the above code did not close my AUD/USD pending orders correctly for some reason.
Thanks for the respond. -
Cool the above additional trigger did the trick. Seems to work now
-
Ok works on FXCM demo, does not work on Pepperstone live for some reason.
Decimals are the same and input for decimals is correct.Might have something to do with ECN or micro lots(0.0x, as i am testing if this works..)? Pending orders are not closing correctly on pepperstone after another pending is triggered and tp is hit.
-
Apparently it is because on an ECN broker the pending order needs to get filled first, and one should then set TP and SL afterwards for it to work. So frustrating. I use a low maintenance strategy and do not wish to stare at my screen the whole day for an order to get filled.
Is there a workaround for this?
Edit: I just confirmed this since it works fine on FXCM, continuously closing pending orders, while on ECN pepperstone it keeps giving problems by not closing pending orders.
-
In the past it was not possible to send SL and TP with the trade on an ECN broker. Then they changed the OrderSend() function so it's now possible. This happened > 1 year ago. And this was for trades (running orders), not pending orders.
You can easily see what is possible and what is not. Click on "New Order" and check whether the Stop Loss and Take Profit fields are active or they look disabled.
Do you have error messages?
-
__In the past it was not possible to send SL and TP with the trade on an ECN broker. Then they changed the OrderSend() function so it's now possible. This happened > 1 year ago. And this was for trades (running orders), not pending orders.
You can easily see what is possible and what is not. Click on "New Order" and check whether the Stop Loss and Take Profit fields are active or they look disabled.
Do you have error messages?[/quote:1318sayp]
No error messages. Basically i get the message of order close: tp hit. But then i dont get the remove pending order after. I do get this on fxcm demo. Just not on pepperstone live.
Also i tried a workaround by modifying pending orders SL instead of a removal when a previous trade hits tp. Same results, modify orders sl works fine on fxcm. Pepperstone ecn on the other hand.. no error at all either
-
Last but not least i should mention that Pepperstone ECN platform deleted the pending orders once or twice succesfully, 90% of the time it does not. Maybe this is pointing at a different cause...
-
Well, I created a demo account in this Pepperstone and I can't even create a trade or pending order. Can you show me what you have when you click on "New Order"?
-
__Well, I created a demo account in this Pepperstone and I can't even create a trade or pending order. Can you show me what you have when you click on "New Order"?[/quote:2dookq8z]
Thanks for trying to help me out. Its such a mess at the moment
Also tried workaround by setting new expirations on pending orders. Does not work but think it has to do with minimal expiration and such,,......
Untitled.png -
It looks that you can use SL and TP when you send a trade.
Do you have some messages in the logs, or the EA does not work as you expect at all? If the EA tries to do something, there will be indication of that in the logs, otherwise there will be nothing in there
-
__It looks that you can use SL and TP when you send a trade.
Do you have some messages in the logs, or the EA does not work as you expect at all? If the EA tries to do something, there will be indication of that in the logs, otherwise there will be nothing in there[/quote:r8ewnrcf]
I shut down my notebook a min ago but i can tell you the journal shows all messages, including activation of order, closed by take profit etc. Its corresponding with the blocks i have used. The onky message that doesnt show up is the one that normally says: pending order deleted. Its like this block "delete pending orders" does not exist within pepperstone mt4, but does on other mt4 broker platforms, such as fxcm
-
This is what you have:
http://img.prntscr.com/img?url=http://i.imgur.com/gEmnIOi.pngYour MagicStart is 0, so you are working with the manually created trades, which is fine. So you want to delete existing pending orders when a trade is closed by Take Profit.
To detect when a trade was closed by TP or SL, the EA is reading it's comment. Normally [sl] or [tp] is appended to the comment. Do you have this?
http://i.imgur.com/hfILobg.png
Let's say that it does not exists. Then "(on trade) Trade closed" has another way to detect whether the trade was closed by TP or SL, which can be seen in the code that the block produces:
http://i.imgur.com/lH8yraA.png -
__
Your MagicStart is 0, so you are working with the manually created trades, which is fine. So you want to delete existing pending orders when a trade is closed by Take Profit.To detect when a trade was closed by TP or SL, the EA is reading it's comment. Normally [sl] or [tp] is appended to the comment. Do you have this?
Let's say that it does not exists. Then "(on trade) Trade closed" has another way to detect whether the trade was closed by TP or SL, which can be seen in the code that the block produces:
[/quote:3m9oewmf]Thanks for all the extensive helping once again Dreema, this is very interesting. While FXCM has all the [TP] and [SL] in its comment section, its blank field with nothing in it on Pepperstone.
-
Tried the following, adding an extra block for custom comment:
https://fxdreema.com/shared/RYtDHhG4d
Still did not put any comment after a take profit took place.
Also, tried to manually change the [sl] and [tp] strings into a simple " " within the mq4 code. No succes either so far.
-
Managed a workaround where i close pending orders at "x" distance from TP instead. Works on FXCM and yes, you guessed right, it absolutely failed again on Pepperstone where it removes pending orders at 200 pips distance from TP instead of 1 pip.
-
Fixed!
So happy i finally managed to get it to work on Pepperstone also. The problem had deffinately to do with TP as all variables that included TP, including "close on TP", "pips/percentage from TP" etc etc did not work.
- Right now it scans for profitable trades only (greater than 0.1 deposited currency)
- Then it scans the distance away from opening price
https://fxdreema.com/shared/oXZRApxO
Distance from opening price works while everything related to TP or SL does not it seems..