This is the Donchian Channel indicator extended version.
You can choose to display the trend in 3 different ways:
- traditional one by applying the indicator directly onto the price chart to display the channel formed by the higher highs and lower lows
- as a normalized price oscillator with normalized boundaries at 1/-1 (calculated upon the last higher highs and lower lows)
- as a normalized price oscillator with dynamic boundaries
The current trend is displayed as a red/green plotted at zero level. The trend change each time the price broke the higher or lower boundaries of the donchian channel.
Indicator converted from mt4 code following a request made in the Italian indicator forum.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
//PRC_DonchianChannel3 | indicator //17.09.2019 //Nicolas @ www.prorealcode.com //Sharing ProRealTime knowledge //translated from mt4 version // --- settings ChannelPeriod = 21 HighLowShift = 1 ShowMiddle = 1 //1=true;0=false ZeroBind = 1 //1=true;0=false Normalize = 1 //1=true;0=false // --- end of settings cprice = customclose dcUpper = Highest[ChannelPeriod](high)[HighLowShift] dcLower = Lowest[ChannelPeriod](low)[HighLowShift] dcMiddle = (dcUpper+dcLower)/2.0 if (ZeroBind) then if (Normalize) then buffer1 = 1 buffer2 = -1 diff = (dcUpper-dcMiddle) if (diff <> 0) then price = (cprice-dcMiddle)/diff else price = 0 endif else buffer1 = dcUpper-dcMiddle buffer2 = dcLower-dcMiddle price = (cprice-dcMiddle) endif else buffer1 = dcUpper buffer2 = dcLower price = cprice endif trendp = trendp[1] trend = trend[1] if (dcUpper>dcUpper[1]) then t rend = 1 endif if (dcLower<dcLower[1]) then t rend = -1 endif buffer3=undefined if (ShowMiddle) then if (ZeroBind) then buffer3 = 0 else buffer3 = (buffer1+buffer2)/2 endif endif if (cprice>dcUpper) then trendp = 1 endif if (cprice<dcLower) then trendp = -1 endif if (cprice<dcUpper and cprice>dcLower) then trendp = 0 endif if trend>0 then r=0 g=128 else r=255 g=0 endif return buffer1 coloured(0,128,0) style(dottedline,1),buffer2 coloured(255,0,0) style(dottedline,1),buffer3 coloured(r,g,0) style(line,2),price coloured(0,191,255) style(line,3) //,buffer4 |
Share this
No information on this site is investment advice or a solicitation to buy or sell any financial instrument. Past performance is not indicative of future results. Trading may expose you to risk of loss greater than your deposits and is only suitable for experienced investors who have sufficient financial means to bear such risk.
ProRealTime ITF files and other attachments :PRC is also on YouTube, subscribe to our channel for exclusive content and tutorials
Hi Nicolas, how to use this on tradingview?
You can’t. All codes here are made for the ProRealTime trading platform:
https://www.prorealtime.com
Thanks!
Hi Nicolas! How do I get the indicator in the price chart? It only stays under i new chart.
Just add it on the price chart by using the wrench on the left upper side of the chart (price settings)