Dear Friends
I was using this codes to get todays high and yesterdays low values in MT4.
double ToDayHigh=iHigh(NULL,1440,0);
double YesterDayLow=iLow(NULL,1440,1);
Whats the code in MQL5 for the same.
Thanks
Noufel
try this
Paul
double ToDayHigh=iHigh(_Symbol,PERIOD_D1,0);
double YesterDayLow=iLow(_Symbol,PERIOD_D1,1);
double iLow(string strSymbol,ENUM_TIMEFRAMES tf,int nShift)
{
double timeseries[1];
if(CopyLow(strSymbol,tf,nShift,1,timeseries)==1) return(timeseries[0]);
else return(-1.0);
}
double iHigh(string strSymbol,ENUM_TIMEFRAMES tf,int nShift)
{
double timeseries[1];
if(CopyLow(strSymbol,tf,nShift,1,timeseries)==1) return(timeseries[0]);
else return(-1.0);
}
Dear Friends
I was using this codes to get todays high and yesterdays low values in MT4.
Please, read article MQL5.community - User Memo :
The
button of the object inserting menu is intended to insert the initial
MQL code into the text of the message. An empty window to paste the code
in appears as soon as you press this button. In order to finish code
adding you should press the Insert button. To cancel the
operation you should press the Cancel button. The example of
inserting the code is given at the corresponding section.
Thanks Rosh and Paul
I am getting the description
'=' - constant expression is required
when i am trying to compile in mql5 for the code
string symbol=Symbol();
Whats the soln please
Noufel
I am getting the description
'=' - constant expression is required
when i am trying to compile in mql5 for the code
"CopyHigh" on the high
And now the code works perfect...
Hi friends,
Want to check for at new value(nv) for sell indicator as follows. But no response for this,
help me to fix my pattern
***
bool M5LTPrevM5() { double ov,nv; ov=iHigh(NULL,PERIOD_M5,1)-iClose(NULL,PERIOD_M5,1); nv=iClose(NULL,PERIOD_M5,1)-ov; if(iClose(NULL,PERIOD_M5,1)==nv) return(true); return(false); }
Your math is "faulty" ...
ov = high - close nv = close - ov = close - high + close = 2 * close - high close == nv == 2 * close - high == high
Simplifying and taking into account floating point adjustments ...
bool M5LTPrevM5() { double dbHighM5 = iHigh( _Symbol, PERIOD_M5, 1 ), dbCloseM5 = iClose( _Symbol, PERIOD_M5, 1 ); return !( dbCloseM5 < dbHighM5 ); };
try this
Paul
double ToDayHigh=iHigh(_Symbol,PERIOD_D1,0); double YesterDayLow=iLow(_Symbol,PERIOD_D1,1);
Those are not assignments; they are initialization of a common (globally declared), or static variable with a constant. They work exactly the same way in MT4/MT5/C/C++.
-
They are initialized once on program load.
-
They don't update unless you assign to them.
-
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 indicator) or server related functions in OnInit (or on load or in OnTimer before you've received a tick), as there may be no connection/chart yet:
- Terminal starts.
- Indicators/EAs are loaded. Static and globally declared variables are initialized. (Do not depend on a specific order.)
- OnInit is called.
- For indicators OnCalculate is called with any existing history.
- Human may have to enter password, connection to server begins.
- New history is received, OnCalculate called again.
- New tick is received, OnCalculate/OnTick is called. Now TickValue, TimeCurrent, account information and prices are valid.
-
Unlike indicators, EAs are not reloaded on chart change, so you must reinitialize them, if necessary.
external static variable - MQL4 programming forum #2 (2013)

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Dear Friends
I was using this codes to get todays high and yesterdays low values in MT4.
double ToDayHigh=iHigh(NULL,1440,0);
double YesterDayLow=iLow(NULL,1440,1);
Whats the code in MQL5 for the same.
Thanks
Noufel