Hyper Trend
Hyper Trend
Hyper Trend
//Style
bullCss = input.color(color.teal, 'Average Color', inline = 'avg', group = 'Style')
bearCss = input.color(color.red, '' , inline = 'avg', group = 'Style')
//-----------------------------------------------------------------------------}
//Calculation
//-----------------------------------------------------------------------------{
var float upper = na
var float lower = na
var float avg = close
var hold = 0.
var os = 1.
os := math.sign(avg - avg[1])
hold := os != os[1] ? atr : hold
//-----------------------------------------------------------------------------}
//Plots
//-----------------------------------------------------------------------------{
css = os == 1 ? bullCss : bearCss
//Fill
if area == 'Gradient'
upper_topcol := upperCss
upper_btmcol := color.new(chart.bg_color, 100)
lower_topcol := color.new(chart.bg_color, 100)
lower_btmcol := lowerCss
else
upper_topcol := upperCss
upper_btmcol := upperCss
lower_topcol := lowerCss
lower_btmcol := lowerCss
//Upper Area
fill(plot_upper, plot_avg
, top_color = os != os[1] ? na : upper_topcol
, bottom_color = os != os[1] ? na : upper_btmcol
, top_value = upper
, bottom_value = avg)
//Lower Area
fill(plot_avg, plot_lower
, top_color = os != os[1] ? na : lower_topcol
, bottom_color = os != os[1] ? na : lower_btmcol
, top_value = avg
, bottom_value = lower)
//-----------------------------------------------------------------------------}