My first Inidicator Markttechnik ZigZag based
Forums › ProRealTime English forum › ProBuilder support › My first Inidicator Markttechnik ZigZag based
- This topic has 5 replies, 4 voices, and was last updated 3 weeks ago by robertogozzi.
-
-
12/21/2023 at 2:42 PM #22557412/27/2023 at 12:28 PM #22572712/27/2023 at 12:44 PM #225731
Yes, ZigZag, DPO and other indicators are the so-colled REPAINTING indicators and cannot be used for autotrading.
11/28/2024 at 7:09 AM #24083811/28/2024 at 12:29 PM #240853It’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:
123456789101112131415161718192021222324252627282930313233343536373839// 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 = 21MAtype = 0 //(sma)Arrows = 1Periods = max(1,min(999,Periods))MAtype = max(0,min(8,MAtype))src = CustomClosen = round((Periods / 2) - 0.5) + 1MyDPO = 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 > openBearish = close < open// If ARROWS are ticked then display signalsIF Arrows THENIF MyDPO CROSSES OVER MyDPO[n] AND Bullish THENDrawArrowUP(BarIndex,MyDPO) coloured(0,255,0,180) //GreenENDIFIF MyDPO CROSSES UNDER MyDPO[n] AND Bearish THENDrawArrowDOWN(BarIndex,MyDPO) coloured(255,0,0,180) //RedENDIFENDIF//RETURN MyDPO AS "DPO",0 AS "Zero"11/28/2024 at 12:32 PM #240857Actually the gap is 6 bars, since the calculation is (Periods / 2) + 1, so 10/2 + 1 = 6.
-
AuthorPosts
Find exclusive trading pro-tools on