Navigation:Home > Content >

Lsma2.mq4

Time: 2013-03-14 | Download file:Lsma2.mq4

//+------------------------------------------------------------------+
//|                                                       LSMA       |
//|                      Copyright © 2004, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property  copyright "Copyright © 2005, FX Sniper "
#property  link      "http://www.metaquotes.net/"

//---- indicator settings
#property  indicator_chart_window
#property  indicator_buffers 1
#property indicator_color1 Yellow
#property indicator_width1 2      

//---- buffers
double ExtMapBuffer1[];

extern int Rperiod = 14;
int shift;
int i;
int loopbegin;
double sum1;
int length;
double lengthvar;
double tmp ;
double wt;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
  
   IndicatorBuffers(1);
   
//---- drawing settings
   SetIndexBuffer(0,ExtMapBuffer1);
   
   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID);

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

int start()

  {
   int    limit;
   int    counted_bars=IndicatorCounted();
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
  
      length = Rperiod;
 
      for(shift = limit; shift >= 0; shift--)
      { 
         sum1 = 0;
         for(i = length; i >= 1  ; i--)
         {
         lengthvar = length + 1;
         lengthvar /= 3;
         tmp = 0;
         tmp = ( i - lengthvar)*Close[length-i+shift];
         sum1+=tmp;
         }
         wt = sum1*6/(length*(length+1));
         
//========== COLOR CODING ===========================================               
        
       ExtMapBuffer1[shift] = wt;
       
      }
    
      return(0);
  }
//+------------------------------------------------------------------+


Recommend