搜索
产品
社区
市场
新闻
经纪商
更多
CN
开始
社区
/
指标和策略
/
My strategy
OPEN-SOURCE SCRIPT
My strategy
由powerandy提供
关注
关注
3天前
图表
图表
策略报告
策略报告
1
添加到收藏
添加到收藏
3天前
//
version
=5
strategy("Dynamic RSI Momentum", "DRM Strategy", process_orders_on_close = true, default_qty_type = strategy.percent_of_equity, default_qty_value = 50 )
// +++++++++++++++++++++
// ++ INPUT ++
// +++++++++++++++++++++
// Momentum
len = input.int(10, "Momentum Length", 1, group = "Dynamic RSI Momentum")
src = input.source(close, "Source", group = "Dynamic RSI Momentum")
min_rsi = input.int(20, "Min RSI", group = "Dynamic RSI Momentum")
max_rsi = input.int(50, "Max RSI", group = "Dynamic RSI Momentum")
upLvl = input.float(70, "OverBought", 0, 100, group = "Dynamic RSI Momentum")
dnLvl = input.float(30, "OverSold", 0, 100, group = "Dynamic RSI Momentum")
// +++++++++++++++++++++
// ++ CALCULATION ++
// +++++++++++++++++++++
// RMA Function
rmaFun(src, len) =>
sma = ta.sma(src, len)
alpha = 1/len
sum = 0.0
sum := na(sum[1]) ? sma : alpha * src + (1 - alpha) * nz(sum[1])
// RSI Function
rsiFun(src, len) =>
100 - 100 / (1 + rmaFun(src - src[1] > 0 ? src - src[1] : 0, len) /
rmaFun(src[1] - src > 0 ? src[1] - src : 0, len))
// Momentum
momVal = src - src[len]
// Calculation Price vs Momentum
corr = ta.correlation(src, momVal, len)
corr := corr > 1 or corr < -1 ? float(na) : corr
rsiLen = 0
rsiLen := int(min_rsi + nz(math.round((1 - corr) * (max_rsi-min_rsi) / 2, 0), 0))
rsiMom = rsiFun(src, rsiLen)
// +++++++++++++++++++++
// ++ STRATEGY ++
// +++++++++++++++++++++
long = ta.crossover(rsiMom, dnLvl)
short = ta.crossunder(rsiMom, upLvl)
// +++> Long <+++++
if long and not na(rsiMom)
strategy.entry("Long", strategy.long)
// +++> Short <+++++
if short and not na(rsiMom)
strategy.entry("Short", strategy.short)
// +++++++++++++++++++++
// ++ PLOT ++
// +++++++++++++++++++++
plot(rsiMom, "Dynamic RSI Momentum", rsiMom < dnLvl ? color.green : rsiMom > upLvl ? color.red : color.yellow)
hline(50, "Mid Line", color.gray)
upperLine = hline(upLvl, "Upper Line", color.gray)
lowerLine = hline(dnLvl, "Lower Line", color.gray)
fill(upperLine, lowerLine, color.new(color.purple, 90), "Background Fill")
Bands and Channels
Bill Williams Indicators
Breadth Indicators
开源脚本
本着真正的TradingView精神,此脚本的作者已将其开源,以便交易者可以理解和验证它。向作者致敬!您可以免费使用它,但在出版物中重复使用此代码受
网站规则
约束。 您可以收藏它以在图表上使用。
想在图表上使用此脚本?
添加到收藏
powerandy
关注
免责声明
这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在
使用条款
阅读更多信息。