Public Bank Bhd
교육
업데이트됨

SIRI PINE SCRIPT - crossover dan barcolor untuk indicator

233
Permintaan dari rakan kita untuk mewarnakan candle jika syarat pada stochrsi tercapai serta membuat simple alert berdasarkan syarat tadi.

Semoga terhibur.
노트
//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')

면책사항

이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.