Classifying trends with Zigzag

Back to topics list To post a new topic, please log in or register
avatar
14
filipefr 2015.02.15 02:51
 

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;
         } 
avatar
21
hji 2015.02.15 06:26 #
 
Isn't it showing any down trends in the chart?
avatar
14
filipefr 2015.02.15 09:20 #
 
Yes, there are UP and DOWN trends.
Back to topics list  

To add comments, please log in or register