Making Arrows (buffers) Appear On One Timeframe Only

 

So I have 16 buffers currently on this indicator, 4 for 4 different timeframes. 

I want 4 to appear only on one timeframe, 4 on another, etc..

Below is the code for the 15 min arrows. I've read about SetIndexBuffer, and ObjectSetInteger, but can't figure out how to apply them to these.

All the examples use ObjectCreate, or something else. I've not seen any that use buffers.

Do I need to change all of them to Objects, or is there a way of doing it with buffers?

//--- indicator buffers mapping

//------------M15--------------

    IndicatorBuffers(16);  
    SetIndexBuffer(0,buffer1);
    SetIndexStyle(0,DRAW_ARROW,EMPTY,ArrowSize,BuyArrowColor);
    SetIndexArrow(0,233);  

    SetIndexBuffer(1,buffer2);
    SetIndexStyle(1,DRAW_ARROW,EMPTY,ArrowSize,SellArrowColor);
    SetIndexArrow(1,234);  
    
    SetIndexBuffer(2,buffer3);
    SetIndexStyle(2,DRAW_ARROW,EMPTY,ArrowSize,upClosePriceArrowColor);
    SetIndexArrow(2,233);  
    
    SetIndexBuffer(3,buffer4);
    SetIndexStyle(3,DRAW_ARROW,EMPTY,ArrowSize,downClosePriceArrowColor);
    SetIndexArrow(3,234);  
    
 
write a function check each buffer and assign different timeframe
 
Samuel Akinbowale:
write a function check each buffer and assign different timeframe

I have it linked to this code;

if(upCloseArrowEnableM15 && tenkan_senValueM151 > kijun_sen_ValueM151 && tenkan_senValueM152 <= kijun_sen_ValueM152)
   { 
     buffer3[i] = iLow(Symbol(),PERIOD_M15, i) - distance *  Point;
     if(i == 0 && IsCrossNewBarM15() )

but when I go to higher timeframes, other arrows are their from other timeframes too

 
Then check if timeframe lower than current,to eliminate false alarm
 
Mohamad Zulhairi Baba:

https://docs.mql4.com/constants/objectconstants/visible

example above buffer will visible on M15 or H1 only.

I read this, as I said in my original post, but I don't understand how it works with buffers.

Can you give me an example with buffers? 

 
Mohamad Zulhairi Baba:

https://docs.mql4.com/constants/objectconstants/visible

example above buffer will visible on M15 or H1 only.

That is for Objects not Buffers

 
Keith Watford:

That is for Objects not Buffers


That's what I thought. Is there a way of doing it with buffers? Or do I need to make them all objects?
 
WTM:

That's what I thought. Is there a way of doing it with buffers? Or do I need to make them all objects?

You don't need to. You just need 4 buffers.

In OnInit check the chart period and set up the 4 buffers accordingly.

In OnCalculate, again check the period and only calculate the values for the buffers relevant to the chart time-frame.

Reason: