首页 > 解决方案 > 真实强度指标策略

问题描述

我对编码世界很陌生,我正在尝试在 Tradingview 中构建一个简单的策略。

我只想建立一个基于真实强度指标的买卖策略。因此,每当“慢”线向上穿过信号线时,我想买入,而当慢线向下穿过信号线时,我想卖出。

任何人都可以为我提供代码吗?我有 TSI 指标的代码,仅用于显示指标,但不用于交易信号。

非常感谢。

标签: pine-script

解决方案


创建一个新的 Pinscript。选择真实强度指标 稍作修改,脚本将如下所示:

//@version=4
study("True Strength Indicator", shorttitle="TSI", format=format.price, precision=4)
long = input(title="Long Length", type=input.integer, defval=25)
short = input(title="Short Length", type=input.integer, defval=13)
signal = input(title="Signal Length", type=input.integer, defval=13)
price = close
double_smooth(src, long, short) =>
    fist_smooth = ema(src, long)
    ema(fist_smooth, short)
pc = change(price)
double_smoothed_pc = double_smooth(pc, long, short)
double_smoothed_abs_pc = double_smooth(abs(pc), long, short)
tsi_value = 100 * (double_smoothed_pc / double_smoothed_abs_pc)
tsi_ema = ema(tsi_value, signal)
plot(tsi_ema, color=#FF006E)
plot(tsi_value, color=#3BB3E4)
hline(0, title="Zero")

现在使用变量tsi_valuetsi_ema创建您自己的表达式

尝试 whit crossunder或 crossover


推荐阅读