1 algorithmic-trading tradingview-api pine-script pine-script-v5
看来我无法找出适合我的策略的正确脚本,如下所示:
\n在每日时间范围内效果更好,收到的信号更少,但更有效,脚本是这样的:
\n//@version=5\nstrategy("Estrategia Long Only")\n// Definir el indicador ADX\nlen = input(14, title="ADX Length")\nth = input(44, title="ADX Threshold")\nadx_val = ta.adx(high, low, close, len)\n// Definir el indicador RSI\nrsi_len = input(14, title="RSI Length")\nrsi_buy = input(20, title="RSI Buy Threshold")\nrsi_sell = input(35, title="RSI Sell Threshold")\nrsi_val = ta.rsi(close, rsi_len)\n// Generar se\xc3\xb1ales de compra\nadx_above_th = adx_val > th\nrsi_above_buy = rsi_val >= rsi_buy and rsi_val < rsi_sell\nbuy_signal = adx_above_th and rsi_above_buy\n// Entradas largas\nif buy_signal\n strategy.entry("Long", strategy.long)\n// Plotting\n plotshape(buy_signal, "Buy", shape.triangleup, location.belowbar, color.green, size=size.small)\nRun Code Online (Sandbox Code Playgroud)\n但我不断收到此错误:
\n\n\n错误于 10:11 找不到函数或函数引用“ta.adx”
\n
我尝试从其他指标导入值,因为问题似乎出在 ADX 指标中,但似乎无法解决。
\nta.adx()错误消息告诉您没有任何功能。
您应该使用ta.dmi()来获取 adx 值。
len = input.int(17, minval=1, title="DI Length")
lensig = input.int(14, title="ADX Smoothing", minval=1, maxval=50)
[diplus, diminus, adx] = ta.dmi(len, lensig)
plot(adx, color=color.red, title="ADX")
plot(diplus, color=color.blue, title="+DI")
plot(diminus, color=color.orange, title="-DI")
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4247 次 |
| 最近记录: |