Reputation: 6624
I am trying to check if the past n
candles are of the same type.
For example, are all five previous candles bullish, or are they all bearish.
With my approach, I keep getting an error:
lines 30:37: Return type of one of the 'if' blocks is not compatible with return type of other block(s) (void; series[bool]; series[bool])
What am I getting wrong in my iteration?
Thank you all in advance.
I am also willing to try out any other working approach/ ideas.
// Determine if we have a valid setup
isBullish = true
isBearish = true
for i = (iterationCount - 1) to 0
notSeries = not(isBullish or isBearish)
if notSeries
break
else if close[i] > open[i] and isBullish
isBearish := false
else
isBullish := false
Upvotes: 0
Views: 661
Reputation: 6865
Not sure why it throws that error, because even if you put isBearish := false
before the break
, the error persists, even though every path in the if
statement returns a bool
.
I'd write it like this, because you don't need the break
for the evaluation of your isBullish
and isBearish
. You only need the break
to stop your for
loop.
for i = (iterationCount - 1) to 0
notSeries = not(isBullish or isBearish)
if notSeries
break
if close[i] > open[i] and isBullish
isBearish := false
else
isBullish := false
Upvotes: 1