VISUAL LEVELs INDICATOR with Donchian channel
Forums › ProRealTime English forum › ProBuilder support › VISUAL LEVELs INDICATOR with Donchian channel
- This topic has 27 replies, 6 voices, and was last updated 1 year ago by gregoire.
-
-
12/15/2020 at 11:37 PM #153891
Hello,
I think that a level indicator based on Donchian channels helps to find more easily the levels of slowdowns/reversals.
Can anyone code an indicator that draws lines that extend the high/low of the Donchian channels please ?
In my example I have used the Donchian channels over 500 periods and you can see that it adds a very useful visual aid.1 user thanked author for this post.
01/06/2021 at 6:14 PM #156651This indicator is a great idea @Soyouzzz1 !
01/07/2021 at 2:23 PM #156751The below code plots the last “maxlines” of the Donchian Channel 500 periods, the same way as described by @Soyouzzz1
123456789101112131415161718192021222324252627282930313233defparam drawonlastbaronly=truemaxlines = 20 //how many lines to plot?hh= DonchianChannelUp[500]ll= DonchianChannelDown[500]if hh<>hh[1] then$hh[hhi]=hhhhi=hhi+1endifif ll<>ll[1] then$ll[lli]=lllli=lli+1endifif islastbarupdate thencount=0for i = max(hhi,lli) downto 0 doif isset($hh[i]) thendrawhline($hh[i]) coloured(0,200,0)endifif isset($ll[i]) thendrawhline($ll[i]) coloured(200,0,0)endifcount=count+1if count>=maxlines thenbreakendifnextendifreturn3 users thanked author for this post.
01/07/2021 at 10:02 PM #156810Hello @Nicolas, can you send us the indicator in itf, because there is a calculation error when copying and pasting?
01/08/2021 at 8:53 AM #15685301/08/2021 at 10:30 AM #156872I think it must be some error in the Donchian calculation as I just coded this totally different version and it also has a ‘calculation error’
12345678910111213141516171819202122232425262728293031323334353637defparam drawonlastbaronly=truedefparam calculateonlastbars = 2000p = 100if barindex > p thenif islastbarupdate thenmaxlines = 20hh= DonchianChannelUp[p]ll= DonchianChannelDown[p]a = 1for b = 0 to barindexif hh[b]<>hh[b+1] thendrawhline(hh[b]) coloured(0,128,0)a = a + 1if a > maxlines thenbreakendifendifnexta = 1for b = 0 to barindexif ll[b]<>ll[b+1] thendrawhline(ll[b]) coloured(128,0,0)a = a + 1if a > maxlines thenbreakendifendifnextendifendifreturn1 user thanked author for this post.
01/08/2021 at 7:50 PM #156987Thank you for your help @Nicolas and @Vonasi.
I also had the same problem: the indicator returns an error message.According to Vonasi, the problem comes from the Donchian channel calculation performed by PRT.
So I incorporated the calculation in your 2 indicators, replacing the lines :12hh= DonchianChannelUp [500]ll= DonchianChannelDown [500]by
12hh= HIGHEST [DH](HIGH)ll=HIGHEST [DL](HIGH)DH(Donchian High) and DL(Donchian Low) are variables with default values of 500.
In Nicholas’ indicator it effectively traces the lines, but in Vonasi’s indicator it did not allow to display them.
To create an indicator with a high probability of reversal, can these 3 points be improved?
1. Removal of levels when the price has crossed them
In the picture posted in my first message, I make the lines continue until the prices go through them. Once crossed the levels are no longer relevant and pollute the image by sending lines whose probas of reversing the price are lower than lines that have not been crossed.
Example in image 1.DLTo avoid erasing levels that have been briefly crossed, if you can add two filters (modifiable by a variable) to choose to keep :
-lines that have been crossed by less than 5/10/x points
and
-lines whose price remained less than 1/2/x candles beyond .
Example in image 2.DL2. Display of the most relevant levels
The current indicator takes into account all levels of Donchian.
But in a trend we can see that a Donchian level is often only a pause level of the trend and this level is quickly broken.To avoid displaying levels that are not solid, if you can add two filters (modifiable by a variable) to choose to keep only:
– levels that have reversed prices for more than 20/50/x candles
and
– levels that have reversed prices by more than 20/50/x points (an SMA5 can be used to choose the timing of the beginning and end of the reversals)
Example in images 3.DL and 4.DL3. Display levels in smaller time units
To trade reversals, traders look for levels/areas on large time units and use setups on small time units to take positions with good timing.
For this it is important to be able to display the indicator levels on several time units, for example :
– display the levels detected by the indicator in H4 on 5min.
– display the levels detected by the indicator in H1 over 1min.
…Not only will this allow discretionary traders to display all important information on the same screen, but it will also allow them to program trading algorithms where everyone can use their own setups to enter and exit positions.
If we can create this indicator, I will share in the library a reversal algorithm created from it.
Thank you for your help. 😀
01/13/2021 at 1:14 AM #15760901/13/2021 at 11:02 AM #15762401/13/2021 at 4:26 PM #157672Here is a first draft that use the highest levels only.
These are not tested and over complicate the calculation:
To avoid erasing levels that have been briefly crossed, if you can add two filters (modifiable by a variable) to choose to keep :
-lines that have been crossed by less than 5/10/x points
and
-lines whose price remained less than 1/2/x candles beyond .1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950defparam drawonlastbaronly=truep = 20maxbars = 800 //how many bars in history?reversedCandles = 10 //levels have been the same during X barsreversedPoints = 2 //current level - previous level > Y pointsif barindex > p thenhh= highest[p](high)ll= lowest[p](low)if hh<>hh[1] and hh[1]>0 and hh[1]=hh[1+reversedCandles] and abs(hh-hh[1])>=reversedPoints*pointsize then$hhprice[hhi]=hh$hhbar[hhi]=barindex[1+reversedCandles]hhi=hhi+1endifendifif islastbarupdate and hhi>0 then//plot the hh linesfor i = 0 to hhi-1 do //loop through levelselapsed = barindex-$hhbar[i]if elapsed>1 and elapsed<=maxbars thenoffset = max(0,barindex-$hhbar[i])for j = 0 to offset do //testing price break of the current levelprice = close[j]priceprev = close[j+1]level = $hhprice[i]broken = 0if (price>level and priceprev<level) or (price<level and priceprev>level) thenbroken=1//drawarrow($hhbar[i],price)breakendifnextif broken=0 thendrawsegment($hhbar[i],$hhprice[i],barindex,$hhprice[i])test=$hhprice[i]drawtext("#test#",barindex,$hhprice[i],serif,bold,20)//drawtext("#offset#",barindex,$hhprice[i],serif,bold,20)endifendifnextendifreturn1 user thanked author for this post.
01/15/2021 at 11:41 PM #158002Hello @Nicolas, thanks for your help, this is a very good start !
I tried to change the color of the segment because it almost doesn’t show, but it seems that this is not possible on Prorealtime?
If the color of the segment is not changeable can we create zones that would start from the top and bottom of the candle wicks that were used to create the Donchian levels?
01/15/2021 at 11:42 PM #15800601/16/2021 at 10:13 AM #158025Just add COLOURED(0,0,0) at the end of lines 40 and 42.
Change the zero values to any combination found here to draw the lines and text in whatever colour you want.
01/16/2021 at 10:34 AM #15803201/16/2021 at 10:50 AM #158037 -
AuthorPosts