pine-script - 真实强度指标策略
问题描述
我对编码世界很陌生,我正在尝试在 Tradingview 中构建一个简单的策略。
我只想建立一个基于真实强度指标的买卖策略。因此,每当“慢”线向上穿过信号线时,我想买入,而当慢线向下穿过信号线时,我想卖出。
任何人都可以为我提供代码吗?我有 TSI 指标的代码,仅用于显示指标,但不用于交易信号。
非常感谢。
解决方案
创建一个新的 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_value和tsi_ema创建您自己的表达式
尝试 whit crossunder或 crossover
推荐阅读
- visual-studio-code - Visual Studio Code 1.52 SCSS Emmet 行为已更改
- azure-application-insights - 如何评估 Application Insights 请求“自己的”持续时间,而不考虑依赖关系的持续时间?
- python - 从命令行解析成python脚本
- c# - Unity RectTransform.sizeDelta 不会改变大小
- python - 异常后如何继续循环
- python - 生成集合和子集的唯一排列
- c++ - 如何在仅标头库中实现静态类成员?
- python-sphinx - 在文档字符串的某处嵌入植物图(使用 Sphinx 植物扩展)
- python - 如何将 python np.array 转换为 cv2 图像
- c# - C# 删除最后一个动态创建的文本框