EMAdensity





//+------------------------------------------------------------------+
//|                                                   EMAdensity.mq4 |
//|                                                             niva |
//|                                                        forex-tsd |
//+------------------------------------------------------------------+
#property copyright "niva"
#property link      "forex-tsd"

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Red
double ExtMapBuffer1 [];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,ExtMapBuffer1);
   string short_name = "EMA lines desity!";
   IndicatorShortName(short_name);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
   double ema1, ema2, ema3, ema4, ema5;
   double mean, variance, result;
   if (counted_bars < 0) return(-1);
   if (counted_bars >0) counted_bars --;
   int pos=Bars-counted_bars;
//----
   while(pos>=0)
   {
      ema1=iMA(NULL,0,10,0,MODE_EMA,PRICE_CLOSE,pos);
      ema2=iMA(NULL,0,20,0,MODE_EMA,PRICE_CLOSE,pos);
      ema3=iMA(NULL,0,30,0,MODE_EMA,PRICE_CLOSE,pos);
      ema4=iMA(NULL,0,40,0,MODE_EMA,PRICE_CLOSE,pos);
      ema5=iMA(NULL,0,50,0,MODE_EMA,PRICE_CLOSE,pos);
      mean = (ema1 +ema2+ema3+ema4+ema5)/5;
      variance = (square(ema1-mean)+square(ema2-mean)+square(ema3-mean)+square(ema4-mean)+square(ema5-mean))/5;
      result = 100*variance;
      
      ExtMapBuffer1[pos]=result;
      pos--;
    }
   
//----
   return(0);
  }
  
  double square(double number){
   double result;
   result=number*number;
  
   return(result);
  
  }
//+------------------------------------------------------------------+



Sample



image not available


Analysis



Market Information Used:



Indicator Curves created:

Implements a curve of type DRAW_LINE


Indicators Used:

Moving average indicator


Custom Indicators Used:

Order Management characteristics:

Other Features: