我似乎找不到解决以下 2 个错误的解决方案
26:0 的错误无法调用带有“标题”=字符串的“情节”。参数的类型应该是:const string; 36:0 处的错误无法使用“title”=series[string] 调用“plot”。参数的类型应该是:const string
这是我目前的代码,如果有人能指出我正确的方向,那将是一个很大的帮助
//@version=4
study("Elliot Wave", overlay=true)
// Define the swing high and low points
var swingHigh = high >= high[1] and high >= high[-1] and high > high[-2]
var swingLow = low <= low[1] and low <= low[-1] and low < low[-2]
// Initialize variables
var trend = 0.0
var direction = 0.0
var lastHigh = 0.0
var lastLow = 0.0
var waveCount = 0
var lastWaveHigh = 0.0
var lastWaveLow = 0.0
// Loop through the price data and identify the waves
for i = 2 to bar_index
if swingHigh[i]
if trend == -1
// We have a wave completion, mark the end point
lastWaveHigh := lastHigh
plot(lastWaveHigh, "Wave " + tostring(waveCount), color=color.purple, linewidth=2, style=plot.style_stepline)
waveCount += 1
// New wave started, mark the start point
lastHigh := high[i]
trend := 1
direction := -1
if swingLow[i]
if trend == 1
// We have a wave completion, mark the end point
lastWaveLow := lastLow
plot(lastWaveLow, "Wave " + tostring(waveCount), color=color.purple, linewidth=2, style=plot.style_stepline)
waveCount += 1
// New wave started, mark the start point
lastLow := low[i]
trend := -1
direction := 1
// Plot the wave direction for bullish trend
var lastWaveHighIndex = bar_index - barssince(swingHigh)
plot(lastWaveHigh + direction * (bar_index - lastWaveHighIndex), "Bullish Wave", color=color.green, linewidth=2, style=plot.style_stepline)
// Plot the wave direction for bearish trend
var lastWaveLowIndex = bar_index - barssince(swingLow)
plot(lastWaveLow + direction * (bar_index - lastWaveLowIndex), "Bearish Wave", color=color.red, linewidth=2, style=plot.style_stepline)```
I have tried moving the plot calls inside the corresponding if statements. however it caused another error entirely.
Cannot use 'plot' in local scope.;
在 pinescript 中,您不能在局部范围内使用绘图(在 if 或 for 循环中)。
然后,对于情节,你不能使用标题变化的“变量”,它必须是一个常量字符串=一个不能像“我的字符串示例”那样改变的字符串。
请参阅:https://www.tradingview.com/pine-script-reference/v5/#fun_plot