The TrendRisk bands indicator is a simple channel indicator made of 2 custom averages of candlesticks ranges calculated within the variable “BandsBars” period.
Upper and lower channel bands width can be adjusted with the “Deviation” variable, which act as a simple factor to enlarge the spread between them.
Indicator converted from MT4 version by a request on the french forum.
//PRC_Trend Risk indicator | indicator
//29.05.2017
//Nicolas @ www.prorealcode.com
//Sharing ProRealTime knowledge
//translated from MT4 code
// --- settings
//BandsBars=28
//Deviation=3.5
// --- end of settings
once SmoothPrice=close
once SmoothRange=range
if barindex>1 then
SmoothPrice=(SmoothPrice[1]*(BandsBars-1)+Close)/BandsBars
SmoothRange=(SmoothRange[1]*(BandsBars-1)+High-Low)/BandsBars
Top=SmoothPrice+SmoothRange*Deviation
Bottom=SmoothPrice-SmoothRange*Deviation
endif
T=1
D=1
N=1
if (Close< Top) then
T=0
endif
if (Close> Bottom ) then
D=0
endif
if ( Close < Bottom or Close> Top ) then
N=0
endif
if (T= 1) then
r=0
g=255
b=0
endif
if (D= 1) then
r=255
g=0
b=0
endif
if (N= 1) then
r=150
g=150
b=150
endif
DRAWCANDLE(open,high,low,close)coloured(r,g,b)
RETURN Top as "Top channel", Bottom as "Bottom channel"