[MT4指标]cci主图变色指标
主图指标 cci主图变色指标
mt4指标类型:趋势指标
是否能用在mt4手机版上:否
是否含有未来函数:无
//+------------------------------------------------------------------+
//|                                            CCI CustomCandles.mq4 |
//|                                                  modified by cja |
//+------------------------------------------------------------------+
#property copyright \"Copyright ? 2007, Christof Risch (iya)\"
#property link      \"http://www.forexfactory.com/showthread.php?t=13321\"
#property indicator_chart_window
//----
#property indicator_buffers 4
#property indicator_color1 Green //wick
#property indicator_color2 Red   //wick
#property indicator_color3 Green //candle
#property indicator_color4 Red   //candle
#property indicator_width1 1
#property indicator_width2 1
#property indicator_width3 3
#property indicator_width4 3
//---- stoch settings
extern int   CCI_Period     =14;
extern int   CCI_Price      =0;
extern int   Overbought     =100;
extern int   Oversold       =-100;
//---- input parameters
extern int   BarWidth        =1,
             CandleWidth     =3;
//---- buffers
double Bar1,
       Bar2,
       Candle1,
       Candle2;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   IndicatorShortName(\"CCI Candles:(\"+   CCI_Period+\")\");
   IndicatorBuffers(4);
   SetIndexBuffer(0,Bar1);
   SetIndexBuffer(1,Bar2);
   SetIndexBuffer(2,Candle1);
   SetIndexBuffer(3,Candle2);
   SetIndexStyle(0,DRAW_HISTOGRAM,0,BarWidth);
   SetIndexStyle(1,DRAW_HISTOGRAM,0,BarWidth);
   SetIndexStyle(2,DRAW_HISTOGRAM,0,CandleWidth);
   SetIndexStyle(3,DRAW_HISTOGRAM,0,CandleWidth);
//----
   return(0);
  }
//+------------------------------------------------------------------+
double CCI     (int i=0)   {return(iCCI(NULL,0,CCI_Period,CCI_Price,i));}
//+------------------------------------------------------------------+
void SetCandleColor(int col, int i)
  {
   double high,low,bodyHigh,bodyLow;
     {
      bodyHigh=MathMax(Open,Close);
      bodyLow =MathMin(Open,Close);
      high     =High;
      low     =Low;
     }
   Bar1=low;   Candle1=bodyLow;
   Bar2=low;   Candle2=bodyLow;
   switch(col)
     {
      case 1:    Bar1=high;   Candle1=bodyHigh;   break;
      case 2:    Bar2=high;   Candle2=bodyHigh;   break;
     }
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   for(int i=MathMax(Bars-1-IndicatorCounted(),1); i>=0; i--)
     {
      double   cci  =CCI(i);
      if(cci > Overbought)      SetCandleColor(1,i);
      else   if(cci < Oversold)      SetCandleColor(2,i);
     }
//----
   return(0);
  }
//+------------------------------------------------------------------+
发表于:2016-09-20 20:47只看该作者
2楼 
谢谢分享
韬客社区www.talkfx.co
发表于:2016-10-02 12:05只看该作者
3楼 
无图
韬客社区www.talkfx.co
发表于:2017-08-08 08:58只看该作者
4楼 
通宝通宝
韬客社区www.talkfx.co

















