Newbie - Help with MTF indicator

 

Hello everyone. I am trying to use the modified MTF indicator to call a regular indicator but for some reason, when iterating through timeframes, I am only able to retrieve the current timeframes data. What am I doing wrong here? Thanks for any help!

MTF indicator:

//+------------------------------------------------------------------+
//|                                             Linear Price Bar.mq4 |
//|                                      Copyright © 2006, Keris2112 |
//|                                                             none |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, Keris2112"
#property link      "none"

#property indicator_separate_window
#property indicator_buffers 4
#property indicator_color1 Blue
#property indicator_color2 Red
#property indicator_color3 Blue
#property indicator_color4 Red

string indicatorName = "test";

//---- input parameters
/*************************************************************************
PERIOD_M1   1
PERIOD_M5   5
PERIOD_M15  15
PERIOD_M30  30 
PERIOD_H1   60
PERIOD_H4   240
PERIOD_D1   1440
PERIOD_W1   10080
PERIOD_MN1  43200
You must use the numeric value of the timeframe that you want to use
when you set the TimeFrame' value with the indicator inputs.
**************************************************************************/
extern int TimeFrame=0;

//---- buffers

double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];

extern string note2="Default Font Color";
extern color  FontColor=White;
extern string note3="Font Size";
extern int    FontSize=10;
extern string note4="Font Type";
extern string FontType="Trebuchet MS";
extern string note5 = "Display the price in what corner?";
extern string note6 = "Upper left=0; Upper right=1";
extern string note7 = "Lower left=2; Lower right=3";
extern int    WhatCorner=3;

double v1[];
double v2[];
double val1;
double val2;
double   RRR1=0,SL_price=0,TP_price=0, var1, var2, var3,var4, var5, var6;

string Timeframes[] = {"Period_M1", "Period_M5", "Period_M15", "Period_M30", "Period_H1", "Period_H4", "Period_D1", "Period_W1", "Period_MN1"};
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {

//---- indicators
   SetIndexStyle(0,DRAW_LINE,EMPTY,EMPTY,clrRed);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexStyle(2,DRAW_LINE,EMPTY,3);
   SetIndexBuffer(2,ExtMapBuffer3);
   SetIndexStyle(3,DRAW_HISTOGRAM,EMPTY,3);
   SetIndexBuffer(3,ExtMapBuffer4);
  
//---- name for DataWindow and indicator subwindow label   
   switch(TimeFrame)
   {
      case 1 : string TimeFrameStr="Period_M1"; break;
      case 5 : TimeFrameStr="Period_M5"; break;
      case 15 : TimeFrameStr="Period_M15"; break;
      case 30 : TimeFrameStr="Period_M30"; break;
      case 60 : TimeFrameStr="Period_H1"; break;
      case 240 : TimeFrameStr="Period_H4"; break;
      case 1440 : TimeFrameStr="Period_D1"; break;
      case 10080 : TimeFrameStr="Period_W1"; break;
      case 43200 : TimeFrameStr="Period_MN1"; break;
      default : TimeFrameStr="Current Timeframe";
   }
   
   IndicatorShortName("MTF_Linear Price Bar ("+TimeFrameStr+")");
   return(0);   
  }
//----
   
 
//+------------------------------------------------------------------+
//| MTF Parabolic Sar                                         |
//+------------------------------------------------------------------+
int start()
  {
  string text = "";
   for(int t=0; t<9; t++){
      string TimeFrame1 = Timeframes[t];
      datetime TimeArray[];
      int    i,limit,y=0,counted_bars=IndicatorCounted();
   
   // Plot defined time frame on to current time frame
      ArrayCopySeries(TimeArray,MODE_TIME,Symbol(),TimeFrame1); 
      
      limit=Bars-counted_bars;
      limit=Bars-counted_bars;
      for(i=0,y=0;i<limit;i++)
      {
      //if (Time[i]<TimeArray[y]) y++;
   
   /***********************************************************   
      Add your main indicator loop below.  You can reference an existing
         indicator with its iName  or iCustom.
      Rule 1:  Add extern inputs above for all neccesary values   
      Rule 2:  Use 'TimeFrame' for the indicator time frame
      Rule 3:  Use 'y' for your indicator's shift value
    **********************************************************/  
    
      
         if(i==0) {
            ExtMapBuffer1[i]=iCustom(NULL,TimeFrame1,indicatorName,0,0); // Data always the same here!
            ExtMapBuffer2[i]=iCustom(NULL,TimeFrame1,indicatorName,1,0); // And here!
            var1 = ExtMapBuffer1[i];
            var2 = ExtMapBuffer2[i];
            text += " | "+var1;
   
         }
         
      }
      
   ObjectCreate("test",OBJ_LABEL,0,0,0);
      ObjectSetText("test","test: " + text + "% from High",FontSize,FontType,FontColor);
      ObjectSet("test",OBJPROP_CORNER,2);
      ObjectSet("test",OBJPROP_XDISTANCE,10);
      ObjectSet("test",OBJPROP_YDISTANCE,10);  
      }
   return(0);
  }
//+------------------------------------------------------------------+


Indicator:

#property copyright "Click here: Barry Stander"
#property link      "http://myweb.absa.co.za/stander/4meta/"

#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Red
#property indicator_color2 Blue

extern string    SLLevel="SLPrice";
extern string    TPLevel="TPPrice";
extern string note2="Default Font Color";
extern color  FontColor=White;
extern string note3="Font Size";
extern int    FontSize=10;
extern string note4="Font Type";
extern string FontType="Trebuchet MS";
extern string note5 = "Display the price in what corner?";
extern string note6 = "Upper left=0; Upper right=1";
extern string note7 = "Lower left=2; Lower right=3";
extern int    WhatCorner=3;

//---- buffers
double v1[];
double v2[];
double val1;
double val2;
int i;
  
int init()
  {

  IndicatorBuffers(2);
 
//---- drawing settings
 SetIndexArrow(0, 119);
 SetIndexArrow(1, 119);
  
   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,1,Red);
   SetIndexDrawBegin(0,i-1);
   SetIndexBuffer(0, v1);
   SetIndexLabel(0,"Resistance");
    

   SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,1,Blue);
   SetIndexDrawBegin(1,i-1);
   SetIndexBuffer(1, v2);
   SetIndexLabel(1,"Support");
 
   return(0);
  }

int start()
  {
  double   RRR1=0,SL_price=0,TP_price=0, var1, var2, var3,var4, var5, var6;
   string   Text="";
   string   HighText="";
   string   LowText="";
   //int i=0;

   i=Bars;
   while(i>=0)
     {
   
      val1 = iFractals(NULL, 0, MODE_UPPER,i);
      if (val1 > 0){
         v1[i]=High[i];
         
      }
       else{
         v1[i] = v1[i+1];
         var1 = v1[i+1];
      }
  
      val2 = iFractals(NULL, 0, MODE_LOWER,i);
      if (val2 > 0) {
         v2[i]=Low[i];
      }
       else{
         v2[i] = v2[i+1];
         var2 = v2[i+1];
      }
        i--;
     }   
     
      
   return(0);
   
 
  }
 
//+------------------------------------------------------------------+
Documentation on MQL5: Constants, Enumerations and Structures / Chart Constants / Chart Timeframes
Documentation on MQL5: Constants, Enumerations and Structures / Chart Constants / Chart Timeframes
  • www.mql5.com
All predefined timeframes of charts have unique identifiers. The PERIOD_CURRENT identifier means the current period of a chart, at which a mql5-program is running.
 
Perhaps you should read the manual. 
Your code
Documentation
      string TimeFrame1 = Timeframes[t];
            ExtMapBuffer1[i]=iCustom(
NULL,
TimeFrame1,                            
indicatorName,
  ...            // custom indicator 
0,
0
); // Data always the same here!
⋮
double  iCustom(
   string       symbol,    // symbol
   int          timeframe, // timeframe
   string       name,      // path/name 
   ...                     // input parameters
   int          mode,      // line index
   int          shift      // shift
   );