BURSATRENDBANDCHART

SIRI PINE SCRIPT - crossover dan barcolor untuk indicator

Education
MYX:PBBANK   PUBLIC BANK BHD
Permintaan dari rakan kita untuk mewarnakan candle jika syarat pada stochrsi tercapai serta membuat simple alert berdasarkan syarat tadi.

Semoga terhibur.
Comment:
//@version=4
study(title="Stochastic RSI", shorttitle="Stoch RSI", format=format.price, precision=2, resolution="")
smoothK = input(3, "K", minval=1)
smoothD = input(3, "D", minval=1)
lengthRSI = input(14, "RSI Length", minval=1)
lengthStoch = input(14, "Stochastic Length", minval=1)
src = input(close, title="RSI Source")

rsi1 = rsi(src, lengthRSI)
k = sma(stoch(rsi1, rsi1, rsi1, lengthStoch), smoothK)
d = sma(k, smoothD)
plot(k, "K", color=#0094FF)
plot(d, "D", color=#FF6A00)
h0 = hline(80, "Upper Band", color=#606060)
h1 = hline(20, "Lower Band", color=#606060)
fill(h0, h1, color=#9915FF, transp=80, title="Background")

green = crossover(k,d) and k <= 20 and d <= 20
red = crossover(d,k) and k >=80 and d >= 80

barcolor (color = green ? color.green : red ? color.red : na)

alertcondition(green, title='Green bar', message = '{{tickerid}} - Crossover from below')

alertcondition(red, title='Red bar', message = '{{tickerid}} - Crossover from above')

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.