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

CandlesticksCW.mq4

CandlesticksCW指标根据AO和AC在主图创建另类K线。和CandlesticksBW指标同一类型。

图表:CandlesticksCW指标

源码:

//+------------------------------------------------------------------+
//|                                               CandlesticksCW.mq4 |
//|                                                         Vladimir |
//+------------------------------------------------------------------+
#property copyright "Vladimir"
#property link      "http://www.125808047.com/"

#property indicator_chart_window
#property indicator_buffers 7
#property indicator_color1 LimeGreen
#property indicator_color2 Red
#property indicator_color3 LimeGreen 
#property indicator_color4 Red
#property indicator_color5 White

double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
double ExtMapBuffer5[];
double ExtMapBuffer6[];
double ExtM;//----
int ExtCountedBars=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit(void)
{
   SetIndexStyle(0,DRAW_HISTOGRAM,0,1,LimeGreen);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexStyle(1,DRAW_HISTOGRAM,0,1,Red);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexStyle(2,DRAW_HISTOGRAM,0,2,LimeGreen);
   SetIndexBuffer(2,ExtMapBuffer3);
   SetIndexStyle(3,DRAW_HISTOGRAM,0,2,Red);
   SetIndexBuffer(3,ExtMapBuffer4);
   SetIndexStyle(4,DRAW_HISTOGRAM,0,1,White);
   SetIndexBuffer(4,ExtMapBuffer5);
   SetIndexStyle(5,DRAW_HISTOGRAM,0,1,White);
   SetIndexBuffer(5,ExtMapBuffer6);
   SetIndexStyle(4,DRAW_NONE,0,1,LimeGreen);
   Comment("www.125808047.com");
  return(INIT_SUCCEEDED);
  }

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[])
  {
   if (Bars<=10) return(0);
   ExtCountedBars=IndicatorCounted();

   if (ExtCountedBars<0) return(-1);

   if (ExtCountedBars>0) ExtCountedBars--;
   int pos=Bars-ExtCountedBars-1;
   
   while (pos>=0)
     {
        	if (iAO(NULL,0,pos)>=iAO(NULL,0,pos+1) && iAC(NULL,0,pos)>=iAC(NULL,0,pos+1))
          {
           ExtMapBuffer1[pos]=High[pos];
           ExtMapBuffer2[pos]=Low[pos];
           if (Open[pos]>Close[pos]) 
             { ExtMapBuffer3[pos]=Open[pos]; ExtMapBuffer4[pos]=Close[pos]; }
         else 
           if (Open[pos]<Close[pos]) 
             { ExtMapBuffer3[pos]=Close[pos]; ExtMapBuffer4[pos]=Open[pos]; 
             ExtMapBuffer5[pos]=Open[pos]+ExtM;  ExtMapBuffer6[pos]=Close[pos]-ExtM;  }
           }
         if (iAO(NULL,0,pos)<=iAO(NULL,0,pos+1) && iAC(NULL,0,pos)<=iAC(NULL,0,pos+1))
	     	 {
           ExtMapBuffer1[pos]=Low[pos];
           ExtMapBuffer2[pos]=High[pos];
           if (Open[pos]<Close[pos]) 
             { ExtMapBuffer3[pos]=Open[pos]; ExtMapBuffer4[pos]=Close[pos];
               ExtMapBuffer5[pos]=Open[pos]+ExtM; ExtMapBuffer6[pos]=Close[pos]-ExtM;}
           else  
             if (Open[pos]>Close[pos]) 
               { ExtMapBuffer3[pos]=Close[pos]; ExtMapBuffer4[pos]=Open[pos]; }         
	  	       }
 	   pos--;
     }
   return(rates_total);
  }
打赏
版权所有转载请注明标题及链接:峰汇在线 » CandlesticksCW.mq4
上一篇:
下一篇:
分享到: 更多 (0)

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

支付宝扫一扫打赏

微信扫一扫打赏