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

随机振动指标 CyAn_5_CG Oscillator.mq4

CyAn_5_CG Oscillator指标用法类似于KD。

图表:CyAn_5_CG Oscillator指标

源码:

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

#property indicator_buffers 2
#property indicator_separate_window
#property indicator_color1 Yellow
#property indicator_color2 Blue

extern double length=8;
extern string 
Price_Choice="-----  Typical or Median  --------------";
extern bool is_median=true;

//---- buffers
double ind1[];
double ind2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit(void)
{
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,ind1);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,ind2);

   SetLevelValue(0,0.0);
   ArrayInitialize(ind1,0.0);
   ArrayInitialize(ind2,0.0);
   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[])
 {
      int    counted_bars=IndicatorCounted();
      double num=0,denom=0;  
      if(counted_bars<0) return(-1);
      int limit=Bars-counted_bars;
      for (int i = limit; i>=0;i--)
      {
         num=0;denom=0;
         for(int j=0;j<length;j++)
         {            
            num=num+(1+j)*Calc_pr(i+j,is_median);
            denom=denom+Calc_pr(i+j,is_median);
         }
         if(denom!=0)         	      
	      ind1[i]=-num/denom + (1+length)/2;
         ind2[i]=ind1[i+1];	          
       }
   return(rates_total);
  }
  
 double Calc_pr(int x,bool pricet)
 {
    double pr;
    if(pricet)
            {
               pr=(High[x]+Low[x])/2;
            
            }
            else
            {
               pr=(High[x]+Low[x]+Close[x])/3;
            } 
  return(pr);          
 }
打赏
版权所有转载请注明标题及链接:峰汇在线 » 随机振动指标 CyAn_5_CG Oscillator.mq4
上一篇:
下一篇:
分享到: 更多 (0)

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

支付宝扫一扫打赏

微信扫一扫打赏