Tradescript code for trend() not working

short signal: HIGH > KeltnerChannelTop(14, SIMPLE, 1.1) and trend(sma(close,200)) = down

this code always crashes pi. however, whenever i remove the trend function, it works fine. could anyone please advice me what is the problem? i have tried using lower values of sma like 100 and 50 etc but still this issue persists.

TREND() function is fine, check the KeltnerChannelTop function which is not defined in tradescript

KC is working fine. Trend is not. It never generates signals.

try using the TREND function first, like below

trend(sma(close,200)) = DOWN AND HIGH > KeltnerChannelTop(14, SIMPLE, 1.1)