有您的持续关注
我们会做得更好

ZigZag_Pointer_alert指标以箭头指示行情波动可能发生变化的节点



ZigZag_Pointer_alert指标属于ZigZag指标优化的一种,在图表中以箭头指示行情波动可能发生变化的节点,不能直接成为开仓的条件,但是可以配合其它方法来研究分析市场波动的轨迹。

ZigZag_Pointer_alert指标图表效果如下:ZigZag_Pointer_alert指标

ZigZag_Pointer_alert指标源码如下:

//+------------------------------------------------------------------+
//|                                         ZigZag_Pointer_alert.mq4 |
//|                                       Copyright @2015, 125808047 |
//+------------------------------------------------------------------+
#property copyright "www.125808047.com"
#property link      "http://www.125808047.com"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_width1 3
#property indicator_color2 Blue
#property indicator_width2 3
//---- indicator parameters
extern int ExtDepth=23;//21;//105
extern int ExtDeviation=26;//24;//120
extern int ExtBackstep=16;//14;//70
//---- indicator buffers
double ExtMapBuffer[];
double ExtMapBuffer2[];
int OldLastZigZag, OldPreviousZigZag;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   IndicatorBuffers(2);
//---- drawing settings
   SetIndexStyle(0,DRAW_ARROW,0,3);
   SetIndexArrow(0, 233);
   SetIndexStyle(1,DRAW_ARROW,0,3);
   SetIndexArrow(1, 234);
//---- indicator buffers mapping
   SetIndexBuffer(0,ExtMapBuffer);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexEmptyValue(0,0.0);
   
//---- indicator short name
   IndicatorShortName("ZigZag("+ExtDepth+","+ExtDeviation+","+ExtBackstep+")");
//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
  {
   int    shift, back,lasthighpos,lastlowpos;
   double val,res;
   double curlow,curhigh,lasthigh,lastlow;

   for(shift=Bars-ExtDepth; shift>=0; shift--)
     {
      val=Low[Lowest(NULL,0,MODE_LOW,ExtDepth,shift)];
      if(val==lastlow) val=0.0;
      else 
        { 
         lastlow=val; 
         if((Low[shift]-val)>(ExtDeviation*Point)) val=0.0;
         else
           {
            for(back=1; back<=ExtBackstep; back++)
              {
               res=ExtMapBuffer[shift+back];
               if((res!=0)&&(res>val)) ExtMapBuffer[shift+back]=0.0; 
              }
           }
        } 
      ExtMapBuffer[shift]=val;
      //--- high
      val=High[Highest(NULL,0,MODE_HIGH,ExtDepth,shift)];
      if(val==lasthigh) val=0.0;
      else 
        {
         lasthigh=val;
         if((val-High[shift])>(ExtDeviation*Point)) val=0.0;
         else
           {
            for(back=1; back<=ExtBackstep; back++)
              {
               res=ExtMapBuffer2[shift+back];
               if((res!=0)&&(res<val)) ExtMapBuffer2[shift+back]=0.0; 
              } 
           }
        }
      ExtMapBuffer2[shift]=val;
     }

   // final cutting 
   lasthigh=-1; lasthighpos=-1;
   lastlow=-1;  lastlowpos=-1;

   for(shift=Bars-ExtDepth; shift>=0; shift--)
     {
      curlow=ExtMapBuffer[shift];
      curhigh=ExtMapBuffer2[shift];
      if((curlow==0)&&(curhigh==0)) continue;
      //---
      if(curhigh!=0)
        {
         if(lasthigh>0) 
           {
            if(lasthigh<curhigh) ExtMapBuffer2[lasthighpos]=0;
            else ExtMapBuffer2[shift]=0;
           }
         //---
         if(lasthigh<curhigh || lasthigh<0)
           {
            lasthigh=curhigh;
            lasthighpos=shift;
           }
         lastlow=-1;
        }
      //----
      if(curlow!=0)
        {
         if(lastlow>0)
           {
            if(lastlow>curlow) ExtMapBuffer[lastlowpos]=0;
            else ExtMapBuffer[shift]=0;
           }
         //---
         if((curlow<lastlow)||(lastlow<0))
           {
            lastlow=curlow;
            lastlowpos=shift;
           } 
         lasthigh=-1;
        }
     }
  
   for(shift=Bars-1; shift>=0; shift--)
     {
      if(shift>=Bars-ExtDepth) ExtMapBuffer[shift]=0.0;
      else
        {
         res=ExtMapBuffer2[shift];
         if(res!=0.0) ExtMapBuffer2[shift]=res;
        }
      int i=0;
      int LastZigZag, PreviousZigZag;
   
   int h=0;
   while ( ExtMapBuffer[h]==0 && ExtMapBuffer2[h]==0) {
       h++;
   }
   
   LastZigZag=h;
   
   h++;
   while(ExtMapBuffer[h]==0 && ExtMapBuffer2[h]==0) {
       h++;
   }
   
   PreviousZigZag=h;
   
   if (OldLastZigZag!=LastZigZag || OldPreviousZigZag!=PreviousZigZag) {
       if(OldLastZigZag>LastZigZag) Alert("ZZ Pointer Alert...Possible change in direction... (M",Period()," ",Symbol(),")");
        OldLastZigZag=LastZigZag;
       OldPreviousZigZag=PreviousZigZag;
       //ObjectDelete("Fibo");
       //ObjectCreate("Fibo", OBJ_FIBO, 0, Time[PreviousZigZag], ExtMapBuffer[LastZigZag], Time[LastZigZag], ExtMapBuffer[PreviousZigZag]);
  }
   if (OldLastZigZag!=LastZigZag || OldPreviousZigZag!=PreviousZigZag) {
       if(OldLastZigZag<LastZigZag) Alert("ZZ Pointer Alert...Possible change in direction... (M",Period()," ",Symbol(),")");
       OldLastZigZag=LastZigZag;
       OldPreviousZigZag=PreviousZigZag;
       //ObjectDelete("Fibo");
       //ObjectCreate("Fibo", OBJ_FIBO, 0, Time[PreviousZigZag], ExtMapBuffer[LastZigZag], Time[LastZigZag], ExtMapBuffer[PreviousZigZag]);
   }
     }
      return(0);    
  }
  
  //end//

如您喜欢此文章请点下面分享按钮↴峰汇在线 » ZigZag_Pointer_alert指标以箭头指示行情波动可能发生变化的节点
上一篇:
下一篇:
分享到:更多 ()