stevehopwoodforex.com
https://www.stevehopwoodforex.com/phpBB3/
Print view

Zigzag embedded in an EA?
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=1836
Page 1 of 1
Author:  slipshod [ Sat Apr 06, 2013 8:44 am ]
Post subject:  Zigzag embedded in an EA?

Hi, just wondering if anyone knows of an EA on this site or elsewhere that has the zigzag logic embedded - I'd rather not use an iCustom call for performance reasons, and by the same token I don't want to spend days reinventing the wheel ;)

Thanks in advance!
Author:  fxarun [ Sat Apr 06, 2013 1:07 pm ]
Post subject:  Re: Zigzag embedded in an EA?

hi,

Please check this one.

Regards,

Arun
Author:  slipshod [ Sat Apr 06, 2013 1:15 pm ]
Post subject:  Re: Zigzag embedded in an EA?

Interesting - its not written like an EA at all, just the indicator code with all its indi-ish stuff & some logic to enter trades appended. Didn't know that kind of hybrid was possible. Thanks Arun I'll try it out :)
Author:  bfis108137 [ Sun Apr 14, 2013 4:05 pm ]
Post subject:  Re: Zigzag embedded in an EA?

I have worked some with zigzag. Basically how I did it was this. You have one buffer which has all of the points, and then the other 2 buffers are all of the historical points before it repainted. So I would look for the last 2 points. The the last point was higher than the previous then it was up and if it was lower then it was down. The code would look something like this.
double point1 = -1;
double point2 = -1;
for(int i=0;i<bars;i++)
{
double pointValue = icustom(put your code here to get the value of bar i);
if(value > 0)
{
if(point1 <0)
{
point1 = value;
}
else if(point2 < 0)
{
point2 = value;
}
else
{
break;
}
}
}

Now you have the last 2 points so you just need to figure out which is higher

if(point1>point2)
{
//code if zigzag is up
}
else
{
//code if zigzag is down
}
All times are UTC Page 1 of 1