Zig Zag from past to present without repainting

 

Good night everyone,

I am trying something interesting with Zig Zag indicator but I have a little doubt. We all know ZigZag repaints to adapt to new price values and cannot be used for signaling, right? I am trying to build an indicator that can show me all those points signaled by Zig Zag in the past which were repainted right after -I know there are some indicators that do that but I wanted to do it myself-. So, my question is: When I call ZigZag with iCustom(), do I get the REAL value displayed at the time, or the "future" adjusted one? I want precisely to mark all those highs and lows that turned out to be "false signals" and show them in a graph without repainting.

It seems a straighforward question with a straighforward answer, but some signals are dissapearing in real time, while past "false" signals seems to be pointed correctly. Take, for instance, the following chart.

Note how "false" signals are pointed with an arrow by reading the past value of ZigZag... However, in real time, signals dissapear.

Example code: Are the values received with iCustom the real values returned at the time?

int start()
  {
    // Start, limit, etc..
    int start = 0;
    int limit;
    int counted_bars = IndicatorCounted();

    // no more to count
    if(counted_bars < 0) 
        return(-1);
        
    // Only check these
    limit = Bars - 1 - counted_bars;
    
    // Check if ignore bar 0
    if(CalculateOnBarClose == true) start = 1;
    
    // Check the signal foreach bar
    for(int i = limit; i >= start; i--)
    {   
        // Zig Zag high. Are these the real values received in the past?
        double zzhighn = iCustom(Symbol(), 0, "ZigZag", ZZDepth, ZZDev, ZZFil, 1, i);
        double zzlown  = iCustom(Symbol(), 0, "ZigZag", ZZDepth, ZZDev, ZZFil, 2, i);
    }
}

How can it be that past "false signals" are pointed in the chart correctly and new ones dissapear if they are wrong?

This happens when the last leg has not closed yet: it seems I can't get the last value of the unclosed leg with iCustom and I get the adjusted one instead.

Thank you!

 
int start = 0 . . . . i >= start . . . . it repaints.
 
flaab:

Good night everyone,

I am trying something interesting with Zig Zag indicator but I have a little dubt. We all know ZigZag repaints to adapt to new price values and cannot be used for signaling, right? I am trying to build an indicator that can show me all those points signaled by Zig Zag in the past which were repainted right after -I know there are some indicators that do that but I wanted to do it myself-. So, my question is: When I call ZigZag with iCustom(), do I get the REAL value displayed at the time, or the "future" adjusted one? I want precisely to mark all those highs and lows that turned out to be "false signals" and show them in a graph without repainting.

It seems a straighforward question with a straighforward answer, but some signals are dissapearing in real time, while past "false" signals seems to be pointed correctly. Take, for instance, the following chart.

Note how "false" signals are pointed with an arrow by reading the past value of ZigZag... However, in real time, signals dissapear.

Example code: Are the values received with iCustom the real values returned at the time?

How can it be that past "false signals" are pointed in the chart correctly and new ones dissapear if they are wrong?

This happens when the last leg has not closed yet: it seems I can't get the last value of the unclosed leg with iCustom and I get the adjusted one instead.

Thank you!


Ask yourself and answer What is zigzag doing ?

and at what point is last signal not repainted..... what condition do we have then....

 
flaab:

We all know ZigZag repaints to adapt to new price values and cannot be used for signaling, right?

I am trying to build an indicator that can show me all those points signaled by Zig Zag in the past which were repainted right afte

So, my question is: When I call ZigZag with iCustom(), do I get the REAL value displayed at the time, or the "future" adjusted one?

How can it be that past "false signals" are pointed in the chart correctly and new ones dissapear if they are wrong?


 double zzhighn = iCustom(Symbol(), 0, "ZigZag", ZZDepth, ZZDev, ZZFil, 1, i);
 double zzlown  = iCustom(Symbol(), 0, "ZigZag", ZZDepth, ZZDev, ZZFil, 2, i);
  1. ZigZag repaints so the current leg can not be used.
  2. Don't copy the indicators values, all you get is the current values. Instead set your indicator if ZigZag was set at any time.
    int init(){
       :
       SetIndexEmptyValue(0,0.0);
    }
    int start(){
       for (int iBar = Bars - 1; iBar >=0; iBar--){
           double value = iCustom(Symbol(), 0, "ZigZag", ZZDepth, ZZDev, ZZFil, 0, iBar);
           if (value != 0) myBuffer[iBar] = value;
       }
    }

  3. When you call iCustom you get the values in the buffers at that time. If the indicator repaints, the values in the buffers has been changed.
  4. "Past 'false signals' are not pointing correctly." It displays for example, the current high for the leg. Each higher high changes the leg (the repainting.) Once the market reverses, the current high is no longer changing and the value in the indicator stops changing. The POTENTIALLY false signal has become correct.

  5. Why are you looking at buffer 1 and 2. ZigZag has only 1 displayed buffer (0) the other two are internal use.
 
RaptorUK:
int start = 0 . . . . i >= start . . . . it repaints.
The iteration is from past to present, it should not repaint... or at least, I think the reason is not the iteration. Thank you for your attention.
 
WHRoeder:
  1. ZigZag repaints so the current leg can not be used.
  2. Don't copy the indicators values, all you get is the current values. Instead set your indicator if ZigZag was set at any time.
  3. When you call iCustom you get the values in the buffers at that time. If the indicator repaints, the values in the buffers has been changed.
  4. Past 'false signals' are not pointing correctly. It displays for example, the current high for the leg. Each higher high changes the leg (the repainting.) Once the market reverses, the current high is no longer changing and the value in the indicator stops changing. The POTENTIALLY false signal has become correct.

  5. Why are you looking at buffer 1 and 2. ZigZag has only 1 displayed buffer (0) the other two are internal use.

Helo WHRoeder, I was using the two internal buffers which represent highs and lows. I'll try using just buffer 0 at all times and post the results, and maybe in the code base.

My goal is to do a full map of past zigzag signals -using fractals as well-, and then maybe filter them in some way. I'll keep you posted thank you.

 

I know what it was, the parameter ExtBackStep sets how many past buffer values are "repainted". When set to 2 and using fractals to validate signals, there is no repainting at all.

It is an useful indicator, I will share soon in codebase. It is like like a "multiple past zig zag comparation". Cheers!

 
You know that fractals are also repainting 2 bars in the past/fixed after two more closed bars?
 
zzuegg:
You know that fractals are also repainting 2 bars in the past/fixed after two more closed bars?
I am using my own fractals implementation that does not repaint and ignores bar[0], and using ZigZag with ExtBackStep of 1, so nothing repaints. Is nice, I'll share in a few hours.
 

Here is the result: I just shared on codebase. Something profitable might arise using Parabolic Sar.

Cheers and thanks.

--

Description:

This indicator is very simple: it shows signals triggered using two different ZigZag indicators (fast and slow) without any filtering.

It does never -ever- repaint a past signal and therefore is useful to study the real behavior of the ZigZag indicator -which does repaint- as a trading tool over time.

As you can see, many signals are repainted by ZigZag indicator over time. Fractals have been used to reduce the number of highs and lows painted.

It depends on original MetaQuotes ZigZag indicator.

Images:



In the following example, I am using the following. FastZigZag = 12, SlowZigZag = 36. ZigZag: 6.



Mixed with Parabolic Sar...


Recommendations:

  • Do not trade this indicator by itself
  • This indicator has been made for educational purposes only -not for actual trading-
  • You can use this indicator template to filter zigzag signals with your trading strategy
  • You can study the relationship between not-repainted fast and slow zigzag signals over time

Color convention:

  • Orange dots are signals shared by both ZigZags
  • Blue dots are only Fast ZigZag signals
  • Red dots are only Slow ZigZag signals (only seen if fast ZigZag is hidden)

Input parameters:

  • CalculateOnBarClose (default: true) - Determines if unclosed bar is evaluated
  • ZigZagFast (default: 6) Set as 0 to hide it
  • ZigZagSlow(default: 24) Set as 0 to hide it
Files:
 

This one does the same but only with one zigzag. You might find it useful.

Cheers.

-

Description:

This indicator is very simple: it shows signals triggered using Fractals and the original ZigZag indicator without any further filtering.

It does never -ever- repaint a past signal and therefore it useful to study the real behavior of the ZigZag -which does repaint- as a trading tool over time.

You should complement signals with your own trading strategy or edit the source code to do it.

As you can see, many signals are repainted by ZigZag indicator over time.

It depends on original MetaQuotes ZigZag indicator.


Images:



Recommendations:

  • Do not trade this indicator by itself
  • You can use this indicator template to filter zigzag signals with your trading strategy

Features:

  • Adjustable ZigZag parameters
  • You decide wether to evaluate bar zero or not
Reason: