我有以下指示器,我尝试将其转换为版本4,但出现以下错误
17:12:06 Error at 14:0 Cannot call 'operator -' with 'expr1'=series[bool]. The argument should be of type: const integer
17:12:06 Cannot call 'operator -' with 'expr2'=series[bool]. The argument should be of type: const integer;
17:12:06 Error at 15:0 Undeclared identifier 'ARROW';
以下是脚本代码:
study(shorttitle="BOA", title="Binary Options Arrows (example) [TheMightyChicken]", overlay=true)
// Inputs
E = input(1, minval=1, title="Expiry")
// Calculations
Bearish_harami = (close[1] > open[1] and open > close and open <= close[1] and open[1] <= close and open - close < close[1] - open[1] and open[5] < open)
Bullish_harami = (open[1] > close[1] and close > open and close <= open[1] and close[1] <= open and close - open < open[1] - close[1] and open[5] > open)
// Setups
CALL = Bullish_harami == 1
PUT = Bearish_harami == 1
ARROW = CALL - PUT
plotarrow(ARROW, colorup=lime, colordown=red, transp=0, minheight=10, maxheight=10)
// Results
WIN = (CALL[E]==1 and close[E]<close) or (PUT[E]==1 and close[E]>close)
LOSE = (CALL[E]==1 and close[E]>=close) or (PUT[E]==1 and close[E]<=close)
bgcolor(WIN==1 ? lime : LOSE==1 ? red : na, transp=70)
指标链接: https://in.tradingview.com/v/ioSbnNIX/
想要将其转换为pinescript版本4
v1
的问题是,它将允许对 bool
类型进行数学运算。 false
将是 0
,true
将是 1
。因此,虽然CALL
和PUT
都是bool
类型,但ARROW = CALL - PUT
是允许的。
在
v4
中,这是不允许的。作为解决方法,您可以将这些变量转换为 int
。
修复颜色后,以下将起作用。
CALL = Bullish_harami ? 1 : 0
PUT = Bearish_harami ? 1 : 0