1

My script does not working as expected when I put a 'NA' variable in 'AND' logical.

// ON/OFF Indicator
// Buy Condition
MACDonoffbuy = useMACD ? macdLine > 0 : na  
ADXonfoffbuy = useADX ? ADX > thradx : na 
RSIonoffbuy = useRSI ? rsi >= overbought : na
Williamonoffbuy = useWilliam ? percentR >= -25 : na
Squeezeronoffbuy = useSqueezer ? sqzOff : na
// Sell Condition
MACDonoffsell = useMACD ? macdLine < 0 : na
ADXonfoffsell = useADX ? ADX > thradx : na 
RSIonoffsell = useRSI ? rsi <= overbought : na
Williamonoffsell = useWilliam ? percentR <= -25 : na
Squeezeronoffsell = useSqueezer ? sqzOff : na

// Final Combination 
buy = MACDonoffbuy and ADXonfoffbuy and RSIonoffbuy and Williamonoffbuy and Squeezeronoffbuy
sell = MACDonoffsell and ADXonfoffsell and RSIonoffsell and Williamonoffsell and Squeezeronoffsell

My expectation is if one of expression is 'NA' on that 'AND' logical, the other expression is still calculated.

0 Answers0