Questions from Beginners MQL5 MT5 MetaTrader 5 - page 673
![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
How to detect the alerts via iCustom ?
Maybe you know already existing indicators/advisors for that ?
I am writing an EA which works on a martingale basis.
How can I get it to close all of its open orders when the maximum permissible loss in pips is reached on one currency pair?
If you really need it in pips and not in money, here is a function to apply just like the last one
//------------------ Возвращает суммарный профит открытых позиций в пунктах --------------------+
//===============================================================================================
double GetProfitOpenPosInPoint(string symb="0", int type=-1, int mg=-1) {
double p=0, prb=0, prs=0, pr=0;
if(symb=="0") { symb=Symbol();}
for(int i=0; i<OrdersTotal(); i++) {
if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
if((OrderSymbol()==symb||symb=="")&&(type<0||OrderType()==type)&&(mg<0||OrderMagicNumber()==mg)) {
p=MarketInfo(OrderSymbol(), MODE_POINT)*Sign;
if(OrderType()==OP_BUY) {
prb+=((MarketInfo(OrderSymbol(), MODE_BID)-OrderOpenPrice())/p);
}
if(OrderType()==OP_SELL) {
prs+=((OrderOpenPrice()-MarketInfo(OrderSymbol(), MODE_ASK))/p);
}
pr=prb+prs;
}
}}
return(pr);
}
Hello,What code should I add to make the alerts of any indicator appear in the EA?
How to detect the alerts via iCustom ?
Maybe you know already existing indicators/advisors for that ?
Hi. I wanted to open.ex4 file with mt4.exe and set it to use for all files. How can i revert the "windows general shell library" ? for some reason mt4 does not see this EA (robot) now.
You won't believe it, but everyone!!! wants to open a .ex4 file, the problem is that it has never been opened for editing, and won't open.
Editable files are .mq4 only, executable files are .ex4
Client terminal events
Init
Immediately after the client terminal loads a program (Expert Advisor or custom indicator) and starts the initialization of global variables, an Init event will be sent that is handled using OnInit(), if available. This event is also generated after a security and/or chart period change, after recompiling the program in MetaEditor, after a change of input parameters from an Expert Advisor or a custom indicator setting window. The Expert Advisor is also initialized after the account is changed. The Init event is not generated for scripts.
And if it is not "out of the window"? For example, during optimization mode in the Strategy Tester ? Where to read about it ?
Client terminal events
Init
Immediately after the client terminal loads a program (Expert Advisor or custom indicator) and starts the initialization of global variables, an Init event will be sent that is handled using OnInit(), if available. This event is also generated after a security and/or chart period change, after recompiling the program in MetaEditor, after a change of input parameters from an Expert Advisor or a custom indicator setting window. The Expert Advisor is also initialized after the account is changed. The Init event is not generated for scripts.
And if it is not "out of the window"? For example, during optimization mode in the Strategy Tester ? Where to read about it ?
In optimisation mode, each pass with new parameters is nothing but a new program run. Accordingly after start the event OnInit() passes.
Thank you Vladimir! I understand it)). But where in the documentation it is written? If I put Print, Alert, Comment in init(), nothing is written either to the journal or to the screen. How can we be sure of what we know about?
There are limitations for some functions in the strategy tester of the client terminal.
Functions Print() and PrintFormat()
To improve the performance when optimizing EA parameters, functionsPrint() andPrintFormat() are not executed. The exception is the use of these functions inside theOnInit() handler. This allows us to facilitate the search of error causes when errors occur.
The Alert(), MessageBox(), PlaySound(), SendFTP, SendMail(), SendNotification() and WebRequest() functions
TheAlert(),MessageBox(),PlaySound(),SendFTP(),SendMail(),SendNotification() andWebRequest() functions interacting with the "outside world" are not executed in the strategy tester.
And to make sure - start debugging on the history and set breakpoint in OnInit().
I can't get something to print() into the tester's log. How do you do this?