#MTF_TMA





//+------------------------------------------------------------------+
//|                                            #MTF_4_CoeffoLine.mq4 |
//|                      Copyright © 2005, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+

#property copyright "Copyright © 2005, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"





#property indicator_chart_window

#property indicator_buffers 4
#property indicator_color1 Blue
#property indicator_color2 Blue
#property indicator_color3 Blue
#property indicator_color4 Blue
//---- input parameters

//---- buffers
double Buffer_M5[];
double Buffer_M15[];
double Buffer_M30[];
double Buffer_H1[];


datetime dt5[200], dt15[200], dt30[200], dth1[200];   

extern string CustomIndicator = "TMA";
extern int CustomIndIndex = 0;
extern int PRD_1 = 5;
extern int PRD_2 = 15;
extern int PRD_3 = 30;
extern int PRD_4 = 60;

//-----------------------
extern int       Periods=30;
extern int       ApplyTo=0;



//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,Buffer_M5);

   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,Buffer_M15);

   SetIndexStyle(2,DRAW_LINE);
   SetIndexBuffer(2,Buffer_M30);

   SetIndexStyle(3,DRAW_LINE);
   SetIndexBuffer(3,Buffer_H1);
   
   IndicatorShortName("MTF_4_TMA M5,M15,M30,M60");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
   int limit, shift;
   if(counted_bars<0) return(-1);
   if (counted_bars==0) limit=Bars-1;  // limit = Bars-MinBars-1;
//---- last counted bar will be recounted
   if(counted_bars>0) limit=Bars-counted_bars;
   limit--;

   int i5 = 0, i15 = 0, i30 = 0, ih1 = 0;

   static bool fft = true;
   
   //if (NewBar()) // Update array every 15 minutes
   {
      ArrayCopySeries(dt5,MODE_TIME,Symbol(),PRD_1); 
      ArrayCopySeries(dt15,MODE_TIME,Symbol(),PRD_2); 
      ArrayCopySeries(dt30,MODE_TIME,Symbol(),PRD_3); 
      ArrayCopySeries(dth1,MODE_TIME,Symbol(),PRD_4); 
   }   
   
   if ((fft) && (Symbol() == "EURUSD"))
   {
      fft = false;
      datetime d = iTime(NULL, PERIOD_D1, 0);
      for (int j=0; j<80; j++)
      {
         Print(j,") ",dt5[j]-d," ",dt15[j]-d, " ", dt30[j]-d," ", dth1[j]-d);
      }
   }
   for(int i=0; i<limit; i++)
   {   
      datetime ddt = iTime(NULL, 0, i);
      if (ddt<dt5[i5]) i5++;
      if (ddt<dt15[i15]) i15++;
      if (ddt<dt30[i30]) i30++;
      if (ddt<dth1[ih1])  ih1++;
      
      
       double COG5=iCustom(NULL,PERIOD_M5,CustomIndicator,Periods,ApplyTo,CustomIndIndex,i5);
       double COG5S=0;
      
      
      double  COG15=iCustom(NULL,PERIOD_M15,CustomIndicator,Periods,ApplyTo,CustomIndIndex,i15);
      double  COG15S=0;
      
      
     double   COG30=iCustom(NULL,PERIOD_M30,CustomIndicator,Periods,ApplyTo,CustomIndIndex,i30);
     double  COG30S=0;
      
      
      double COGH1=iCustom(NULL,PERIOD_H1,CustomIndicator,Periods,ApplyTo,CustomIndIndex,ih1);
      double COGH1S=0;
      
      
      Buffer_M5[i] = COG5;  
      Buffer_M15[i] = COG15;  
      Buffer_M30[i]  = COG30; 
      Buffer_H1[i]  = COGH1;  
   }

   return(0);
  }
//+------------------------------------------------------------------+

/*
bool NewBar()
{
   static datetime dt = 0;
   if (dt != iTime(NULL, PERIOD_M15, 0))
   {
      dt = iTime(NULL, PERIOD_M15, 0);
   }
   return(false);
}
*/



Sample





Analysis



Market Information Used:



Indicator Curves created:

Implements a curve of type DRAW_LINE


Indicators Used:




Custom Indicators Used:
CustomIndicator

Order Management characteristics:

Other Features: