Please post your trading view indicators and scripts. With the AI explosion, its easier then ever to create scripts and strategies.
The purpose for me is to learn, teach and help each other with shared knowledge, testing and oversight.
Please try and post original scripts, modified or otherwise, not just copy and paste. Modifying available scripts with enhancements and improvements is acceptable and share your views on improvements and strategy testing.
Below is a modified ADR indicator. ADR line based on daily data, has a multiplied ADR line value set at 1.30 (130%), it also paints arrows showing candles that hit the ADR lines (customisable).
//@version=2
study(title="ADR.v2 - Average Daily Range [CK]", shorttitle="ADR [CK]", overlay=true)
length = input(defval=5, title="Length", type=integer, minval=1)
offset = input(defval=0, title="Offset", type=integer, minval=0)
use_av = input(defval="EMA", title="EMA/SMA", type=string)
today_only = input(defval=false, title="Show Today Only", type=bool)
multiplier = input(1.30, title="ADR Multiplier", minval=0.1, step=0.05)
// Used to calculate true range
high0 = security(tickerid, 'D', high[offset])
low0 = security(tickerid, 'D', low[offset])
close1 = security(tickerid, 'D', close[1 + offset])
open0 = security(tickerid, 'D', open)
datr = max(max(high0 - low0, abs(high0 - close1)), abs(low0 - close1))
smooth = security(tickerid, 'D', use_av=="SMA" ? sma(datr, length) : ema(datr, length))
milliseconds_in_1day = 1000 * 60 * 60 * 24 * 1
midnight_today = timenow - (timenow % milliseconds_in_1day)
leftborder = time >= midnight_today or (not today_only)
rightborder = false
// Original ADR levels
p1 = plot(open0 + smooth, color=leftborder and not rightborder ? green : na, title='Upper ADR', linewidth=3, style=line)
p2 = plot(open0 - smooth, color=leftborder and not rightborder ? red : na, title='Lower ADR', linewidth=3, style=line)
// Variable multiplier levels
upper_mult = open0 + smooth * multiplier
lower_mult = open0 - smooth * multiplier
p3 = plot(upper_mult, color=leftborder and not rightborder ? blue : na, title='Upper ' + tostring(multiplier * 100) + '% ADR', linewidth=2, style=line)
p4 = plot(lower_mult, color=leftborder and not rightborder ? orange : na, title='Lower ' + tostring(multiplier * 100) + '% ADR', linewidth=2, style=line)
// Draw arrows when ADR and ADR multiplier levels are touched
plotarrow(series=high >= open0 + smooth ? 1 : na, colorup=green, offset=-1, title='Upper ADR Arrow')
plotarrow(series=low <= open0 - smooth ? -1 : na, colordown=red, offset=-1, title='Lower ADR Arrow')
plotarrow(series=high >= upper_mult ? 1 : na, colorup=blue, offset=-1, title='Upper Multiplier Arrow')
plotarrow(series=low <= lower_mult ? -1 : na, colordown=orange, offset=-1, title='Lower Multiplier Arrow')
The purpose for me is to learn, teach and help each other with shared knowledge, testing and oversight.
Please try and post original scripts, modified or otherwise, not just copy and paste. Modifying available scripts with enhancements and improvements is acceptable and share your views on improvements and strategy testing.
Below is a modified ADR indicator. ADR line based on daily data, has a multiplied ADR line value set at 1.30 (130%), it also paints arrows showing candles that hit the ADR lines (customisable).
//@version=2
study(title="ADR.v2 - Average Daily Range [CK]", shorttitle="ADR [CK]", overlay=true)
length = input(defval=5, title="Length", type=integer, minval=1)
offset = input(defval=0, title="Offset", type=integer, minval=0)
use_av = input(defval="EMA", title="EMA/SMA", type=string)
today_only = input(defval=false, title="Show Today Only", type=bool)
multiplier = input(1.30, title="ADR Multiplier", minval=0.1, step=0.05)
// Used to calculate true range
high0 = security(tickerid, 'D', high[offset])
low0 = security(tickerid, 'D', low[offset])
close1 = security(tickerid, 'D', close[1 + offset])
open0 = security(tickerid, 'D', open)
datr = max(max(high0 - low0, abs(high0 - close1)), abs(low0 - close1))
smooth = security(tickerid, 'D', use_av=="SMA" ? sma(datr, length) : ema(datr, length))
milliseconds_in_1day = 1000 * 60 * 60 * 24 * 1
midnight_today = timenow - (timenow % milliseconds_in_1day)
leftborder = time >= midnight_today or (not today_only)
rightborder = false
// Original ADR levels
p1 = plot(open0 + smooth, color=leftborder and not rightborder ? green : na, title='Upper ADR', linewidth=3, style=line)
p2 = plot(open0 - smooth, color=leftborder and not rightborder ? red : na, title='Lower ADR', linewidth=3, style=line)
// Variable multiplier levels
upper_mult = open0 + smooth * multiplier
lower_mult = open0 - smooth * multiplier
p3 = plot(upper_mult, color=leftborder and not rightborder ? blue : na, title='Upper ' + tostring(multiplier * 100) + '% ADR', linewidth=2, style=line)
p4 = plot(lower_mult, color=leftborder and not rightborder ? orange : na, title='Lower ' + tostring(multiplier * 100) + '% ADR', linewidth=2, style=line)
// Draw arrows when ADR and ADR multiplier levels are touched
plotarrow(series=high >= open0 + smooth ? 1 : na, colorup=green, offset=-1, title='Upper ADR Arrow')
plotarrow(series=low <= open0 - smooth ? -1 : na, colordown=red, offset=-1, title='Lower ADR Arrow')
plotarrow(series=high >= upper_mult ? 1 : na, colorup=blue, offset=-1, title='Upper Multiplier Arrow')
plotarrow(series=low <= lower_mult ? -1 : na, colordown=orange, offset=-1, title='Lower Multiplier Arrow')