This indicator only works on PRT v11 onwards.
This indicator draws trend lines from the last bar on the chart based on the previous p candles.
You can also draw channels above and below the main trend line. The steeper the trend line the further apart these are and the shallower the trend line the closer together they are. Their spacing can be adjusted using the ‘Multiple’ setting. The channel lines can be added or removed with the ‘Upper’ and ‘Lower’ settings.
The trend lines and channel lines are projected into the future by p bars and into the past by p bars. These can be removed or displayed with the ‘Past’ and ‘Future’ settings.
The calculations can be done using either pure price movements of price movements as a percentage of the previous close. The ‘Percentage’ setting allows you to choose which.
The trend lines are green if they are rising and red if they are declining.
If you apply the indicator multiple times to your price chart with different settings for ‘p’ then you can get a feeling for short, medium and long term trends and be able to visualise where price might be in the future.
As always I advise downloading and importing to get full functionality.
//Trend Lines and Trend Channel
//PRT v11
//By Vonasi
//Date: 20200401
if p < barindex then
if barindex >= p-1 then
if percentage then
$diff[barindex] = ((close-open)/(close[1]))
else
$diff[barindex] = close-open
endif
if islastbarupdate then
mydiff = 0
for a = 0 to p-1
if percentage then
mydiff = mydiff+($diff[barindex-a]*close)
else
mydiff = mydiff+($diff[barindex-a])
endif
next
r = 128
g = 0
if mydiff >=0 then
r = 0
g = 128
endif
if past then
drawsegment(barindex,close,barindex-p,close - mydiff)coloured(r,g,0)
endif
if future then
drawsegment(barindex,close,barindex+p,close + mydiff)coloured(r,g,0)
endif
if upper then
hh = abs(mydiff)*multiple
if past then
drawsegment(barindex,close+hh,barindex-p,close-mydiff+hh)coloured(r,g,0)
endif
if future then
drawsegment(barindex,close+hh,barindex+p,close+mydiff+hh)coloured(r,g,0)
endif
endif
if lower then
ll = abs(mydiff)*multiple
if past then
drawsegment(barindex,close-ll,barindex-p,close-mydiff-ll)coloured(r,g,0)
endif
if future then
drawsegment(barindex,close-ll,barindex+p,close+mydiff-ll)coloured(r,g,0)
endif
endif
endif
endif
endif
return