Converting Timeframe to Candles

Abubakar Abu Saidu  

Hello.. good day to you all..

am trying to use Interval between candles.. instead of Timeframe Periods

i tried some other ways but am not getting it right at all...

//+------------------------------------------------------------------+
//|                                                         PA       |
//|                                      Copyright © 2019, Abu Saidu |
//|                                                t.me/ask4abusaidu |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2020, Abu Sa'id"
#property link     "https://www.mql5.com/en/users/ask4abusaidu"
 ""

#property strict
#property indicator_chart_window
input string arraY  = "--------------------< Interval Settigs >--------------------";
input int    Interval=3;
input int    Candles_Interval=24;//Candles Per Interval
input int    Size_Of_Zone=20;
input color   High_Color=clrAqua;
input color   Low_Color=clrYellow;
input int     LineWidth=2;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| 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[])
  {
//---
            for(int cnt=1; cnt<Interval+1; cnt++)
             {
            //  double D1Hi=iHighest(Symbol(),PERIOD_CURRENT,MODE_HIGH,Candles_Interval,cnt);
            //  double D1Lo=iHighest(Symbol(),PERIOD_CURRENT,MODE_LOW,Candles_Interval,cnt);
                 for(int x=0;x<Candles_Interval;x++)
                    {   
              double D1Hi=iHigh(Symbol(),PERIOD_D1,cnt);
              double D1Lo=iLow(Symbol(),PERIOD_D1,cnt);
              datetime D1Time=iTime(Symbol(),PERIOD_D1,cnt);
              datetime end = TimeCurrent();
      


               draw("Day"+IntegerToString(cnt)+"Highu",D1Time,D1Hi,end,D1Hi+Size_Of_Zone* Point, clrBlue);
               draw("Day"+IntegerToString(cnt)+"Highd",D1Time,D1Hi,end,D1Hi-Size_Of_Zone* Point, clrRed);
               draw("Day"+IntegerToString(cnt)+"Lowu",D1Time,D1Lo,end,D1Lo+Size_Of_Zone* Point, clrBlue);
               draw("Day"+IntegerToString(cnt)+"Lowd",D1Time,D1Lo,end,D1Lo-Size_Of_Zone* Point, clrRed);
                   
                   }
             
             }


 
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void draw(string Line,datetime TimeStart,double Price,datetime TimeEnd,double Price2,color line_clr)
  {
   if(ObjectFind(0,Line)<0)
   {
   ObjectCreate(0,Line,OBJ_RECTANGLE,0,TimeStart,Price,TimeEnd,Price2);
   ObjectSet(Line,OBJPROP_COLOR,line_clr);
   ObjectSet(Line,OBJPROP_BACK,true);
         ObjectSet(Line, OBJPROP_TIME1, TimeStart);
         ObjectSet(Line, OBJPROP_PRICE1, Price);
         ObjectSet(Line, OBJPROP_TIME2, TimeEnd);
         ObjectSet(Line, OBJPROP_PRICE2, Price2);
   }
  else
   {
   ObjectSet(Line,OBJPROP_COLOR,line_clr);
   ObjectSet(Line,OBJPROP_BACK,true);
         ObjectSet(Line, OBJPROP_TIME1, TimeStart);
         ObjectSet(Line, OBJPROP_PRICE1, Price);
         ObjectSet(Line, OBJPROP_TIME2, TimeEnd);
         ObjectSet(Line, OBJPROP_PRICE2, Price2);
   }
  }
//+------------------------------------------------------------------+

is there another method to simply use candles interval instead of Timeframe!!

eg.. Using 24Candles instead of using H4 or D1 to calculate.. 



here is a screenshot using D1


Dominik Egert  
Why?

But anyways, you can query data of other Timeframes using

iOpen(), iClose () and so on.

Or use CopyRates()
https://www.mql5.com/en/docs/series


Abubakar Abu Saidu  
Dominik Egert:
Why?

But anyways, you can query data of other Timeframes using

iOpen(), iClose () and so on.

Or use CopyRates()
https://www.mql5.com/en/docs/series


Hi.. thanks for your reply..

i dont mean timeframe..what  i mean is candles..

drawing Hlines at the highest or lowest of certain candles

eg.. the highest and lowest between 24 candles!! 

Dominik Egert  
So you are looking for ArrayMaximum() and ArrayMinimum ()


https://www.mql5.com/en/docs/array

Abubakar Abu Saidu  
Dominik Egert:
So you are looking for ArrayMaximum() and ArrayMinimum ()


https://www.mql5.com/en/docs/array

`Hi.. thanks a lot for your feedback.. unfortunately.. ArrayMaximum() and ArrayMinimum () does not do it

but i managed to figured it out myself.. thanks a lot for your kind response and helpful links!! i really appreciate!!


            
             int Candles=20,Shift=1;
             double h_C= High[iHighest(_Symbol, PERIOD_CURRENT, MODE_HIGH, Candles, Shift)];
             double l_C= Low[iLowest(_Symbol, PERIOD_CURRENT, MODE_LOW, Candles, Shift)];
Reason: