I have below indicator and i tried to convert it into version4 but getting following error
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';
Below is the script code:
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)
Indicator Link: https://in.tradingview.com/v/ioSbnNIX/
Want to convert it to pinescript version4
The problem with v1
is, it will allow math operations on bool
types. false
will be 0
and true
will be 1
. Therefore, although both CALL
and PUT
are of bool
type, ARROW = CALL - PUT
is allowed.
In v4
, this is not allowed. As a workaround, you can convert those variables into int
s.
Below will work after you fix the colors.
CALL = Bullish_harami ? 1 : 0
PUT = Bearish_harami ? 1 : 0