诚信为本
量力而为
当前位置:峰汇在线 > MetaTrader 4 > MT4指标 > 正文

变色LSMA均线 FX Sniper’s LSMA.mq4

FX Sniper’s LSMA 指标创建变色均线。

图表:FX Sniper's LSMA 指标

源码:

//+------------------------------------------------------------------+
//|                                              FX Sniper's LSMA.mq4|
//|                        Copyright 2004, MetaQuotes Software Corp. |
//+------------------------------------------------------------------+
#property  copyright "Copyright 2005, FX Sniper "
#property  link      "http://www.125808047.com/"

#property  indicator_chart_window
#property  indicator_buffers 2
#property indicator_color1 Red      
#property indicator_color2 Lime

double ExtMapBuffer1[];
double ExtMapBuffer2[];
extern int Rperiod = 14;
extern int Draw4HowLongg = 1500;
extern int Type = 3; 
int Draw4HowLong,shift,i,loopbegin,width,length,c;
double sum[];
double lengthvar;
double tmp ;
double wt[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
{ 
   IndicatorBuffers(4);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexBuffer(2,sum);
   SetIndexBuffer(3,wt);
   
   SetIndexStyle(0,DRAW_LINE,0,2);
   SetIndexStyle(1,DRAW_LINE,0,2);
   Comment("www.125808047.com");
   return(INIT_SUCCEEDED);
}

int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
    Draw4HowLong = Bars-Rperiod - 5;
      length = Rperiod;
      loopbegin = Draw4HowLong - length - 1;
 
      for(shift = loopbegin; shift >= 0; shift--)
      { 
         sum[1] = 0;
         for(i = length; i >= 1  ; i--)
         {
         lengthvar = length + 1;
         lengthvar /= 3;
         tmp = 0;
         if(Type==1)
         tmp = ( i - lengthvar)*High[length-i+shift];
         if (Type==2)
         tmp = ( i - lengthvar)*Low[length-i+shift];
         if(Type==3)
         tmp = ( i - lengthvar)*Close[length-i+shift];
         
         sum[1]+=tmp;
         }
         wt[shift] = sum[1]*6/(length*(length+1));
         
//========== COLOR CODING ===========================================               
        
       ExtMapBuffer1[shift] = wt[shift]; 
       ExtMapBuffer2[shift] = wt[shift]; 
       
        if (wt[shift] > wt[shift+1])
        {
        ExtMapBuffer1[shift] = EMPTY_VALUE;
        ExtMapBuffer2[shift+1] = wt[shift+1];
        
        }
       else if (wt[shift] < wt[shift+1]) 
        {
        ExtMapBuffer2[shift] = EMPTY_VALUE; 
        ExtMapBuffer1[shift+1] = wt[shift+1];
        }
      }
      return(rates_total);
  }
//+------------------------------------------------------------------+
打赏
版权所有转载请注明标题及链接:峰汇在线 » 变色LSMA均线 FX Sniper’s LSMA.mq4
上一篇:
下一篇:
分享到: 更多 (0)

如您觉得此文不错请扫码打赏!

支付宝扫一扫打赏

微信扫一扫打赏