MTF in tester

 

I cannot find a MTF indicator that works in tester .    i.e.  run 1 min chart and plot 5min MTF indicator........

Are there any examples to follow?


I saw an iunima_mtf.mq5  but it uses stuff not in MT4 compiler.

BarsCalculated

CopyBuffer


I was thinking that  embedded indicator in a MTF version may not work anymore, i tried but failed.

i.e.

UpBuffer[i]  = iCustom(NULL,TimeFrame,"Envelopes_v5",MA_Period,MA_Met

etc.


Then i looked at something that calls an MT4 function, see below, but that does not work either.......



.

//+------------------------------------------------------------------+
//|                                                     Band MTF.mq4 |
//|                   Copyright © *** onewithzachy ***  .14 May 2012 |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Copyright © *** onewithzachy ***  .14 May 2012"
#property link      ""

#property indicator_chart_window
#property indicator_buffers 6
#property indicator_color1 White
#property indicator_color2 White
#property indicator_color3 White
#property indicator_color4 White
#property indicator_color5 White
#property indicator_color6 White
//--- input parameters
extern int       First_TF=0;
extern color     First_Color=White;
extern int       First_Line_Width=1;
extern int       Second_TF=0;
extern color     Second_Color=Gold;
extern int       Second_Line_Width=1;
extern int       Bands_Period=20;
extern int       Bands_Deviation=2;
extern int       Bands_price_Type=0;

//--- buffers
double Upper_1[], Middle_1[], Lower_1[], Upper_2[], Middle_2[], Lower_2[];
int TF [9] = {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
   int count;
   
   if (First_TF <= 0)
      {
      for (count =0 ; count < 9; count ++)
        {
        if (TF [count] <= Period () ) 
           continue;
           else
           {
           First_TF = TF [count];
           break;
           }
        }
      }
    
   if (Second_TF <= 0)
      {
      for (count =0 ; count < 9; count ++)
        {
        if (TF [count] <= First_TF ) 
           continue;
           else
           {
           Second_TF = TF [count];
           break;
           }
        }
      }
   
   SetIndexBuffer(0,Upper_1);
   SetIndexBuffer(1,Middle_1);
   SetIndexBuffer(2,Lower_1);
   SetIndexBuffer(3,Upper_2);
   SetIndexBuffer(4,Middle_2);
   SetIndexBuffer(5,Lower_2);
   
   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,First_Line_Width,First_Color);
   SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,First_Line_Width,First_Color);
   SetIndexStyle(2,DRAW_LINE,STYLE_SOLID,First_Line_Width,First_Color);
   SetIndexStyle(3,DRAW_LINE,STYLE_SOLID,Second_Line_Width,Second_Color);
   SetIndexStyle(4,DRAW_LINE,STYLE_SOLID,Second_Line_Width,Second_Color);
   SetIndexStyle(5,DRAW_LINE,STYLE_SOLID,Second_Line_Width,Second_Color);
   
   SetIndexLabel(0,StringConcatenate("Upper TF ",First_TF));
   SetIndexLabel(1,StringConcatenate("Middle TF ",First_TF));   
   SetIndexLabel(2,StringConcatenate("Lower TF ",First_TF)); 
   SetIndexLabel(3,StringConcatenate("Upper TF ",Second_TF));
   SetIndexLabel(4,StringConcatenate("Middle TF ",Second_TF));   
   SetIndexLabel(5,StringConcatenate("Lower TF ",Second_TF));
   
   IndicatorDigits (Digits);
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int pos, Shift, Pos_First_TF, Pos_Second_TF, Max_Shift;
   double Upper, Middle, Lower;
//----

  
   //   Writing value to buffer
   for (pos = Bars - Max_Shift - 1; pos >= 0; pos --)
     {
     if (First_TF >= Period ())
        {
        Shift = iBarShift (Symbol(), First_TF, Time [pos], True);
        if (Shift >= 0) Pos_First_TF = Shift;
        BAND_IT (First_TF, Pos_First_TF, Upper, Middle, Lower);
        Upper_1  [pos] = Upper;  
        Middle_1 [pos] = Middle;  
        Lower_1  [pos] = Lower;
        }
        
     if (Second_TF >= Period ())
        {
        Shift = iBarShift (Symbol(), Second_TF, Time [pos], True);
        if (Shift >= 0) Pos_Second_TF = Shift;
        BAND_IT (Second_TF, Pos_Second_TF, Upper, Middle, Lower);
        Upper_2  [pos] = Upper;  
        Middle_2 [pos] = Middle;  
        Lower_2  [pos] = Lower;
        }
     }
     
     Max_Shift = MathMax (Pos_First_TF, Pos_Second_TF);
//----
   return(0);
  }
//+------------------------------------------------------------------+
void BAND_IT (int tf, int pos, double& upper, double& middle, double& lower)
  {
  upper  = iBands (Symbol(), tf, Bands_Period, Bands_Deviation, 0, PRICE_CLOSE, MODE_UPPER, pos);
  middle = iMA    (Symbol(), tf, Bands_Period, 0, MODE_SMA, PRICE_CLOSE, pos);  
  lower  = iBands (Symbol(), tf, Bands_Period, Bands_Deviation, 0, PRICE_CLOSE, MODE_LOWER, pos); 
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
  

.

.

.

Reason: