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

CyAn_4_Cyber Cycle.mq4

CyAn_4_Cyber Cycle指标根据特定价格算法在副图创建均线。用法可以参考均线和KD。

图表:CyAn_4_Cyber Cycle指标

源码:

//+------------------------------------------------------------------+
//|                                            CyAn_4_Cyber Cycle.mq4|
//|                          Copyright @2006, Luis Guilherme Damiani |
//+------------------------------------------------------------------+
#property copyright "Copyright @2006, Luis Guilherme Damiani"
#property link      "http://www.125808047.com/"

#property indicator_buffers 3
#property indicator_separate_window

#property indicator_color1 Red
#property indicator_color2 LightBlue
#property indicator_color3 Yellow

extern double       alpha=0.07;
extern double lag_signal2=9;
extern string 
Price_Choice="-----  Typical or Median  --------------";
extern bool is_median=true;

double ind1[];
double ind2[];
double ind3[];
double AuxBuffer[];
double alpha2;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit(void)
{
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,ind1);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,ind2);
   SetIndexStyle(2,DRAW_LINE);
   SetIndexBuffer(2,ind3);
   SetLevelValue(0,0.0);

   ArrayInitialize(ind1,0.0);
   ArrayInitialize(ind2,0.0);
   ArrayInitialize(ind3,0.0);
   ArrayResize(AuxBuffer,Bars);
   ArrayInitialize(AuxBuffer,0.0);
   alpha2=1/(lag_signal2+1);  
   Comment("www.125808047.com");
   return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
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[])
  {
      double pr0,pr1,pr2,pr3=0;
      
      int    counted_bars=IndicatorCounted();
      if(counted_bars<0) return(-1);
      int limit=Bars-counted_bars;

      for (int i = limit; i>=0;i--)
      {
         if(is_median)
         {
            pr0=(High[i]+Low[i])/2;
            pr1=(High[i+1]+Low[i+1])/2;
            pr2=(High[i+2]+Low[i+2])/2;
            pr3=(High[i+3]+Low[i+3])/2;            
         }
         else
         {
            pr0=(High[i]+Low[i]+Close[i])/3;
            pr1=(High[i+1]+Low[i+1]+Close[i+1])/3;
            pr2=(High[i+2]+Low[i+2]+Close[i+2])/3;      
            pr3=(High[i+3]+Low[i+3]+Close[i+3])/3;      
         }
	      
	      AuxBuffer[i]= (pr0+2*pr1+2*pr2+pr3)/6;
	      
	      ind1[i]=MathPow(1-0.5*alpha,2)*(AuxBuffer[i]-2*AuxBuffer[i+1]+AuxBuffer[i+2])
	              +2*(1-alpha)*ind1[i+1]
	              -MathPow(1-alpha,2)*ind1[i+2];
	      
	      ind2[i]=ind1[i+1];
	      ind3[i]=alpha2*ind1[i]+(1-alpha2)*ind3[i+1];
       }
   return(rates_total);
  }
打赏
版权所有转载请注明标题及链接:峰汇在线 » CyAn_4_Cyber Cycle.mq4
上一篇:
下一篇:
分享到: 更多 (0)

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

支付宝扫一扫打赏

微信扫一扫打赏