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

CCI与布林带的完美结合 FX Sniper’s Ergodic_CCI_BB.mq4

FX Sniper’s Ergodic_CCI_BB 指标将CCI与布林带结合在副图。

图表:FX Sniper's Ergodic_CCI_BB 指标

源码:

//+------------------------------------------------------------------+
//|                                   FX Sniper's Ergodic_CCI_BB.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 6
#property  indicator_color1  Blue
#property  indicator_color2  White
#property  indicator_color3  White
#property  indicator_color4  Yellow
#property  indicator_color5  Lime
#property  indicator_color6  Red

extern int CCI_period=14;
extern int Bollinger_period=50;
extern int Bollinger_deviation = 2;
extern int Bollinger_shift = 0;

double MainCCI[];
double BUpper[];
double BLower[];
double BMain[];
double cciHup[];
double cciHdn[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
{ 
   IndicatorBuffers(8);
   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2);
   SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,1);
   SetIndexStyle(2,DRAW_LINE,STYLE_SOLID,1);
   SetIndexStyle(3,DRAW_LINE,STYLE_DOT,1);
   SetIndexStyle(4,DRAW_HISTOGRAM,0,1);
   SetIndexStyle(5,DRAW_HISTOGRAM,0,1);  
   
   SetIndexBuffer(0,MainCCI);
   SetIndexLabel(0,"CCI Indicator");
   SetIndexBuffer(1,BUpper);
   SetIndexBuffer(2,BLower);
   SetIndexBuffer(3,BMain);
   SetIndexLabel(3,"Bollinger Median Line");
   SetIndexBuffer(4,cciHup);
   SetIndexBuffer(5,cciHdn);

   IndicatorShortName("FX Sniper CCI with Bollinger Bands ");
   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<Bars; i++)
   {
     MainCCI[i]= iCCI(NULL,0,CCI_period,PRICE_TYPICAL,i);
    }
   for(i=0; i<Bars; i++)
   {  
     BLower[i] = iBandsOnArray(MainCCI,0,Bollinger_period,Bollinger_deviation,Bollinger_shift,MODE_LOWER,i); 
     BUpper[i] = iBandsOnArray(MainCCI,0,Bollinger_period,Bollinger_deviation,Bollinger_shift,MODE_UPPER,i); 
     BMain[i] = iBandsOnArray(MainCCI,0,Bollinger_period,Bollinger_deviation,Bollinger_shift,MODE_MAIN,i); 
   }
   
     for(i=0; i<Bars; i++)
   {
     if (MainCCI[i] >= 0 )
      cciHup[i] = MainCCI[i];
     else
      cciHup[i] = 0;
      
    }
    for(i=0; i<Bars; i++)
   {
      
     if (MainCCI[i] < 0 )
      cciHdn[i] = MainCCI[i];
     else
      cciHdn[i]=0; 
   }
   return(rates_total);
  }
//+------------------------------------------------------------------+
打赏
版权所有转载请注明标题及链接:峰汇在线 » CCI与布林带的完美结合 FX Sniper’s Ergodic_CCI_BB.mq4
上一篇:
下一篇:
分享到: 更多 (0)

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

支付宝扫一扫打赏

微信扫一扫打赏