How to get the High price of a bar specified with an open time ?

 

How to get the High price of  a bar specified with an open time ?

 

//+------------------------------------------------------------------+
//|                                                     test2012.mq5 |
//|                        Copyright 2012, MetaQuotes Software Corp. |
//|                                              http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2012, MetaQuotes Software Corp."
#property link      "http://www.mql5.com"
#property version   "1.00"
#property indicator_chart_window
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   
//---
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
//---
         
         datetime opentime = D'2012.04.25 13:25';     //  I want to get the High price of this bar 
         
      //   int      index  = ibarshift(NULL,0,opentime); 
      //   How to the index of bar in MQL5 ?
      //   
         
         double   highprice  = high[index];   
         
        
   
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+

 

 

 Thanks in advance.

Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants / Position Properties
  • www.mql5.com
Standard Constants, Enumerations and Structures / Trade Constants / Position Properties - Documentation on MQL5
 
//+------------------------------------------------------------------+
//|                                                     test2012.mq5 |
//|                        Copyright 2012, MetaQuotes Software Corp. |
//|                                              http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2012, MetaQuotes Software Corp."
#property link      "http://www.mql5.com"
#property version   "1.00"
#property indicator_chart_window
#property indicator_plots 1 
#property indicator_buffers 1 

double myhigh=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   
//---
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
{
   datetime opentime = D'2012.04.25 13:25';     //  I want to get the High price of this bar 

   if(opentime<time[rates_total-1])
    {
    for(int i=1;i<rates_total;i++)
      {
        if(time[i-1]<opentime && time[i]>=opentime) { myhigh=high[i];}
      }
       
    }  
     else {myhigh=high[rates_total-1];}
     
     Print ("Myhigh=",(string)myhigh);
      
   return(rates_total);
  }
//+------------------------------------------------------------------+

 
Karlson:

Thank you Karlson !

I see now.