诚信为本
量力而为
当前位置:首页MetaTrader 4MT4指标副图均线信号指标 CAO.mq4

副图均线信号指标 CAO.mq4

CAO指标根据均线信号在副图绘制柱状线。

图表:

CAO指标

源码:

//+------------------------------------------------------------------+
//|                                                          CAO.mq4 |
//|                       Copyright @2005, MetaQuotes Software Corp. |
//+------------------------------------------------------------------+
#property  copyright "Copyright @2005, MetaQuotes Software Corp."
#property  link      "http://www.125808047.com/"

#property  indicator_separate_window
#property  indicator_buffers 3
#property  indicator_color1  Black
#property  indicator_color2  Green
#property  indicator_color3  Red
#property  indicator_level1  0

double     ExtBuffer0[];
double     ExtBuffer1[];
double     ExtBuffer2[];

extern int ShortMA=32;
extern int LongMA=208;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit(void)
{
   SetIndexStyle(0,DRAW_NONE);
   SetIndexStyle(1,DRAW_HISTOGRAM,EMPTY,1);
   SetIndexStyle(2,DRAW_HISTOGRAM,EMPTY,1);
   IndicatorDigits(Digits+1);
   SetIndexDrawBegin(0,32);
   SetIndexDrawBegin(1,32);
   SetIndexDrawBegin(2,32);

   SetIndexBuffer(0,ExtBuffer0);
   SetIndexBuffer(1,ExtBuffer1);
   SetIndexBuffer(2,ExtBuffer2);

   IndicatorShortName("CAO("+ShortMA+","+LongMA+")");
   SetIndexLabel(1,NULL);
   SetIndexLabel(2,NULL);
   Comment("www.125808047.com");
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Awesome Oscillator                                               |
//+------------------------------------------------------------------+
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    counted_bars=IndicatorCounted();
   double prev,current;

   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;

   for(int i=0; i<limit; i++)
      ExtBuffer0[i]=iMA(NULL,0,ShortMA,0,MODE_SMA,PRICE_CLOSE,i)-iMA(NULL,0,LongMA,0,MODE_SMA,PRICE_CLOSE,i);

   bool up=true;
   for(i=limit-1; i>=0; i--)
     {
      current=ExtBuffer0[i];
      prev=ExtBuffer0[i+1];
      if(current>prev) up=true;
      if(current<prev) up=false;
      if(!up)
        {
         ExtBuffer2[i]=current;
         ExtBuffer1[i]=0.0;
        }
      else
        {
         ExtBuffer1[i]=current;
         ExtBuffer2[i]=0.0;
        }
     }
   return(rates_total);
  }
版权所有转载请注明标题及链接:峰汇在线 » 副图均线信号指标 CAO.mq4
上一篇:
下一篇:
分享到: 更多 (0)