My first Inidicator Markttechnik ZigZag based

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #225574 quote
    gidien
    Participant
    New

    Hello,

    just a preview for my first prorealcode indicator. I’m still learning and coding is not perfect.
    I make it to take my trades with “Markttechnik” strategy. It is like  1-2-3 swing trading.

    best regard

    Guido

    #225727 quote
    Jean FX
    Moderator
    New

    Real zigzag indicators actually do object retracement, which we do not do because it is unrealistic and cannot be used in real trading.

    #225731 quote
    robertogozzi
    Moderator
    Master

    Yes, ZigZag, DPO and other indicators are the so-colled REPAINTING indicators and cannot be used for autotrading.

    #240838 quote
    xpe74
    Participant
    New

    Roberto hi,  at some stage, there are some calculations done by this indicator to draw lines. Is the calculation unable to generate a signal we could convert to a trading signal and why ? best regards

    #240853 quote
    robertogozzi
    Moderator
    Master

    It’s a repainting indicator, i.e. if it NOW detects a signal on a PAST candle, it goes back to that candle and plots the signal on it!

    This is visually acceptable, but CAN’T be used in trading, as you cannor enter a trade back in the past!

    I am attaching a custom version of DPO which returns the CURRENT value which CAN be used in automatic trading (BLACK line), it also plots the DPO as it is usually done, and as it is done by PRT (FUCHSIA line, which CAN’T be used in automatic trading).

    Pic Dpo1 shows the repainting signals circled in ORANGE, while the CURRENT signal is circled in RED.

    Pic Dpo2 shows where the REPAINTING signal is plotted and where it really is as CURRENT. There’s a 10-bar distance because the indicator was set with 10 periods., The more the periods, the bigger the gap, the less the periods the smaller the gap.

    This is the code:

    // DPO - Detrended Price Oscillator
    //
    //       Formula and calculation:
    //
    // The DPO is calculated by subtracting the simple moving average over an "n" day period and shifted
    // n/2+1 days back from the price.
    //
    // To calculate the detrended price oscillator:
    //
    //      Decide on the time frame that you wish to analyze. Set "n" as half of that cycle period.
    //      Calculate a simple moving average for n periods.
    //      Calculate (n / 2 + 1)
    //      Subtract the moving average, from (n / 2 + 1) days ago, from the closing price:
    //      DPO = Close - Simple moving average [from (n / 2 + 1) days ago]
    //
    Periods = 21
    MAtype  = 0    //(sma)
    Arrows  = 1
    Periods    = max(1,min(999,Periods))
    MAtype     = max(0,min(8,MAtype))
    src        = CustomClose
    n          = round((Periods / 2) - 0.5) + 1
    MyDPO      = src[n] - Average[Periods,MAtype](src)
    // Plot shifted DPO   (somewhat like Ichimoku's Chikou)
    DrawSegment(BarIndex - n -1,MyDpo[1],BarIndex - n,MyDPO) coloured(255,0,255,255) //Fuchsia
    //
    Bullish    = close > open
    Bearish    = close < open
    // If ARROWS are ticked then display signals
    IF Arrows THEN
       IF MyDPO CROSSES OVER  MyDPO[n] AND Bullish THEN
          DrawArrowUP(BarIndex,MyDPO) coloured(0,255,0,180)                          //Green
       ENDIF
       IF MyDPO CROSSES UNDER MyDPO[n] AND Bearish THEN
          DrawArrowDOWN(BarIndex,MyDPO) coloured(255,0,0,180)                        //Red
       ENDIF
    ENDIF
    //
    RETURN MyDPO AS "DPO",0 AS "Zero"
    #240857 quote
    robertogozzi
    Moderator
    Master

    Actually the gap is 6 bars, since the calculation is (Periods / 2) + 1, so 10/2 + 1 = 6.

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.

My first Inidicator Markttechnik ZigZag based


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
gidien @gidien Participant
Summary

This topic contains 5 replies,
has 4 voices, and was last updated by robertogozzi
1 year, 2 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 12/21/2023
Status: Active
Attachments: 4 files
Logo Logo
Loading...