icustom ZigZag - page 2

To add comments, please log in or register
zsqabca
23
zsqabca  
zig=icustom(NULL,0,'ZigZag',ExtDepth,ExtDeviation,ExtBackstop,2,i);
Bogdan Caramalac
760
Bogdan Caramalac  
I have a problem too with iCustom ZigZag...it doesn't give me fresh data...remains stuck on old ones.

I have this function called from Start.

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);
  }
Rashid Umarov
Admin
15463
Rashid Umarov  
Bogdan Caramalac
760
Bogdan Caramalac  
Rosh, this happened on LIVE, not testing... Whatever I do, that value remains stuck. ..
I even modified the . Took the indicator from a previous version of MT4 and made it a BetterZigZag (the zigzag on screen is a bit different, but that's not because of me).
The Better Zig Zag returned the same value, no matter what happened on chart further.
It includes 4 extra buffers, 2 temporary (not necesary) and 2 usable, which represent the actual locations on time (ExtExtraBufferX, buffer 3 ; ExtExtraBufferY, buffer 4).
When I saw the last value is still the same no matter the indicator was progressing on screen, I forced the things even far and I put the indicator to write the last zig/zag location in 2 global variables (The EA was explicitly requiring the indicator to be on screen). This didn't work either. I attach the code here:

//+------------------------------------------------------------------+
//|                                                 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)
  }
//+------------------------------------------------------------------+


I see similar problems on the . The value returned is not like the one on the screen, however it gets changed:

I called Parabolic SAR like this:

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

What I get is this:
dr gaines
38
dr gaines  
c0d3:
I'm trying to determine direction of zigzag indicator with the icustom command.

This is what i have so far:

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

The lines are drawn on the chart, but both ZigZagHigh and ZigZagLow are equal to zero when I run the program.




How would i determine the trend of the ZigZag indicator with the icustom function?


Thanks
dr gaines
38
dr gaines  
Hi

Can you guys post the three buffer zigzag please.

Thanks
Dr Gaines
Bogdan Caramalac
760
Bogdan Caramalac  
dr_gaines:
c0d3:
I'm trying to determine direction of zigzag indicator with the icustom command.



This is what i have so far:



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

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



The lines are drawn on the chart, but both ZigZagHigh and ZigZagLow are equal to zero when I run the program.









How would i determine the trend of the ZigZag indicator with the icustom function?





Thanks



You can't determine the trend. The last point's position is variable until another point is added.
zsqabca
23
zsqabca  
dr_gaines:


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

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

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


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

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

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

我得到的是这:





Time>=M30

zsqabca
23
zsqabca  

Time>M30

zigzag=betterzigzag

To add comments, please log in or register