当高于或低于 0 时买入卖出条件和警报

Buy sell conditions and alerts when it is above or below 0

请看下面的指标。它是一个显示时间分段交易量的振荡器。我想在上面添加警报或警报条件。当 bar 高于 0 时买入信号,当 bar 低于 0 时卖出信号。我不知道该怎么做。

感谢您的帮助

//      Written by liw0 active on https://www.tradingview.com/u/liw0
//      corrected version by vitelot December 2018 -- no charity required

//      If you decide to use my script in your published charts,
//      please keep this header as it is now and leave the name unchanged!
//      It would make me happy to see my script put to use in other charts :)

//      If you like it I would also be happy about a small donation
//      BTC 1GyfGTBsVHMbPovFGFeipe7b7ET1aebGx5

//      Questions or Comments? Just send me a PM!

//      CREDITS: http://quant.stackexchange.com/questions/2816/how-to-calculate-time-segmented-volume

//@version=5
indicator('Time Segmented Volume', shorttitle='TSV', overlay=false)

l = input(defval=13, title='TSV Length')


//t = sum(close>close[1]?volume*close-close[1]:close<close[1]?(volume*-1)*close-close:0,l)
// previous line is non sensical. The correct version follows
t = math.sum(close > close[1] ? volume * (close - close[1]) : close < close[1] ? volume * (close - close[1]) : 0, l)

SwapColor = t > 0 ? color.green : color.red

plot(series=t, title='TSV Histogram', color=SwapColor, style=plot.style_histogram, histbase=0, linewidth=1)

好的。我想通了。

if t > 0
    alert(message='Buy TSE', freq=alert.freq_once_per_bar)
    
if t < 0
    alert(message='Sell TSE', freq=alert.freq_once_per_bar)