Hi all !
I have a quite simple question (I think...)
Suppose I have a EA that opens several trades - all with sepecific TP.
Now, I want that this EA will close all the other open trades, once one of the open trades will hit it's TP.
I want that this will happend also if the EA was stopped from some reason and then restart again (So keeping internal variable that save the last-open-trades is no good solution...)
How can I do that ?
10X !U should use HistoryTotal() function and
OrderOpenPrice - OrderClosePrice() for long
or
OrderClosePrice() - OrderOpenPrice for short
If the result will be > than 0 then it was positive trade
That check will work if u close trades ONLY BY TP.
But if u want to check exactly if your takeprofit level was hit at that order u should do it like this:
1) get OrderTakeprofit() level from history (eg. last trade)
2) get Order open and close time
3) check in that period if the High price (eg by highest high function) was >= or Low (with lowest low) was <= than your profit target.
Quite simple isn't it ?
Enjoy!
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi all !
I have a quite simple question (I think...)
Suppose I have a EA that opens several trades - all with sepecific TP.
Now, I want that this EA will close all the other open trades, once one of the open trades will hit it's TP.
I want that this will happend also if the EA was stopped from some reason and then restart again (So keeping internal variable that save the last-open-trades is no good solution...)
How can I do that ?
10X !