icustom ZigZag

 
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
 
whatever you are trying to do, this is probably not the way to get it.
look at 'Custiom indicators, experts and strategy testing' -- I explained the way to use iCustom...

I think you should have change the indicator and make two extra buffers to get those data.
low value is for example LOWbuff[]
high value is HIGHbuff[]

now if you have a new high (inside indicator) then you check is this different from the value stored right now... if it is, you have a new value...
1.2815 ZigZag max for example
bar1
bar2
bar3
...
barx new value comes as 1.2755

your will be something like HIGHBUFF[1.2815,1.2815,....,1.2815,1.2755,1.2755... . ]

then you use Icustom(NULL,0,"ZigZag",3,0); --> and voila! you have your number

Hope you can understand what I'm talkin' about...

zolero
 
zolero:
whatever you are trying to do, this is probably not the way to get it.
look at 'Custiom indicators, experts and strategy testing' -- I explained the way to use iCustom...

I think you should have change the indicator and make two extra buffers to get those data.
low value is for example LOWbuff[]
high value is HIGHbuff[]

now if you have a new high (inside indicator) then you check is this different from the value stored right now... if it is, you have a new value...
1.2815 ZigZag max for example
bar1
bar2
bar3
...
barx new value comes as 1.2755

your will be something like HIGHBUFF[1.2815,1.2815,....,1.2815,1.2755,1.2755... . ]

then you use Icustom(NULL,0,"ZigZag",3,0); --> and voila! you have your number

Hope you can understand what I'm talkin' about...

zolero


No, i actually do not get it,


All i want is to make my EA know which way zigzag indicator is pointing (UP OR DOWN). HOW WOULD I GO ABOUT DOING THAT?
 
All i want is to make my EA know which way zigzag indicator is pointing (UP OR DOWN). HOW WOULD I GO ABOUT DOING THAT?
Probably you want to know was last two values (as zigzag doesn't have always a value). So you have to read last two values of an indicator:

  int n, i;
  double zag, zig;
i=0;
while(n<2)
{
   if(zig>0) zag=zig;
   zig=iCustom(NULL, 0, "ZigZag", 0, i);
   if(zig>0) n+=1;
   i++;
}
now you have two numbers zig -- last value and zag -- value before that
if(zag>zig) indicator shows down
if(zig>zag) indicator shows up

zolero
 
zolero:
All i want is to make my EA know which way zigzag indicator is pointing (UP OR DOWN). HOW WOULD I GO ABOUT DOING THAT?
Probably you want to know was last two values (as zigzag doesn't have always a value). So you have to read last two values of an indicator:

  int n, i;
  double zag, zig;
i=0;
while(n<2)
{
   if(zig>0) zag=zig;
   zig=iCustom(NULL, 0, "ZigZag", 0, i);
   if(zig>0) n+=1;
   i++;
}
now you have two numbers zig -- last value and zag -- value before that
if(zag>zig) indicator shows down
if(zig>zag) indicator shows up

zolero

THANKS, got it, works like a charm
 
c0d3:
zolero:
All i want is to make my EA know which way zigzag indicator is pointing (UP OR DOWN). HOW WOULD I GO ABOUT DOING THAT?
Probably you want to know was last two values (as zigzag doesn't have always a value). So you have to read last two values of an indicator:

  int n, i;
  double zag, zig;
i=0;
while(n<2)
{
   if(zig>0) zag=zig;
   zig=iCustom(NULL, 0, "ZigZag", 0, i);
   if(zig>0) n+=1;
   i++;
}
now you have two numbers zig -- last value and zag -- value before that
if(zag>zig) indicator shows down
if(zig>zag) indicator shows up

zolero

THANKS, got it, works like a charm





AFTER TESTING IT,



if(zag<zig) indicator shows down
if(zig<zag) indicator shows up


i THINK THAT IS CORRECT, IT WAS GIVING OPPOSITE DIRECTION WITH (zag>zig), (zig>zag)

 
c0d3:
i THINK THAT IS CORRECT, IT WAS GIVING OPPOSITE DIRECTION WITH (zag>zig), (zig>zag)

I was looking last line already on the chart. this means that last line was looking down [or up]. It should mean that right now up [or down] movement is expected. But there is a little problem with taking it as up or down signal: zigzag can [and often do] redraw itself. this means that if the line between two points is showing south (from 1.2900 to 1.2850) then it doesn't mean that the price goes up. It will probably go up but there is a big chance that after some movement down you have new line down (from 1.2900 to 1.2820) and so on. My point is that having a line on chart doesn't mean that movement to this direction is over.
 
  
int n, i; double zag, zig;
i=0;
while(n<2)
{
if(zig>0) zag=zig;
zig=iCustom(NULL, 0, "ZigZag", 0, i);
if(zig>0) n+=1;
i++;
}
 

&nbint n, i; double zag, zig; i=0; while(n<2) { if(zig>0) zag=zig; zig=iCustom(NULL, 0, "ZigZag", 0, i); if(zig>0) n+=1; i++; }sp;int n, i; double zag, zig; i=0; while(n<2) { if(zig>0) zag=zig; zig=iCustom(NULL, 0, "ZigZag", 0, i); if(zig>0) n+=1; i++; }

 
I modified a little bit zigzag code to show what I mean by false signal. like they say: one picture can tell more than 1000 words....


The red line is original zigzag and it goes from bottom to top and back again in best moments... at least seems like this. But if you are coding an ea then ea get's signals which are close to yellow line. it can be even worse as I made really quick hack...
the code is redrawing up or down line until next line has been drawed and so step by step changing yellow line (deleting max and min values) until you get a red line...
 
Reason: