首页 > 解决方案 > 谁能检查一下为什么我没有收到信号并收到“未声明的标识符”错误

问题描述

我正在尝试使用 Tradingview 中可用的指标绘制交叉信号(DIminus 和 DIPlus)。Masanakam 的 ADX 和 DI。

我对指标构建策略和生成信号的附加条件是:长期条件和短期条件

//@version=3
strategy("ADX and DI", overlay=true)
len = input(title="Length", type=integer, defval=14)
th = input(title="threshold", type=integer, defval=20)

TrueRange = max(max(high-low, abs(high-nz(close[1]))), abs(low-nz(close[1])))
DirectionalMovementPlus = high-nz(high[1]) > nz(low[1])-low ? max(high-nz(high[1]), 0): 0
DirectionalMovementMinus = nz(low[1])-low > high-nz(high[1]) ? max(nz(low[1])-low, 0): 0rueRange = max(max(high-low, abs(high-nz(close[1]))), abs(low-nz(close[1])))
DirectionalMovementPlus = high-nz(high[1]) > nz(low[1])-low ? max(high-nz(high[1]), 0): 0
DirectionalMovementMinus = nz(low[1])-low > high-nz(high[1]) ? max(nz(low[1])-low, 0): 0

SmoothedTrueRange = nz(SmoothedTrueRange[1]) - (nz(SmoothedTrueRange[1])/len) + TrueRange
SmoothedDirectionalMovementPlus = nz(SmoothedDirectionalMovementPlus[1]) - (nz(SmoothedDirectionalMovementPlus[1])/len) + DirectionalMovementPlus
SmoothedDirectionalMovementMinus = nz(SmoothedDirectionalMovementMinus[1]) - (nz(SmoothedDirectionalMovementMinus[1])/len) + DirectionalMovementMinus

DIPlus = SmoothedDirectionalMovementPlus / SmoothedTrueRange * 100
DIMinus = SmoothedDirectionalMovementMinus / SmoothedTrueRange * 100
DX = abs(DIPlus-DIMinus) / (DIPlus+DIMinus)*100
ADX = sma(DX, len)

longCondition = crossover(DIPlus, DIMinus)
if (longCondition and time>timestamp(2019, 01, 01, 09, 30)) 
strategy.entry("My Long Entry Id", strategy.long)

shortCondition = crossover(DIMinus, DIPlus)
if (shortCondition and time>timestamp(2019, 01, 01, 09, 30)) 
strategy.entry("My Short Entry Id", strategy.short)

我得到的错误是:

未声明标识符“SmoothedDirectionalMovementPlus”
未声明标识符“SmoothedDirectionalMovementMinus”
未声明标识符“SmoothedTrueRange”
未声明标识符“DIPlus”
未声明标识符“DIMinus”
未声明标识符“longCondition”
未声明标识符“shortCondition”

标签: pine-script

解决方案


推荐阅读