fctwoqula:
I am aware that there is a script to stop all trades and close out all positions in MQL4.
But I am not aware of such code's existence in MQL5.
I couldn't find such script in there - where should I find such script which will stop all trades and close out all positions, or will the code from MQL4 work on MQL5 to have the same effect?
Example of the function of closing all the position in the code of the expert Autotrade, in function "CloseAllPositions".
Форум по трейдингу, автоматическим торговым системам и тестированию торговых стратегий
Особенности языка 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:
The question is about mql5.
Alain Verleyen:
The question is about mql5.
The question is about mql5.
Forum on trading, automated trading systems and testing trading strategies
How i can history trade information on MQL5
fxsaber, 2017.04.12 23:39
MQL5-code:// https://www.mql5.com/en/code/16006 #include <MT4Orders.mqh> // Last version - https://www.mql5.com/ru/code/16006 // MQL4-code
That's all !!!
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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
I am aware that there is a script to stop all trades and close out all positions in MQL4.
But I am not aware of such code's existence in MQL5.
I couldn't find such script in there - where should I find such script which will stop all trades and close out all positions, or will the code from MQL4 work on MQL5 to have the same effect?