Download MetaTrader 5
To add comments, please log in or register
Create Forum topics and improve your rating!
Justify
59
Justify 2014.10.20 08:31 

Hi,

 I'm learning to program. I already used several functions, but now I want to know how to program multi time frame indicators. For example, how I can get signals fractals "m15" in "m5" (current time frame)? 

I do not know how to work with functions of time or bars. 

If anyone can tell me how I can start would appreciate. 

Thank you very much

Ernst Van Der Merwe
4407
Ernst Van Der Merwe 2014.10.20 08:46  
justify:

Hi,

 I'm learning to program. I already used several functions, but now I want to know how to program multi time frame indicators. For example, how I can get signals fractals "m15" in "m5" (current time frame)? 

I do not know how to work with functions of time or bars. 

If anyone can tell me how I can start would appreciate. 

Thank you very much

Use iBarShift()

   int shift = iBarShift(NULL,PERIOD_M15,Time[i]);
   double fractal_upper = iFractals(NULL,PERIOD_M15,MODE_UPPER,shift);
Justify
59
Justify 2014.10.20 09:34  

The indicator shows no sign:

 

#property copyright "Copyright 2013, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#property indicator_chart_window
#property indicator_buffers 2

  
  //+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+

int start()
  {
  int counted_bars=IndicatorCounted();


if (counted_bars>0)
counted_bars--;
int limit= Bars-counted_bars;


for (int i=0;i<limit;i++)
{
int shift = iBarShift(NULL,PERIOD_M15,Time[i]);
double fractal_upper = iFractals(NULL,PERIOD_M15,MODE_UPPER,shift);

}
return(0);
} 

 

#property copyright "Copyright 2013, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Red

  
  //+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+

int start()
  {
  int counted_bars=IndicatorCounted();


if (counted_bars>0)
counted_bars--;
int limit= Bars-counted_bars;


for (int i=0;i<limit;i++)
{
int shift = iBarShift(NULL,PERIOD_M15,Time[i]);
double fractal_upper = iFractals(NULL,PERIOD_M15,MODE_UPPER,shift);

}
return(0);
} 
Ernst Van Der Merwe
4407
Ernst Van Der Merwe 2014.10.20 09:53  
justify:

The indicator shows no sign:

 

 

 

You have to declare an array and assign it to a buffer.

#property copyright "Copyright 2013, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#property indicator_chart_window
#property indicator_buffers 1

double fractal_upper[];
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
init()
  {
   SetIndexBuffer(0,fractal_upper);
   SetIndexStyle(...
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int counted_bars=IndicatorCounted();

   if(counted_bars>0)
      counted_bars--;
   int limit=Bars-counted_bars;

   for(int i=0;i<limit;i++)
     {

      int shift=iBarShift(NULL,PERIOD_M15,Time[i]);

      fractal_upper[i]=iFractals(NULL,PERIOD_M15,MODE_UPPER,shift);

     }
   return(0);
  }
//+------------------------------------------------------------------+
Justify
59
Justify 2014.10.20 10:06  
The reason for the 3 arrows appearing is because one candle in M15 is 3 candles in M5? 

Only to learn, there is a solution? 
How to manage time in this situation ?. 

Thank you very much pidPod

 

 

Justify
59
Justify 2014.10.20 10:24  
I try to use the iCustom iBarshift indicator, but no signal. 

The fractalsUp, in current time frame indicator works correctly, but if I try to display signs of "m15" in "m5", I have no signal.

#property copyright "Copyright 2013, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 DeepSkyBlue
#property indicator_color2 Red
//---- input parameters
extern int       Equals=5;
extern int       nLeftUp=2;
extern int       nRightUp=2;
extern int       nLeftDown=2;
extern int       nRightDown=2;




//---- buffers
double fractalsUp[];



//+------------------------------------------------------------------+
//| Custom indicator initialization functi                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_ARROW);
   SetIndexArrow(0,217);
   SetIndexBuffer(0,fractalsUp);
   SetIndexEmptyValue(0,0.0);
   
    return(0);
  }
  
  //+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+

int start()
  {
  int counted_bars=IndicatorCounted();


if (counted_bars>0)
counted_bars--;
int limit= Bars-counted_bars;


for (int i=0;i<limit;i++)
{
 int shift=iBarShift(NULL,PERIOD_M15,Time[i]);
fractalsUp[i]=iCustom(NULL,PERIOD_M15,"fractalsUp",Equals,nLeftUp,nRightUp,nLeftDown,nRightDown,0,shift);



}
return(0);

 

Ernst Van Der Merwe
4407
Ernst Van Der Merwe 2014.10.20 10:40  
justify:
I try to use the iCustom iBarshift indicator, but no signal. 

The fractalsUp, in current time frame indicator works correctly, but if I try to display signs of "m15" in "m5", I have no signal.

 

I'll have to see your fractalsUp indicator to know where the problem is.
Ernst Van Der Merwe
4407
Ernst Van Der Merwe 2014.10.20 11:55  
justify:

fractalsUp run correctly in current time frame:

 

 

 

So I think, the problem is in the code of last message. 

Try using iBarShift() in fractalsUp instead?
Justify
59
Justify 2014.10.20 12:21  
pipPod:
Try using iBarShift() in fractalsUp instead?

I send you a PM,

I try but   I continued without signal

/
To add comments, please log in or register