Need help to convert iHighest , iLowest to mql5 ?

 

Hi,

If anyone can help converting this from mql4 to mql5 as I try to understand the new logic of mql5.

Thanks.

 

double High4=iHigh(Symbol(),PERIOD_H1,iHighest(Symbol(),PERIOD_H1,MODE_HIGH,4,1));

double Low4=iLow(Symbol(),PERIOD_H1,iLowest(Symbol(),PERIOD_H1,MODE_LOW,4,1));

double Med4=(High4+Low4)/2;

 

bool orderBuy=Ask>Med4;

bool orderSell=Bid<Med4;

 

etc…

 
yvel13:

Hi,

If anyone can help converting this from mql4 to mql5 as I try to understand the new logic of mql5.

Thanks.

 

double High4=iHigh(Symbol(),PERIOD_H1,iHighest(Symbol(),PERIOD_H1,MODE_HIGH,4,1));

double Low4=iLow(Symbol(),PERIOD_H1,iLowest(Symbol(),PERIOD_H1,MODE_LOW,4,1));

double Med4=(High4+Low4)/2;

 

bool orderBuy=Ask>Med4;

bool orderSell=Bid<Med4;

 

etc…

Try this: It might be the long way around, but it produces a value. Just hope it is the correct value.

double High[],Low[];

void OnTick()
{
  double High=iHigh(_Symbol,PERIOD_H1,iHighest(_Symbol,PERIOD_H1,4,1));
  double Low=iLow(_Symbol,PERIOD_H1,iLowest(_Symbol,PERIOD_H1,4,1));

  double Med4=(High+Low)/2;

return:
}

double iHigh(string symbol,ENUM_TIMEFRAMES timeframe,int index)
  {
   double high=0;
   ArraySetAsSeries(High,true);
   int copied=CopyHigh(symbol,timeframe,0,Bars(symbol,timeframe),High);
   if(copied>0 && index<copied) high=High[index];
   return(high);
  }


int iHighest(string symbol,ENUM_TIMEFRAMES tf,int count=WHOLE_ARRAY,int start=0)
  {
      double High[];
      ArraySetAsSeries(High,true);
      CopyHigh(symbol,tf,start,count,High);
      return(ArrayMaximum(High,0,count)+start);
     
     return(0);
}

double iLow(string symbol,ENUM_TIMEFRAMES timeframe,int index)
  {
   double low=0;
   ArraySetAsSeries(Low,true);
   int copied=CopyLow(symbol,timeframe,0,Bars(symbol,timeframe),Low);
   if(copied>0 && index<copied) low=Low[index];
   return(low);
  }


int iLowest(string symbol,ENUM_TIMEFRAMES tf,int count=WHOLE_ARRAY,int start=0)
  {
      double Low[];
      ArraySetAsSeries(Low,true);
      CopyLow(symbol,tf,start,count,Low);
      return(ArrayMinimum(Low,0,count)+start);
     
     return(0);
}



 

Thanks, I had to do some modification but it works.
//+------------------------------------------------------------------+
//|                                                     Hi_Lo_EA.mq5 |
//|                                           Copyright 2010, yvel13 |
//|                                                 yvel13@gmail.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2010, yvel13"
#property link      "yvel13@gmail.com"
#property version   "1.00"

//--- input parameters
input int StartBars=1;    // Start Bar in count
input int TotalBars=4;    // Total Bar in count

//---
//Your setting...

//--- Tendences Parameters ------------------------------------------+
double iHigh(string symbol,ENUM_TIMEFRAMES timeframe,int index)
  {
 double high=0;
 ArraySetAsSeries(High,true);
 int copied=CopyHigh(symbol,timeframe,0,TotalBars,High);
 if(copied>0 && index<copied) high=High[index];
 return(high);
  }

int iHighest(string symbol,ENUM_TIMEFRAMES tf,int count=WHOLE_ARRAY,int start=0)
  {
 double High[];
 ArraySetAsSeries(High,true);
 CopyHigh(symbol,tf,start,count,High);
 return(ArrayMaximum(High,0,count)+start);
 return(0);
  }
  
double iLow(string symbol,ENUM_TIMEFRAMES timeframe,int index)
  {
 double low=0;
 ArraySetAsSeries(Low,true);
 int copied=CopyLow(symbol,timeframe,0,TotalBars,Low);
 if(copied>0 && index<copied) low=Low[index];
 return(low);
  }

int iLowest(string symbol,ENUM_TIMEFRAMES tf,int count=WHOLE_ARRAY,int start=0)
  {
 double Low[];
 ArraySetAsSeries(Low,true);
 CopyLow(symbol,tf,start,count,Low);
 return(ArrayMinimum(Low,0,count)+start);
 return(0);
  }

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
{
}
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
}

//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//--- Valeur of Tendences -------------------------------------------+
 double High=iHigh(_Symbol,_Period,iHighest(_Symbol,_Period,TotalBars,StartBars));
 double Low=iLow(_Symbol,_Period,iLowest(_Symbol,_Period,TotalBars,StartBars));
 double Med=(High+Low)/2;
//--- End -----------------------------------------------------------+

// Your functions ...
  }
return(0)

 
If you would like to reduce the volume of code in your EA.mq5 source file, there is an include file mt4timesereis_2.mqh that has all of your needed subroutines and many more.
//+------------------------------------------------------------------+
//|                                                     Hi_Lo_EA.mq5 |
//|                                           Copyright 2010, yvel13 |
//|                                                 yvel13@gmail.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2010, yvel13"
#property link      "yvel13@gmail.com"
#property version   "1.00"

#include <mt4timeseries_2.mqh>

//--- input parameters
input int StartBars=1;    // Start Bar in count
input int TotalBars=4;    // Total Bar in count

//---
//Your setting...

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
{
}
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
}

//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//--- Valeur of Tendences -------------------------------------------+
 double High=iHigh(_Symbol,_Period,iHighest(_Symbol,_Period,TotalBars,StartBars));
 double Low=iLow(_Symbol,_Period,iLowest(_Symbol,_Period,TotalBars,StartBars));
 double Med=(High+Low)/2;
//--- End -----------------------------------------------------------+

// Your functions ...
  }
return(0)





Also, you can add additional sub-routines to this file for many of the predefined timeseries access calls that we have in MT-4.

Example of High[] in MT-4:

double High(int index)
{
  double High[];
  double high=0;
  ArraySetAsSeries(High,true);
  int copied=CopyHigh(_Symbol,0,0,Bars(_Symbol,0),High);
  if(copied>0) high=High[index];
  return(high);
}
Then call the high value of last bar on symbol chart, use High(0). and 1 bar back use High(1) and etc. The difference from MT-4 to MT-5 then would be {} used in MT-4 and () would be used in MT-5.



Files:
 

I want to thank all of you that have been contributing to this forum. May GOD grant you greater vision into what you are doing.

I have been able to download some indicators for mt5 platform but have not been able to attach them to the chats. Please can you enlighten me on how to do this? Is there a link to any tutorial on how best to do this and other things on the mt5 platform.

Thanks and have a wonderful week ahead. 

 

 
220760:

I want to thank all of you that have been contributing to this forum. May GOD grant you greater vision into what you are doing.

I have been able to download some indicators for mt5 platform but have not been able to attach them to the chats. Please can you enlighten me on how to do this? Is there a link to any tutorial on how best to do this and other things on the mt5 platform.

Thanks and have a wonderful week ahead. 

 

In MT5, there's a little change with directories (for the better:P)

You have to copy indicators you have dowloaded into {your MT5 directory}\MQL5\Indicators\

then you can compile it through mql5 language editor.

then add it through  Insert -> Indicators -> Custom -> your indicator

:) 

 
yvel13:

Hi,

If anyone can help converting this from mql4 to mql5 as I try to understand the new logic of mql5.

Thanks.

 

double High4=iHigh(Symbol(),PERIOD_H1,iHighest(Symbol(),PERIOD_H1,MODE_HIGH,4,1));

double Low4=iLow(Symbol(),PERIOD_H1,iLowest(Symbol(),PERIOD_H1,MODE_LOW,4,1));

double Med4=(High4+Low4)/2;

 

bool orderBuy=Ask>Med4;

bool orderSell=Bid<Med4;

 

etc…

double Highest(string symbol,ENUM_TIMEFRAMES timeframe,int count=WHOLE_ARRAY,int start=0)
  {
   double highest=0;
   double High[];
   ArraySetAsSeries(High,true);
   int copied=CopyHigh(symbol,timeframe,start,count,High);
   int index=ArrayMaximum(High,0,count)+start;
   if(copied>0 && index<copied) highest=High[index];
   return(highest);
  }

double Lowest(string symbol,ENUM_TIMEFRAMES timeframe,int count=WHOLE_ARRAY,int start=0)
  {
   double lowest=0;
   double Low[];
   ArraySetAsSeries(Low,true);  
   int copied=CopyLow(symbol,timeframe,start,count,Low);
   int index=ArrayMinimum(Low,0,count)+start;
   if(copied>0 && index<copied) lowest=Low[index];
   return(lowest);
  }