cBoer

GRaB Candles w/Notifications

Just added "notifications" to the previous script I found from mattlacoco.
开源脚本

本着真正的TradingView精神,该脚本的作者将其开源发布,以便交易者可以理解和验证它。为作者喝彩!您可以免费使用它,但在出版物中重复使用此代码受网站规则的约束。 您可以收藏它以在图表上使用。

免责声明

这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。

想在图表上使用此脚本?
study(title='Buy Blue Sell Red - Notification', shorttitle='BBSR-N', overlay=true)
// vars
emaPeriod = input(title="EMA Period", type=integer, defval=34)
showWave = input(title="Show Wave", type=bool, defval=false)

// build wave
emaHigh = ema(high,emaPeriod)
emaLow = ema(low,emaPeriod)
emaClose = ema(close,emaPeriod)

waveHigh = showWave == true ? emaHigh : na
waveLow = showWave == true ? emaLow : na
waveClose = showWave == true ? emaClose : na

prevCandleColor = close[1] < emaLow[1] ? close[1] > open[1] ? -2 : -1 : close[1] > emaHigh[1] ? close[1] > open[1] ? 2 : 1 : close[1] > open[1] ? 0 : 0
currCandleColor = close < emaLow ? close > open ? -2 : -1 : close > emaHigh ? close > open ? 2 : 1 : close > open ? 0 : 0
candleChange = prevCandleColor <= 0 and currCandleColor > 0 ? 1 : 
                prevCandleColor >= 0 and currCandleColor < 0 ? -1 : 0

plotchar(candleChange == 1 ? 1 : na, char="*", title="Changed to Bull", transp=100, color=blue)
plotchar(candleChange == -1 ? 1 : na, char="*", title="Changed to Bear", transp=100, color=red)

plot(waveHigh, title="EMA High",color=red )
plot(waveLow, title="EMA Low", color=blue)
plot(waveClose, title="EMA Close", color=silver)

// paint candles according to close position relative to wave
barcolor(close < emaLow ? close > open ? red : maroon : close > emaHigh ? close > open ? blue : navy : close > open ? silver : gray)