[英]Buy sell conditions and alerts when it is above or below 0
Please see below the indicator.请看下面的指标。 It is an oscillator that shows the time segmented volume.
它是一个显示时间分段成交量的振荡器。 I would like to add alerts or alertcondition on it.
我想在上面添加警报或警报条件。 Buy signal when the bar is above 0, and sell signal when the bar is below 0. I couldn't figure out how to do it.
当柱线高于 0 时买入信号,当柱线低于 0 时卖出信号。我不知道该怎么做。
Thanks for your help谢谢你的帮助
// 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)
Ok.好的。 I figured it out.
我想到了。
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)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.