Author:
Slope_Line
Indicators Used
Moving average indicatorMoving average indicator
Miscellaneous
Implements a curve of type %1
1 Views
0 Downloads
0 Favorites
Slope_Line
//+------------------------------------------------------------------+
//|                                                   Slope Line.mq4 |
//|                                                                  |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright ""
#property link      ""

#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Red
//---- input parameters
extern int SlopePeriod=80;
extern int SlopeMethod=3;
extern int SlopePrice=0;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   IndicatorBuffers(2);
//---- indicators
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexDrawBegin(0,SlopePeriod+MathFloor(MathSqrt(SlopePeriod)));
   SetIndexLabel(0,"Hull MA");
   SetIndexBuffer(1,ExtMapBuffer2);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int counted_bars=IndicatorCounted();
   int limit;
//----
   if(counted_bars<0) return(-1);
//----
   if(counted_bars<1) limit=Bars-1;
   else limit=Bars-counted_bars;
//----
   for(int i=0; i<=limit; i++)
      ExtMapBuffer2[i]=2*iMA(NULL,0,SlopePeriod/2,0,SlopeMethod,SlopePrice,i)-iMA(NULL,0,SlopePeriod,0,SlopeMethod,SlopePrice,i);
//----
   if(counted_bars<1)
      for(i=1;i<=SlopePeriod;i++) ExtMapBuffer2[Bars-i]=0.0;     
//----
   for(i=0; i<=limit; i++)
      ExtMapBuffer1[i]=iMAOnArray(ExtMapBuffer2,Bars,MathSqrt(SlopePeriod),0,SlopeMethod,i);   
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments