Download MetaTrader 5

Classifying trends with Zigzag

To add comments, please log in or register
filipefr
58
filipefr  

I'm trying to classify trends with Zigzag indicator. But my code just classifies the market as a trend (UP/DOWN). But I did some research about zigzag here in the forum and found code similar with the below one. But I applied this code to EURUSD-5min from Jan,1,2015 - Jan,31,2015 - and it just classifies as a DOWN trend. But when I apply the zigzag indicator in the chart, it shows some UP trends.

How can I have the same trends like in the chart? 

 

i=0;
         while(n<5)
         {
         if(zig>0) {
            zag=zig;
         
         }
            zig=iCustom(Symbol(),0,"zigzag",ExtDepth,ExtDeviation,ExtBackstep,0,i);
            if(zig>0) {
               n+=1; 
            }
            i++;
         }
         
         Print("zig ",zig);
         Print("zag ",zag);
         //Print("------------");
         
         
         if (zig>zag) {
            Print("UP");
            market_state = 1;
         } else if (zag > zig)  {
            Print("DOWN");
            market_state = 0;
         } 
hji
26
hji  
Isn't it showing any down trends in the chart?
filipefr
58
filipefr  
Yes, there are UP and DOWN trends.
To add comments, please log in or register