MTF Arrows:

 

Hello

I tried to make an arrow indicator to be multi timeframe and used the tutorial from the codebase  about Multi timeframe indicators. Unfortunately, when I changed timeframe from current, the indicator returns the error "Array Out of Range". Please how can I solve this? Kindly assist. 

Here is the full code

double ExtMapBuffer1[];
double ExtMapBuffer2[];
enum opt
  {
   Current,
   M1,
   M5,
   M15,
   M30,
   H1,
   H4,
   D1,
   W1
  };
extern bool Email = TRUE;
extern int SL_add_pips = 1000;
extern int changeLiner = 1;
extern opt TimeFrame = M1;
extern int Gup = 3;
int OnInit()
  {
   SetIndexStyle(0, DRAW_ARROW);
   SetIndexArrow(0, 233);
   SetIndexBuffer(0, ExtMapBuffer1);
   SetIndexStyle(1, DRAW_ARROW);
   SetIndexArrow(1, 234);
   SetIndexBuffer(1, ExtMapBuffer2);
   return(INIT_SUCCEEDED);
  }
int start()
  {
   datetime TimeArray[];
   int    i, limit, y = 0, counted_bars = IndicatorCounted();
   ArrayCopySeries(TimeArray, MODE_TIME, Symbol(), TimeFrame);
//----
   limit = Bars - counted_bars;
   for(i = 0, y = 0; i < limit; i++)
     {
      if(Time[i] < TimeArray[y])
         y++;
      ExtMapBuffer1[i] = iCustom(NULL, TimeFrame, "Non-repaint Arrows", Email, SL_add_pips, changeLiner, Gup, 2, y);
      ExtMapBuffer2[i] = iCustom(NULL, TimeFrame, "Non-repaint Arrows", Email, SL_add_pips, changeLiner, Gup, 3, y);
     }
   return (0);
  }
int time_use()
  {
   int time = Period();
   if(TimeFrame == M1)
      time = 1;
   if(TimeFrame == M5)
      time = 5;
   if(TimeFrame == M15)
      time = 15;
   if(TimeFrame == M30)
      time = 30;
   if(TimeFrame == H1)
      time = 60;
   if(TimeFrame == H4)
      time = 240;
   if(TimeFrame == D1)
      time = 1440;
   if(TimeFrame == W1)
      time = 10080;
   return time;
  }

 
  1.       ExtMapBuffer1[i] = iCustom(NULL, TimeFrame, "Non-repaint Arrows", Email, SL_add_pips, changeLiner, Gup, 2, y);
          ExtMapBuffer2[i] = iCustom(NULL, TimeFrame, "Non-repaint Arrows", Email, SL_add_pips, changeLiner, Gup, 3, y);
    

    Why did you post your MT4 question in the MT5 Indicators section instead of the MQL4 section, (bottom of the Root page)?
              General rules and best pratices of the Forum. - General - MQL5 programming forum? (2017)
    Next time, post in the correct place. The moderators will likely move this thread there soon.

  2. Invalid argument to iCustom.
  3. Always post all relevant code (using Code button) or attach the source file.

    Did you set the number of buffers? Program Properties (#property) - Preprocessor - Language Basics - MQL4 Reference

  4. Your code
    enum opt
      {
       Current,
       M1,
       M5,
       M15,
       M30,
       H1,
       H4,
       D1,
       W1
      };
    extern opt TimeFrame = M1;
    int time_use()
      {
       int time = Period();
       if(TimeFrame == M1)
          time = 1;
       if(TimeFrame == M5)
          time = 5;
       if(TimeFrame == M15)
          time = 15;
       if(TimeFrame == M30)
          time = 30;
       if(TimeFrame == H1)
          time = 60;
       if(TimeFrame == H4)
    +      time = 240;
       if(TimeFrame == D1)
          time = 1440;
       if(TimeFrame == W1)
          time = 10080;
       return time;
      }
    
    Simplified
    extern ENUM_TIMEFRAMES TimeFrame = PERIOD_M1;
    int time_use(){ return PeriodSeconds(TimeFrame)/60; }
 
I’m so sorry for using the wrong section. I honestly made a mistake. I hope the admins don’t get mad at me. 
 
William Roeder #:
  1. Why did you post your MT4 question in the MT5 Indicators section instead of the MQL4 section, (bottom of the Root page)?
              General rules and best pratices of the Forum. - General - MQL5 programming forum? (2017)
    Next time, post in the correct place. The moderators will likely move this thread there soon.

  2. Always post all relevant code (using Code button) or attach the source file.

    Did you set the number of buffers?Program Properties (#property) - Preprocessor - Language Basics - MQL4 Reference

  3. Your code
    Simplified
Thanks for the simplied version of the code although it doesn’t quite solve my problem but it’s good to know. 

Yes, I did set the buffer numbers to 2 correctly since only 2 buffers are used in the code ( for up and down arrows) 
 
William Roeder #:
  1. Why did you post your MT4 question in the MT5 Indicators section instead of the MQL4 section, (bottom of the Root page)?
              General rules and best pratices of the Forum. - General - MQL5 programming forum? (2017)
    Next time, post in the correct place. The moderators will likely move this thread there soon.

  2. Invalid argument to iCustom.
  3. Always post all relevant code (using Code button) or attach the source file.

    Did you set the number of buffers? Program Properties (#property) - Preprocessor - Language Basics - MQL4 Reference

  4. Your code
    Simplified

Thank you  William Roeder for helping me. I frankly wouldn't have figured it out without you.