a00520

yi da teacher buy sell

//@version=3
// Copyright by Libertus - 2019
// RSI 易达老师
// Free for private use
study(title="Relative Strength Index - Divergences - Libertus", shorttitle="RSI Div - Lib")
len = input(14, minval=1, title="RSI Length")
ob = input(70, "Overbought", integer, minval=0, maxval=100)
os = input(30, "Oversold", integer, minval=0, maxval=100)

// RSI code
rsi = rsi (close, len )
band1 = hline(ob)
band0 = hline(os)
plot( rsi , color=( rsi > ob or rsi < os ? red : black), transp=0)
fill(band1, band0, color=purple, transp=97)

// DIVS code
piv = input(false,"Hide reverses?")
shrt = input(false,"Shorter labels?")
xbars = input(90, "Div lookback period (bars)?", integer, minval=1)
hb = abs(highestbars( rsi , xbars)) // Finds bar with highest value in last X bars
lb = abs(lowestbars( rsi , xbars)) // Finds bar with lowest value in last X bars

// Defining variable values, mandatory in Pine 3
max = na
max_rsi = na
min = na
min_rsi = na
reverseh = na
reversel = na
divsell = na
divbuy = na

// If bar with lowest / highest is current bar, use it's value
max := hb == 0 ? close : na(max) ? close : max
max_rsi := hb == 0 ? rsi : na(max_rsi) ? rsi : max_rsi
min := lb == 0 ? close : na(min) ? close : min
min_rsi := lb == 0 ? rsi : na(min_rsi) ? rsi : min_rsi

// Compare high of current bar being examined with previous bar's high
// If curr bar high is higher than the max bar high in the lookback window range
if close > max // we have a new high
max := close // change variable "max" to use current bar's high value
if rsi > max_rsi // we have a new high
max_rsi := rsi // change variable "max_rsi" to use current bar's RSI value
if close < min // we have a new low
min := close // change variable "min" to use current bar's low value
if rsi < min_rsi // we have a new low
min_rsi := rsi // change variable "min_rsi" to use current bar's RSI value

// Finds reverse point with at least 2 right candles with lower value
reverseh := (max_rsi == max_rsi) and (max_rsi != max_rsi) ? true : na
reversel := (min_rsi == min_rsi) and (min_rsi != min_rsi) ? true : na

// Detects divergences between price and indicator with 1 candle delay so it filters out repeating divergences
if (max > max) and (rsi < max_rsi) and ( rsi <= rsi)
divsell := true
if (min < min) and (rsi > min_rsi) and ( rsi >= rsi)
divbuy := true
// Alerts
alertcondition(divsell, title='sell div', message='sell div')
alertcondition(divbuy, title='buy div', message='buy div')

// Plots divergences and reverses with offest
// Longer labels
plotshape(shrt ? na : divsell ? rsi + 1 : na, location=location.absolute, style=shape.labeldown, color=red, size=size.tiny, text="sell", textcolor=white, transp=0, offset=-1)
plotshape(shrt ? na : divbuy ? rsi - 1 : na, location=location.absolute, style=shape.labelup, color=green, size=size.tiny, text="buy", textcolor=white, transp=0, offset=-1)
plotshape( piv ? na : shrt ? na : reverseh ? max_rsi + 1 : na, location=location.absolute, style=shape.labeldown, color=blue, size=size.tiny, text="reverse", textcolor=white, transp=0, offset=-2)
plotshape( piv ? na : shrt ? na : reversel ? min_rsi - 1 : na, location=location.absolute, style=shape.labelup, color=blue, size=size.tiny, text="reverse", textcolor=white, transp=0, offset=-2)

// Shorter labels
plotshape(shrt ? (divsell ? rsi + 3 : na) : na, location=location.absolute, style=shape.triangledown, color=red, size=size.tiny, transp=0, offset=-1)
plotshape(shrt ? (divbuy ? rsi - 3 : na) : na, location=location.absolute, style=shape.triangleup, color=green, size=size.tiny, transp=0, offset=-1)
plotshape( piv ? na : shrt ? (reverseh ? max_rsi + 3 : na) : na, location=location.absolute, style=shape.triangledown, color=blue, size=size.tiny, transp=0, offset=-2)
plotshape( piv ? na : shrt ? (reversel ? min_rsi - 3 : na) : na, location=location.absolute, style=shape.triangleup, color=blue, size=size.tiny, transp=0, offset=-2)

// Debug tools
// plot(max, color=blue, linewidth=2)
// plot(max_rsi, color=red, linewidth=2)
// plot(hb, color=orange, linewidth=2)
// plot( lb , color=purple, linewidth=1)
// plot(min_rsi, color=lime, linewidth=1)
// plot(min, color=black, linewidth=1)
从常用脚本中删除 添加到常用脚本

评论

首页 股票筛选器 外汇筛选器 加密货币筛选器 财经日历 如何运作 图表功能 价格 推荐朋友 网站规则 帮助中心 网站 & 经纪商解决方案 插件 图表解决方案 轻量图表库 博客 & 新闻 Twitter
概览 个人资料设置 账户和账单 推荐朋友 我的客服工单 帮助中心 已发表观点 粉丝 正在关注 私人消息 在线聊天 退出