自定义 "Z "字形 - 页 2

 
zig=icustom(NULL,0,'ZigZag',ExtDepth,ExtDeviation,ExtBackstop,2,i) 。
 
我对iCustom ZigZag也有一个问题......它不给我新的数据......仍然停留在旧的数据上。

我在 "开始 "中调用了这个函数。

double FindClosestZZ()
  {
  int i;
  double zzh;
  for (i=0;i<1000;i++)
    {
    zzh=iCustom(Symbol(),Period(),"ZigZag",12,5,3, 0, i); 
    if (zzh!=0)
      return(zzh);
    }
  return(0);
  }
 
Rosh,这发生在现场,不是测试...无论我怎么做,这个值仍然被卡住。
我甚至修改了.从以前的MT4版本中提取了指标,并将其变成了BetterZigZag(屏幕上的ZigZag有点不同,但这不是因为我)。
更好的之字形返回相同的值,无论图表上发生什么,都会进一步。
它包括4个额外的缓冲区,2个临时的(不是必须的)和2个可用的,它们代表时间上的实际位置(ExtExtraBufferX,缓冲区3;ExtExtraBufferY,缓冲区4)。
当我看到无论指标在屏幕上的进展如何,最后的值仍然是一样的,我迫使事情更进一步,我把指标写在2个全局变量中的最后的Zig/Zag位置(EA明确要求指标在屏幕上)。这也不起作用。我在这里附上代码。

//+------------------------------------------------------------------+
//|                                                 BetterZigZag.mq4 |
//+------------------------------------------------------------------+
 
 
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Red
//---- indicator parameters
extern int ExtDepth=12;
extern int ExtDeviation=5;
extern int ExtBackstep=3;
//---- indicator buffers
double ExtMapBuffer[];
double ExtLowBuffer[];
double ExtHighBuffer[];
double ExtExtraBufferX[];
double ExtExtraBufferY[];
double ExtTempBufferX[];
double ExtTempBufferY[];
 
int extrapos=0;
 
int Round(double i)
    {
    string s;
    int res;
    s=DoubleToStr(i,0);
    res=StrToInteger(s);
    return(res);
    }
    
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {   
   IndicatorBuffers(7);   
//---- drawing settings
   SetIndexStyle(0,DRAW_SECTION);
//---- indicator buffers mapping
   SetIndexBuffer(0,ExtMapBuffer);
   SetIndexBuffer(1,ExtLowBuffer);
   SetIndexBuffer(2,ExtHighBuffer);
   SetIndexBuffer(3,ExtExtraBufferX);
   SetIndexBuffer(4,ExtExtraBufferY);
   SetIndexBuffer(5,ExtTempBufferX);
   SetIndexBuffer(6,ExtTempBufferY);   
   SetIndexEmptyValue(0,0.0);
//---- indicator short name
   IndicatorShortName("BetterZigZag("+ExtDepth+","+ExtDeviation+","+ExtBackstep+")");
//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
  {
   int    shift, back,lasthighpos,lastlowpos,index;
   double val,res;
   double curlow,curhigh,lasthigh,lastlow;
//----
   for(shift=Bars-ExtDepth; shift>=0; shift--)
     {
      index=Lowest(NULL,0,MODE_LOW,ExtDepth,shift);
      val=Low[index];
      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=ExtLowBuffer[shift+back];
               if((res!=0)&&(res>val)) ExtLowBuffer[shift+back]=0.0; 
              }
           }
        } 
      ExtLowBuffer[shift]=0.0;
      if(val!=0.0) ExtLowBuffer[index]=val;
      //--- high
      index=Highest(NULL,0,MODE_HIGH,ExtDepth,shift);
      val=High[index];
      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=ExtHighBuffer[shift+back];
               if((res!=0)&&(res<val)) ExtHighBuffer[shift+back]=0.0; 
              } 
           }
        }
      ExtHighBuffer[shift]=0.0;
      if(val!=0.0) ExtHighBuffer[index]=val;
     }
//---- final cutting 
   lasthigh=-1; lasthighpos=-1;
   lastlow=-1;  lastlowpos=-1;
 
   for(shift=Bars-ExtDepth; shift>=0; shift--)
     {
      curlow=ExtLowBuffer[shift];
      curhigh=ExtHighBuffer[shift];
      if(curlow==0 && curhigh==0) continue;
      //---
      if(curhigh!=0)
        {
         if(lasthigh>0) 
           {
            if(lasthigh<curhigh) ExtHighBuffer[lasthighpos]=0;
            else ExtHighBuffer[shift]=0;
           }
         //---
         if(lasthigh<curhigh || lasthigh<0)
           {
            lasthigh=curhigh;
            lasthighpos=shift;
           }
         lastlow=-1;
        }
      //----
      if(curlow!=0)
        {
         if(lastlow>0)
           {
            if(lastlow>curlow) ExtLowBuffer[lastlowpos]=0;
            else ExtLowBuffer[shift]=0;
           }
         //---
         if((curlow<lastlow)||(lastlow<0))
           {
            lastlow=curlow;
            lastlowpos=shift;
           } 
         lasthigh=-1;
        }
     }
//---- merge 2 buffers
   lasthighpos=-1;
   lastlowpos=-1;
   for(shift=Bars-1; shift>=0; shift--)
     {
      if(shift>=Bars-ExtDepth) 
        {
         ExtMapBuffer[shift]=0.0;
         ExtTempBufferX[shift]=0.0;
         ExtTempBufferY[shift]=0.0;         
         ExtExtraBufferX[shift]=0.0;
         ExtExtraBufferY[shift]=0.0;
        }
      else
        {
         curlow=ExtLowBuffer[shift];
         curhigh=ExtHighBuffer[shift];
         //----
         res=0;
         if(curlow!=0)
           {
            if(lastlowpos==-1)
              {
               res=curlow;
               lastlowpos=shift;
              }
            else
              {
               if(lasthighpos!=-1 && lastlowpos>lasthighpos)
                 {
                  res=curlow;
                  lastlowpos=shift;
                 }
              }
           }
         if(curhigh!=0)
           {
            if(lasthighpos==-1)
              {
               res=curhigh;
               lasthighpos=shift;
              }
            else
              {
               if(lastlowpos!=-1 && lasthighpos>lastlowpos)
                 {
                  res=curhigh;
                  lasthighpos=shift;
                 }
              }
           }
         //----
         ExtMapBuffer[shift]=res;
         if (res!=0&&shift<10000000)
           {            
            ExtTempBufferX[extrapos]=shift;
            ExtTempBufferY[extrapos]=res;
            extrapos=extrapos+1;
           }
        }
     }
     
  //arranging extras
  if (ExtTempBufferX[extrapos]>10000000)
    {
     extrapos=extrapos-1;
    }    
  if (extrapos>=0&&extrapos!=1)
    {    
    int maxpos=extrapos;   
    int final;
    bool addmid=false;
    double swap=0; 
    if (extrapos/2==Round(extrapos/2))
      {
      final=Round(extrapos/2)-1;
      addmid=True;
      }
    else
      {
       final=Round(extrapos/2);
       addmid=false;
      }
    for (int xscan=0;xscan<=final;xscan++)
       {
        swap=ExtTempBufferY[xscan];
        ExtExtraBufferY[xscan]=ExtTempBufferY[maxpos];
        ExtExtraBufferY[maxpos]=swap;
        swap=ExtTempBufferX[xscan];
        ExtExtraBufferX[xscan]=ExtTempBufferX[maxpos];
        ExtExtraBufferX[maxpos]=swap;        
        maxpos=maxpos-1;
       }
    if (addmid==true)
      {
       ExtExtraBufferX[final+1]=ExtTempBufferX[final+1];
       ExtExtraBufferY[final+1]=ExtTempBufferY[final+1];
      }
    GlobalVariableSet("ClosestZigZagX",ExtExtraBufferX[0]);
    GlobalVariableSet("ClosestZigZagY",ExtExtraBufferY[0]);
    maxpos=extrapos;    
    }//if (extrapos!=0&&extrapos!=1)
  }
//+------------------------------------------------------------------+


我在.上看到类似的问题,返回的值与屏幕上的不一样,但是它被改变了。

我是这样调用抛物线SAR 的。

PSar=iCustom(NULL,0, "Parabolic",0.02,0.2,0,0)。

我得到的结果是这样的。
 
c0d3:
我试图用icustom命令来确定人字形指标的方向。

这是我目前的情况。

ZigZagHigh=iCustom(NULL,0, "ZigZag",MODE_HIGH,0)。
ZigZagLow=iCustom(NULL,0, "ZigZag",MODE_LOW,0)。

线条画在了图表上,但是当我运行程序时,ZigZagHigh和ZigZagLow都等于零。




我如何用icustom函数确定ZigZag指标的趋势?


谢谢
 
你好

你们能不能把三个缓冲区的人字形贴出来。

谢谢
盖恩斯博士
 
dr_gaines:
c0d3:
我正试图用icustom命令确定人字形指标的方向。



这是我目前的情况。



ZigZagHigh=iCustom(NULL,0, "ZigZag",MODE_HIGH,0)。

ZigZagLow=iCustom(NULL,0, "ZigZag",MODE_LOW,0)。



线条画在了图表上,但是当我运行程序时,ZigZagHigh和ZigZagLow都等于零。









我如何用icustom函数确定ZigZag指标的趋势?





谢谢



你不能确定趋势。最后一个点的位置是可变的,直到另一个点被添加。
 
dr_gaines:


能你们请张贴 3缓冲区之字形。

感谢
盖恩斯博士
附加的文件:
zigzag_1.mq4  7 kb
 
TheEconomist:
Rosh, 这发生了在上生动, 不测试...我做无论什么,那价值留下粘住...
我甚至更改了之字形。 从MT4的一个先前的版本拿了指示物并且使它成为了一BetterZigZag(在屏幕上的之字形是一点的不同,但是那不因为我)。
好一些的转弯急变归还了一样的价值,不管在图表上什么进一步发生了。
它包括4个额外的缓冲区,2暂时(不需要) 并且2合用,它准时代表实际的地点(ExtExtraBufferX, 缓冲区3; ExtExtraBufferY, 缓冲区4)。
当我看了时最后价值仍然是一样的不管指示物在屏幕上正在进行, 我甚至远强迫了事情并且我把指示物放在2全球的变数写最后转弯/急变地点(Ea是明析地要求指示物在屏幕上)。 也这没工作。 我这里依附代码。

//+------------------------------------------------------------------+
//|                                                 BetterZigZag.mq4|
//+------------------------------------------------------------------+
 
 


在比喻的SAR上我看相似的问题。 归还的价值不是在屏幕上喜欢一个, 它然而得到改变:

我叫了比喻的SAR象一样这:

PSar=iCustom(0,0,“比喻”,0.02,0.2,0,0);

我得到的是这:





时间>=M30

 

时间>M30

zigzag=betterzigzag

原因: