Questions from Beginners MQL5 MT5 MetaTrader 5 - page 673

 
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 ?
 
RichLux:

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);
}
 
greeng2016:
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 ?
As far as I know, the appearance of the alert window cannot be tracked.
 
Hi. I wanted to open.ex4 file with mt4.exe and set it to use for all files. How do I get the "windows general shell library" back ? for some reason mt4 can't see this expert (robot) now.
Files:
pui_mqhrx2.png  40 kb
 
VSEVPOTOLKI:
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 ?

 
Leo59:

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 optimization mode, each pass with new parameters is nothing else but a new program start. The OnInit() event is executed accordingly after the start.
 
Vladimir Karputov:
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 is it written in the documentation? If I put Print, Alert and Comment in init(), nothing gets shown in the log or on the screen. How can we be sure of what we know about?
 
Leo59:
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?

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?

Reason: