zig zag help

 

Hi,

I'm trying to write an ea based on zigzag and pitchfork.

to draw pitchfork i need price and time of last 4 zigzag

i get the price with ICustom()

but I don't know how to get the Time

Please help me :)

thanks in advance

----------------------------------------------------------------------

this is for price...


int n0, n1, n2, n3, i0, i1, i2, i3 = 0;

double zig0, zig1, zig2, zig3;


while(n3<4)

{

zig3=iCustom(NULL, 0, "ZigZag", 0, i3);

if(zig3>0) n3+=1;

i3++;

}

while(n2<3)

{

zig2=iCustom(NULL, 0, "ZigZag", 0, i2);

if(zig2>0) n2+=1;

i2++;

}

while(n1<2)

{

zig1=iCustom(NULL, 0, "ZigZag", 0, i1);

if(zig1>0) n1+=1;

i1++;

}

while(n0<1)

{

zig0=iCustom(NULL, 0, "ZigZag", 0, i0);

if(zig0>0) n0+=1;

i0++;

}

...........................................

 
Time[i3] Time[i2] Time[i1] Time[i0]
regardless, u r wasting lines of code for nothing
 
You will need to calculate the pichfork values by yourself. MT4 does not offer a way of getting the line values.
 
gianluca87:

int n0, n1, n2, n3, i0, i1, i2, i3 = 0;

double zig0, zig1, zig2, zig3;

Please use this to post code . . . it makes it easier to read.

 

thanks qjol

i solved this way


int n1, n2, n3, n0,  i1, i2, i3, i0 = 0;
double zig3, zig2, zig1, zig0;
datetime zig3time, zig2time, zig1time, zig0time;

while(n3<4)
{
zig3=iCustom(NULL, 0, "ZigZag", 0, i3);
zig3time = iTime(NULL, 0, i3);
if(zig3>0) n3+=1;
i3++;

}
while(n2<3)
{
zig2=iCustom(NULL, 0, "ZigZag", 0, i2);
zig2time = iTime(NULL, 0, i2);
if(zig2>0) n2+=1;
i2++;

}   
while(n1<2)
{
zig1=iCustom(NULL, 0, "ZigZag", 0, i1);
zig1time = iTime(NULL, 0, i1);
if(zig1>0) n1+=1;
i1++;

}   
while(n0<1)
{
zig0=iCustom(NULL, 0, "ZigZag", 0, i0);
zig0time = iTime(NULL, 0, i0);
if(zig0>0) n0+=1;
i0++;
}   

zzuegg

now i have price and time of zig zag, i will use your method ( https://www.mql5.com/en/forum/132593 )

to draw pitchfork as a line :)

regards

Reason: