Trend Lines and Trend Channel update.
Forums › ProRealTime English forum › ProBuilder support › Trend Lines and Trend Channel update.
- This topic has 6 replies, 2 voices, and was last updated 2 years ago by Nicolas.
-
-
04/06/2020 at 11:17 AM #124811
I have made a few improvements to my PRTv11 Trend Lines and Trend Channel indicator.
You can now set a StartBack period. This allows you to draw the trend lines that would have been shown StartBack bars ago. So for example if you set p to 100 and StartBack also to 100 you can see what lines would have been projected forward for 100 bars from 100 bars back in history so you can see how price behaved in the last 100 bars compared to what the trend lines drew.
There is also now the option to remove the middle trend line. this allows you to just show the upper and lower channels if you wish to.
There is now also the option to display the pivot point at the central point of the middle line. This is useful when using the StartBack feature as it shows you exactly where in the history the lines are being drawn from.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778//Trend Lines and Trend Channel v2//PRT v11//By Vonasi//Date: 20200406// p = 100//Percentage = 1//Lower = 1//Upper = 1//Past = 1//Future = 1//Multiple = 1//StartBack = 0//PivotPoint = 1//Middle = 1if p < barindex thenif barindex >= p-1 thenif percentage then$diff[barindex] = ((close-open)/(close[1]))else$diff[barindex] = close-openendifif islastbarupdate thenmydiff = 0for a = startback to startback+p-1if percentage thenmydiff = mydiff+($diff[barindex-a]*close)elsemydiff = mydiff+($diff[barindex-a])endifnextr = 128g = 0if mydiff >=0 thenr = 0g = 128endifif pivotpoint thendrawpoint(barindex-startback,close[startback],2)coloured(r,g,0)endifif middle thenif past thendrawsegment(barindex-startback,close[startback],barindex-p-startback,close[startback] - mydiff)coloured(r,g,0)endifif future thendrawsegment(barindex-startback,close[startback],barindex+p-startback,close[startback] + mydiff)coloured(r,g,0)endifendifif upper thenhh = abs(mydiff)*multipleif past thendrawsegment(barindex-startback,close[startback]+hh,barindex-p-startback,close[startback]-mydiff+hh)coloured(r,g,0)endifif future thendrawsegment(barindex-startback,close[startback]+hh,barindex+p-startback,close[startback]+mydiff+hh)coloured(r,g,0)endifendifif lower thenll = abs(mydiff)*multipleif past thendrawsegment(barindex-startback,close[startback]-ll,barindex-p-startback,close[startback]-mydiff-ll)coloured(r,g,0)endifif future thendrawsegment(barindex-startback,close[startback]-ll,barindex+p-startback,close[startback]+mydiff-ll)coloured(r,g,0)endifendifendifendifendifreturn1 user thanked author for this post.
04/07/2020 at 2:42 PM #12506904/07/2020 at 3:06 PM #125073It quite simply looks back p bars and adds up the close-open (or the percentage of price that (close-open) is if you are using the percentage option) and stores that value in an array for every bar on the chart. Green bars will be a positive value and red bars a negative value. So then it can go back p bars from any point and add up all the values in the array for those p bars. Our result is the value ‘diff’. If red candles have been bigger or more plentiful than green ones then this will add up to a negative number and if green candles have been bigger or more plentiful than red ones then this will add up to a positive number.
It then draws a segment from p bars back to the start bar and another segment p bars forward from the start bar. The line slopes down if our result was negative and up if it was positive.
The channels are simply a line drawn parallel but ‘diff’ higher and ‘diff’ lower (actually diff*multiple). Hence the shallower the slope the narrower the bands because our ‘diff’ value is low and the steeper the slope the wider the bands because our ‘diff’ value is high.
Then there is just some jiggery pokery with drawing instructions to draw everything in the right place on the chart.
06/11/2020 at 8:42 AM #135546Hi!
There is a fault in the attachment.
At least if you run it on 10.3
Best Regards
06/11/2020 at 9:01 AM #135549I have made a few improvements to my PRTv11 Trend Lines and Trend Channel indicator.
The clue as to why it does not work on v10.3 can clearly be found in the very first line of my opening post.
The indicator uses arrays which are not available for use in v10.3
02/28/2022 at 12:51 AM #188963Can anyone assist? I added the indicator it keep showing up multiple trends/channels in the chart.
The old trend/channels will show on the chart, and new one keeps on printing/ I was hoping it will auto repaint it self or is there a setting to do auto repaint?
Wayne.
02/28/2022 at 11:06 AM #189002Add this line at the top of the code:
1defparam drawonlastbaronly=true1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on