I can not use High and Low in Code New comment

 

Actually I have two questions. I'm studying in a video, in which the boy uses mql4 to give the lesson. And when he types, the program, a. Another thing that is not a high and low video to get the value of Maxima and the Minimum of the Last candle, mql5 does not recognize High and Low.

 //VARIAVEIS
double bid = SymbolInfoDouble ( _Symbol , SYMBOL_BID );
double max_ant;
double min_ant;


void OnTick (){
max_ant = High[ 1 ];
min_ant = Low[ 1 ];

   if (bid > max_ant){
   Comment ( "ROMPIMENTO DE MAXIMA ANTERIOR" );
  }
  
   if (bid < min_ant){
   Comment ( "ROMPIMENTO DE MINIMA ANTERIOR" );
  }
   
  }

 
Hi,

For MQL5 you must use iHigh and iLow functions:

MQL4
MQL5
High[1]
iHigh(Symbol(),PERIOD_CURRENT,1)
Low[1]
iLow(Symbol(),PERIOD_CURRENT,1)
 
Henrique Araújo: in which the boy uses mql4 to give the lesson.
double bid = SymbolInfoDouble ( _Symbol , SYMBOL_BID );
⋮
void OnTick (){ …
  1. Global and static variables work exactly the same way in MT4/MT5/C/C++.
    1. They are initialized once on program load.
    2. They don't update unless you assign to them.
    3. In C/C++ you can only initialize them with constants, and they default to zero. In MTx you should only initialize them with constants. There is no default in MT5 (or MT4 with strict which you should always use.)

      MT4/MT5 actually compiles with non-constants, but the order that they are initialized is unspecified and don't try to use any price or server related functions in OnInit (or on load,) as there may be no connection/chart yet:

      1. Terminal starts.
      2. Indicators/EAs are loaded. Static and globally declared variables are initialized. (Do not depend on a specific order.)
      3. OnInit is called.
      4. For indicators OnCalculate is called with any existing history.
      5. Human may have to enter password, connection to server begins.
      6. New history is received, OnCalculate called again.
      7. New tick is received, OnCalculate/OnTick is called. Now TickValue, TimeCurrent, account information and prices are valid.
    4. Unlike indicators, EAs are not reloaded on chart change so you must reinitialize them, if necessary.
                external static variable - Inflation - MQL4 programming forum

  2. Henrique Araújo: Another thing that is not a high and low video to get the value of Maxima and the Minimum of the Last candle, mql5 does not recognize High and Low.
    Be careful with your case. There is no High and Low in MT5. There is a high and low in both (OnCalculate.)