Thanks in advance!
Zigzag embedded in an EA?
- slipshod
- Trader
- Posts: 404
- Joined: Tue Dec 27, 2011 9:14 am
- Location: Australia
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!
Thanks in advance!
-
fxarun
- Trader
- Posts: 41
- Joined: Tue Feb 07, 2012 10:21 am
- Location: Chennai India
Re: Zigzag embedded in an EA?
hi,
Please check this one.
Regards,
Arun
Please check this one.
Regards,
Arun
You do not have the required permissions to view the files attached to this post.
"It's not the strongest species that survive, nor the most intelligent, but the one most responsive to change"
-- Darwin.
-- Darwin.
- slipshod
- Trader
- Posts: 404
- Joined: Tue Dec 27, 2011 9:14 am
- Location: Australia
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 
-
bfis108137
- Posts: 4
- Joined: Fri Jul 13, 2012 1:57 pm
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
}
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
}