How to create Opposite Pending Order with Open Price from Last Closed Trade?
-
Hi,
How to create opposite pending order with open price from each last closed trade on fxDreema MQL5 ?
Because I want to create opposite Pending Order (eg. Buy) with same last open price for each closed trade (eg. Sell).
Thanks.
-
Not sure if this will work in practice but it might get you on the right track.
Bucket of Closed Trades with only 1 for history. The use a formulae to set a variable for the close price.

-
@clubsport640 thanks for your help. yes it work. but it's create multiple pending order at once. I'm prefer to create opposite pending order with open price rather than closing price from last close trade.
I have try to create pending order with No position nearby and No pending nearby filter. Pending order get last open price from varLastPrice variable. but the problems is pending order not create for every trade close and have incorrect last open price value.


What's wrong ?
I'm shared this project : https://fxdreema.com/shared/d6roIgJH -
Do you mean creating a pending order at the exact same moment the last open trade was closed? Probably your broker will stop you from doing it because of the current spread. I recommend you to wait for some time or shift it a few pips away.
-
@l-andorrà yes that's right.

I have shift 500 pips away for each pending order to cover it's spread, but still have a problems. is it possible to create Opposite Pending Order by last open price value (exact moment) from each open trade was closed?
Let's say. I was open buy at 1680.00, than it's closed at 1685.00 or 500 pips away from it's open price by Take Profit. and at moment my EA should create pending order Sell again at 1680, I think 500 pips or 1.000 pips is enough for now.
So I want my EA create Opposite Pending Order at exact same moment for each the last open trade was closed and what's wrong with my script /project ? Thanks.
-
No, you won't be able to create pending orders in those conditions. What you can do is:
- Open a trade immediately after the previous one was closed. So no pending needed.
Or - Create a pending order at the exact same moment you opened the previous trade. Programming a pending order at 500 pips distance is not only possile but recommended. However you will need to program it much earlier.
- Open a trade immediately after the previous one was closed. So no pending needed.