Showing higher timeframe indicators

 

Hi - as per my other posts I'm sure this has already been talked about, but I can't find it :)

Is it possible to set up an indicator so that it shows you a higher time frame but to the scale of a short time frame?

That might not make much sense - so here's are some pics to show what I mean.

The indicator is the close of the m15 - so nothing difficult. The code for it is stipped right back -


#property indicator_separate_window
#property indicator_buffers 2


double Array[];

int OnInit()
  {

   SetIndexBuffer(0,Array);
   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,1,clrRed);
  
  
  
//---
   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[])
  {
//---
  
   int counted_bars=IndicatorCounted();
   if(counted_bars<0)return(-1);
   if(counted_bars>0) counted_bars--;
   int uncountedbars=Bars-counted_bars;
      
  
   for(int i=0;i<uncountedbars;i++)
  
   {
     Array[i]=iClose(0,PERIOD_M15,i);
     }
  


  
//--- return value of prev_calculated for next call
   return(rates_total);
  }

I've got two versions of this - one on chart and one as seperate window.

When I have it on the m15 chart - its fine - as far as I can tell both the on chart and seperate window are showing an indicators that shows the close of the m15 candles.




When I toggle to m5, the m15 lines stay the same



What I want to be able to do is see the m15 line at m5 resolution (or m1 for that matter). I reaslise that means that the m15 line won't update every m5/m1 candle - but I'm wondering if this is possible as a simple way of checking whether an EA that invovles different timeframes has worked.

Thanks in advance for any help :)

 
You are mixing apples and oranges
   for(int i=0;i<uncountedbars;i++){
      Array[i]=iClose(0,PERIOD_M15,i);
 
whroeder1:
You are mixing apples and oranges
   for(int i=0;i<uncountedbars;i++){
      Array[i]=iClose(0,PERIOD_M15,i);

I know - the question is - is there a way to do that?

I can think of some failry complex coding ways (such as work out which 1 min periods fall into which 15 min period, then find the close of the last one etc) - but I was wondering if there was a simple way of doing it?

 
David: - is there a way to do that?
Maybe you should link on the link provided and start learning.
 
Ah - didn't see the link under the colours - many thanks - I'll read and see where I get to :)
 
Thank - read both the links and followed the logic of using iBarShift to find the corresponding high time frame bar for the time of the bar thats being examined. It now seems to be showing what I want. Next task is to get it showing something more useful than just the close of the those higher timeframe periods - and then to move it into an EA...
Reason: