寻找解决方法,不能以这种方式使用 plotshape,因为它在本地范围内不起作用。
//@version=3
study("MA test ", overlay=true)
FastMA = sma(close, 9)
SlowMA = sma(close, 15)
Diff = FastMA - SlowMA
if Diff > 0
plotshape(Diff, style=shape.arrowup, location=location.belowbar, color=green)
Run Code Online (Sandbox Code Playgroud) 如果我想将今天的收盘价与过去 4 天的最高价进行比较,格式是什么?我用过了
_hi = close > high[4] ? 1 : 0
Run Code Online (Sandbox Code Playgroud)
但这仅计算 4 天前的高点,而不是两者之间的天数。我试过了
_hi = close > high[1,2,3,4] ? 1 : 0
Run Code Online (Sandbox Code Playgroud)
错误信息
我正在尝试换行,因为它太长,无法在一个屏幕上看到所有内容:
strategy.entry
("Long Continuation",
true, 1, when = FastMA < SlowMA and SlowMA > SlowMA[5] and ShortDiff <
ShortDiff[1]
and close[1] < _PercentAbove and close[1] > _PercentBelow)
Run Code Online (Sandbox Code Playgroud)
它在未包装的情况下工作,但是当我包装它时,我收到错误“添加到图表操作失败,原因:第 15 行:输入‘行尾无行延续’处的语法错误”
我意识到我可以用更好的代码来缩短这个时间,但我只是对 Pine 中的换行工作感到好奇enter code here
pine-script ×3