ZigZag Channel Help me please!

Back to topics list To post a new topic, please log in or register
avatar
86
fly7680 2016.07.30 21:41
 
Hello everyone, I have modified the Fractal channel indicator by entering the ZigZag indicator, however, I would like to create a obliguo channel but the result is not as expected, you could give me some help?

Thank you

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Gray
#property indicator_color2 Gray
//---- buffers
double v1[];
double v2[];
//----
double val1;
double val2;
int i;
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+  
int init()
  {
//---- drawing settings
   SetIndexArrow(0, 119);
   SetIndexArrow(1, 119);
//----  
   SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 1);
   SetIndexDrawBegin(0, i-1);
   SetIndexBuffer(0, v1);
   SetIndexLabel(0, "Resistance");  
//----
   SetIndexStyle(1, DRAW_LINE, STYLE_SOLID, 1);
   SetIndexDrawBegin(1, i-1);
   SetIndexBuffer(1, v2);
   SetIndexLabel(1, "Support");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
  {
   i = Bars;
   while(i >= 0)
     {   
       // last 2 candles
       if (i <= 2) {
        v1[i] = v1[i + 1];
        v2[i] = v2[i + 1];
       // every other
       } else {
        val1 = iCustom(NULL, PERIOD_CURRENT, "ZIG ZAG NRP", 480, 4, 0, i); // ZigZag Upper
               //----
               if(val1 > 0) 
                   v1[i] = High[i];
               else
                   v1[i] = v1[i+1]; 
               val2 = iCustom(NULL, PERIOD_CURRENT, "ZIG ZAG NRP", 480, 4, 0, i); // ZigZag Lower
               //----
               if(val2 > 0) 
                   v2[i] = Low[i];
               else
                   v2[i] = v2[i+1];
       }
       // iterator
       i--;
     }   
   return(0);
}
 
//+------------------------------------------------------------------+
avatar
12988
WHRoeder 2016.07.30 22:15 #
 
fly7680:

I have modified the Fractal channel indicator by entering the ZigZag indicator,

however, I would like to create a obliguo channel

but the result is not as expected, you could give me some help?

  1. val1 = iCustom(NULL, PERIOD_CURRENT, "ZIG ZAG NRP", 480, 4, 0, i); // ZigZag Upper
    val2 = iCustom(NULL, PERIOD_CURRENT, "ZIG ZAG NRP", 480, 4, 0, i); // ZigZag Lower
    Same calls, how can they be different? You should write a self documenting function instead of calling iCustom directly, see Detailed explanation of iCustom - MQL4 forum
  2. Don't assume we can find your exact indicator, always post it or the link I Have Zig Zag Non Repaint Indicator!! A Programmer Needed To Optimize It! @ Forex Factory

  3. Never heard of "a obliguo channel"
  4. "Doesn't work" is meaningless - just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires - meaningless. There are no mind readers here.
avatar
86
fly7680 2016.07.31 09:16 #
 
WHRoeder:
  1. Never heard of "a obliguo channel"
  2. "Doesn't work" is meaningless - just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires - meaningless. There are no mind readers here.
why should not in its operation? With the ZigZag indicator and its oblique channel you can have a lot of information. I understand it's very difficult to program and I am a beginner, but certainly an oblique channel would be very useful.

Thanks, I will study better MQL4 code.




avatar
12988
WHRoeder 2016.07.31 16:50 #
 

Now that you explained yourself with a picture.

  1. You can't use buffers to do that.
  2. You must get the last two, non-zero highs and last two non-zero lows from the zig zag. Then create or move two trendlines (with Ray=true) using those points.
avatar
86
fly7680 2016.07.31 21:43 #
 
WHRoeder:

Now that you explained yourself with a picture.

  1. You can't use buffers to do that.
  2. You must get the last two, non-zero highs and last two non-zero lows from the zig zag. Then create or move two trendlines (with Ray=true) using those points.
Thanks for the answer, I will try to study the code to achieve my goal.
Thank you
Back to topics list  

To add comments, please log in or register