TradingView
Nanda86
2020年3月9日下午3點18分

ADR price targets with alert options- Ultimate 

描述

ADR based price targets with option to hide past levels..

發布通知

Made ADR(Average Daily Range) calculation changes so that levels wont be changing once low or high has been made in the time period you are looking at...

發布通知

Label changes

發布通知

Added 60 minutes price targets - useful for scalping and intraday

發布通知

Added the ability to extend the target lines and also added Trailing stop loss

Trailing stop loss uses 8 period SMA of close for longs and 8 MA of open for shorts

Method to exit longs -- Close your longs once price close below the Long TS EMA
Method to exit shorts -- Close your shorts once price close above the Short TS EMA

評論
Nanda86
Posted the code for this indicator in one of the comments..plz use it..
harikumar85
@Nanda86, please post the full code again.. as the old code getting much errors....
SandipYadav
@Nanda86, geeting error so paste full proper code sir
SandipYadav
@Nanda86, sir i m trying this last one month but geeting error so request kindly share proper code
gaurangkhatri68
@Nanda86, plz explain how to use?
faaz777ss
works well with crude oil add 1 bull and 1 bear at a time and check it
rajasandy
@faaz777ss, .. i dont understand bro.. pls explain.
smr553
can you please share the script for study purposes? since i'm new to pine script
Nanda86
@smr553,

//@version=4
study(title="Ultimate ADR Price Targets", shorttitle="Ultim. ADR. Price Alerts", overlay = true)

// Function outputs 1 when it's the first bar of the D/W/M/Y
is_newbar(res) =>
ch = 0
if(res == 'Y')
t = year(time('D'))
ch := change(t) != 0 ? 1 : 0
else
t = time(res)
ch := change(t) != 0 ? 1 : 0
ch

// Rounding levels to min tick
nround(x) =>
n = round(x / syminfo.mintick) * syminfo.mintick

////////////
// INPUTS //
////////////

pp_type = input(title = 'Target Type', defval = "Bull", options = ["Bear", "Bull"])
pp_period = input(title = "Period", defval = "D", type = input.resolution, options = ['D', '60','W', 'M', 'Y'])
extendOption = input(title="Line Extension", type=input.string, options=["none", "left", "right", "both"], defval="none")
tl = input(false, title = 'Trailing Stoploss - Long')
ts = input(false, title = 'Trailing Stoploss - Short')
show_historical_levels = input(title = "Show Historical Levels?", defval = false, type = input.bool)
show_level_value = input(title = "Show Levels Value?", defval = true, type = input.bool)
show_current_levels = input(title = "Show Current Levels", defval = false, type = input.bool)
Length = input(10, title="average length for ADR")

pp_res = pp_period == 'D' ? 'D' : pp_period == '60' ? '60' : pp_period == 'W' ? 'W' : pp_period == 'M' ? 'M' : 'Y'
//tf = input(title="Resolution", type=input.resolution, defval="D")
/////////////////////
// Get HLC from HT //
lineExtend = (extendOption == "left") ? extend.left : (extendOption == "right") ? extend.right : (extendOption == "both") ? extend.both : extend.none

// Calc Open
dhigh = security(syminfo.tickerid, pp_period , high, lookahead=barmerge.lookahead_on)
dlow = security(syminfo.tickerid, pp_period , low, lookahead=barmerge.lookahead_on)
//whigh = security(syminfo.tickerid, "W", high, lookahead=barmerge.lookahead_on)
//wlow = security(syminfo.tickerid, "W", low, lookahead=barmerge.lookahead_on)
//mhigh = security(syminfo.tickerid, "M", high, lookahead=barmerge.lookahead_on)
//mlow = security(syminfo.tickerid, "M", low, lookahead=barmerge.lookahead_on)

trailstoplong = sma(close,8)
trailstopshort = sma(open,8)
display_value = true
plot(tl and trailstoplong ? trailstoplong:na, title="Long Trailing Stop", color=color.green, transp=0, offset=0)
plot(ts and trailstopshort ? trailstopshort:na, title="Short Trailing Stop", color=color.red, transp=0, offset=0)
label_sl1 = tl ? label.new(bar_index, trailstoplong, text=display_value ? (" SL" + " " + tostring(nround(trailstoplong))) : "SL", style= label.style_none, textcolor=color.green, yloc = yloc.belowbar) : na
label.delete(label_sl1[1])
label_sl2 = ts
smr553
@Nanda86, thank you so much....
更多