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

以KD样式显示CCI FX Sniper’s Ergodic_CCI.mq4

FX Sniper’s Ergodic_CCI 指标已KD指标线的样式显示另类CCI。

图表:FX Sniper's Ergodic_CCI 指标

源码:

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

#property  indicator_separate_window
#property  indicator_buffers 3
#property  indicator_color1  White
#property  indicator_color2  Red
#property  indicator_color3  Yellow

extern int pq =2;
extern int pr = 14;
extern int ps = 5;
extern int CCI_period = 14;

double mtm[];
double absmtm[];
double ErgoCCI[];
double MainCCI[];
double var1[];
double var2[];
double var2a[];
double var2b[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
{ 
   IndicatorBuffers(8);
   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2,White);
   SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,1,Yellow);
   
   SetIndexBuffer(0,ErgoCCI);
   SetIndexBuffer(1,MainCCI);
   SetIndexBuffer(2,mtm);
   SetIndexBuffer(3,var1);
   SetIndexBuffer(4,var2);
   SetIndexBuffer(5,absmtm);
   SetIndexBuffer(6,var2a);
   SetIndexBuffer(7,var2b);
  IndicatorShortName("FX Sniper Ergo/CCI ");
   Comment("www.125808047.com");
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Calculations                                    |
//+------------------------------------------------------------------+
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 limit;
   int i;
   int counted_bars=IndicatorCounted();

   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;

   for(i=0; i<limit; i++)
   {
     MainCCI[i]=iCCI(NULL,0,CCI_period,PRICE_TYPICAL,i);
   }
   for(i=0; i <= Bars; i++) 
   {
   mtm[i]= Close[i]- Close[i +1];
   }
   for(i=0; i <= Bars-1; i++) 
   { 
    absmtm[i] =  MathAbs(mtm[i]);
   }
   for(i=0; i <= Bars-1; i++) 
   {   
    var1[i]= iMAOnArray(mtm,0,pq,0,MODE_EMA,i);
   }
   for(i=0; i <= Bars-1; i++) 
   {
   var2[i]= iMAOnArray(var1,Bars,pr,0,MODE_EMA,i);
   }
   for(i=0; i <= Bars-1; i++) 
   {
   var2a[i]= iMAOnArray(absmtm,0,pq,0,MODE_EMA,i);
   }
   for(i=0; i <= Bars-1; i++) 
   {
   var2b[i]= iMAOnArray(var2a,0,pr,0,MODE_EMA,i);
   }
   
    for(i=0; i <= Bars-1; i++) 
   {   
   ErgoCCI[i] = (450 * iMAOnArray(var2,0,ps,0,MODE_EMA,i))/(iMAOnArray(var2b,0,ps,0,MODE_EMA,i)); //var2a[i]/var2b[i];  
   }
   return(rates_total);
  }
//+------------------------------------------------------------------+
打赏
版权所有转载请注明标题及链接:峰汇在线 » 以KD样式显示CCI FX Sniper’s Ergodic_CCI.mq4
上一篇:
下一篇:
分享到: 更多 (0)

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

支付宝扫一扫打赏

微信扫一扫打赏