pine
//@version=5
strategy("Coin Price Prediction Strategy", overlay=true)
// 입력 파라미터
rsiPeriod = input(14, "RSI 기간")
macdFast = input(12, "MACD 빠른 기간")
macdSlow = input(26, "MACD 느린 기간")
macdSignal = input(9, "MACD 시그널 기간")
volumePeriod = input(20, "거래량 기간")
// RSI 계산
rsiValue = ta.rsi(close, rsiPeriod)
// MACD 계산
[macdLine, signalLine, _] = ta.macd(close, macdFast, macdSlow, macdSignal)
// 볼린저 밴드
[middle, upper, lower] = ta.bb(close, 20, 2)
// 거래량 분석
avgVolume = ta.sma(volume, volumePeriod)
volumeRatio = volume / avgVolume
// 상승/하락 확률 계산 로직
bullishScore = 0.0
bearishScore = 0.0
// RSI 분석
if (rsiValue > 70)
bearishScore += 30
else if (rsiValue < 30)
bullishScore += 30
// MACD 분석
if (macdLine > signalLine)
bullishScore += 25
else
bearishScore += 25
// 볼린저 밴드 분석
if (close < lower)
bullishScore += 20
else if (close > upper)
bearishScore += 20
// 거래량 분석
if (volumeRatio > 1.5)
bullishScore += 15
else if (volumeRatio < 0.5)
bearishScore += 15
// 최종 확률 계산
totalScore = bullishScore - bearishScore
bullishProbability = math.max(0, math.min(100, (bullishScore / (bullishScore + bearishScore)) * 100))
bearishProbability = 100 - bullishProbability
// 결과 시각화
var color textColor = color.white
var color bullColor = color.green
var color bearColor = color.red
f_printLabel(_text) =>
label.new(
x = bar_index,
y = high,
text = _text,
color = textColor,
style = label.style_label_down,
textcolor = totalScore > 0 ? bullColor : bearColor
)
// 확률 라벨 표시
if (bar_index == last_bar_index)
f_printLabel(
"상승 확률: " + str.tostring(math.round(bullishProbability)) + "%\n" +
"하락 확률: " + str.tostring(math.round(bearishProbability)) + "%"
)
// 플로팅
plot(bullishProbability, color=bullColor, title="상승 확률")
plot(bearishProbability, color=bearColor, title="하락 확률")