JMA_Angle





/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

//+------------------------------------------------------------------+
//|                                                    JMA_Angle.mq4 |
//|                      Copyright © 2004, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property  copyright "Copyright © 2004, MetaQuotes Software Corp."
#property  link      "http://www.metaquotes.net/"
//---- indicator settings
#property  indicator_separate_window
#property  indicator_buffers 3
#property  indicator_color1  LimeGreen
#property  indicator_color2  Yellow
#property  indicator_color3 FireBrick
#property indicator_width1 2
#property indicator_width2 2
#property indicator_width3 2

//---- indicator parameters
extern int JMA_Period=34;

extern double AngleTreshold=15;
extern int StartMAShift=4;
extern int EndMAShift=0;

//---- indicator buffers
double UpBuffer[];
double DownBuffer[];
double ZeroBuffer[];

   double mFactor;
   int ShiftDif;
   string Sym;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicator buffers mapping

   IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+1);

//---- 3 indicator buffers mapping
   if(!SetIndexBuffer(0,UpBuffer) &&
      !SetIndexBuffer(1,DownBuffer) &&
      !SetIndexBuffer(2,ZeroBuffer))
      Print("cannot set indicator buffers!");
//---- drawing settings
   SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID);
   SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID);
   SetIndexStyle(2,DRAW_HISTOGRAM,STYLE_SOLID);
   SetIndexDrawBegin(0,JMA_Period);
   IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+1);
//---- name for DataWindow and indicator subwindow label
   IndicatorShortName("JMA_Angle("+JMA_Period+","+AngleTreshold+","+StartMAShift+","+EndMAShift+")");
   SetIndexLabel(0,"JMA Angle");
   if(EndMAShift >= StartMAShift)
   {
      Print("Error: EndMAShift >= StartMAShift");
      StartMAShift = 6;
      EndMAShift = 0;      
   }  
   mFactor = 100000.0;
   Sym = StringSubstr(Symbol(),3,3);
   if (Sym == "JPY") mFactor = 1000.0;
   ShiftDif = StartMAShift-EndMAShift;
   mFactor /= ShiftDif;
//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//| Moving Averages Convergence/Divergence                           |
//+------------------------------------------------------------------+
int start()
  {
   double ma1, ma2;
   double fEndMA, fStartMA;
   double fAngle;
   int limit,i;
   double angle;
   int counted_bars=IndicatorCounted();
//---- check for possible errors
   if(counted_bars<0) 
      return(-1);
   if(counted_bars<1)
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
//---- main loop
   for(i=0; i<limit; i++)
   {
      fEndMA=iCustom(NULL, 0, "JMA",JMA_Period,0,i+EndMAShift);
      fStartMA=iCustom(NULL, 0, "JMA",JMA_Period,0,i+StartMAShift);
      // 10000.0 : Multiply by 10000 so that the fAngle is not too small
      // for the indicator Window.
      fAngle = mFactor * (fEndMA - fStartMA)/2.0;
//Print (mFactor, fEndMA, fStartMA, fAngle);
      DownBuffer[i] = 0.0;
      UpBuffer[i] = 0.0;
      ZeroBuffer[i] = 0.0;
      
      if(fAngle > AngleTreshold)
      {
         UpBuffer[i] = fAngle;
      }
      else if (fAngle < -AngleTreshold)
      {
         DownBuffer[i] = fAngle;
      }
      else ZeroBuffer[i] = fAngle;
   }

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

//+------------------------------------------------------------------+



Sample





Analysis



Market Information Used:



Indicator Curves created:


Implements a curve of type DRAW_HISTOGRAM

Indicators Used:




Custom Indicators Used:
JMA

Order Management characteristics:

Other Features: