Форум по трейдингу, автоматическим торговым системам и тестированию торговых стратегий
Особенности языка mql4, тонкости и приёмы работы
fxsaber, 2017.04.09 11:40
// Закрывает позиции, описание - https://www.mql5.com/ru/code/17943 sinput int RTOTAL = 4; // Число повторов при неудачных сделках sinput int SLEEPTIME = 1; // Время паузы между повторами в секундах sinput int Deviation_ = 10; // Отклонение цены sinput bool exAllSymbols = false; // false - только текущий, true - все символы #define _CS(A) ((!IsStopped()) && (A)) bool CloseAllPositions( const bool AllSymbols = true, const int Slippage = 0 ) { bool Res = true; for (int i = OrdersTotal() - 1; _CS(i >= 0); i--) if (OrderSelect(i, SELECT_BY_POS) && (OrderType() <= OP_SELL) && (AllSymbols ? true : (OrderSymbol() == Symbol()))) Res &= OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), Slippage); return(Res); } void OnStart() { for (int i = 0; _CS((i < RTOTAL) && (!CloseAllPositions(exAllSymbols, Deviation_))); i++) Sleep(SLEEPTIME * 1000); }
fxsaber:
Run the script on the EURUSD-chart.
Ok..Thank you very much..
Run the script on the EURUSD-chart.
Ali irwan:
hello master master goodnight, I want to ask how to make a script on mql4 to close all orders in just one currency only.
example:
I trade in many currencies with a lot of open positions, but when the EURUSD currency I see false position,then all orders in the EURUSD currency will close all position .and positions are pending or which are still open.
https://www.mql5.com/en/code/16623

Closed_TOTAL
- votes: 9
- 2016.10.19
- Miguel Angel Vico Alba
- www.mql5.com
Total closure of all positions (winners/losers). You can also select which are of a single instrument.

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
hello master master goodnight, I want to ask how to make a script on mql4 to close all orders in just one currency only.
example:
I trade in many currencies with a lot of open positions, but when the EURUSD currency I see false position,then all orders in the EURUSD currency will close all position .and positions are pending or which are still open.