커뮤니티
트레이딩뷰 지표 변환
트레이딩뷰로 작성한 지표를 지표와 종목검색으로 변환해주세요
//@version=6
indicator("Custom Donchian Mid Breakout (Green Ribbon BUY)", overlay=true, max_labels_count=500)
// ==========================================
// 1. 입력 설정 (Inputs)
// ==========================================
i_exp = input.bool(true, title="Exponential MA (EMA 사용)", group="Madrid Ribbon")
donchian_len = input.int(20, title="돈치안 채널 기간", group="Donchian Channel")
// [추가] 200 SMA 설정
show_sma200 = input.bool(true, title="200 SMA 점선 표시", group="200 SMA")
sma200_len = input.int(200, title="SMA 기간", group="200 SMA")
// ==========================================
// 2. 지표 계산 (Calculations)
// ==========================================
src = close
// [마드리드 리본 계산]
ma05 = i_exp ? ta.ema(src, 5) : ta.sma(src, 5)
ma10 = i_exp ? ta.ema(src, 10) : ta.sma(src, 10)
ma15 = i_exp ? ta.ema(src, 15) : ta.sma(src, 15)
ma20 = i_exp ? ta.ema(src, 20) : ta.sma(src, 20)
ma25 = i_exp ? ta.ema(src, 25) : ta.sma(src, 25)
ma30 = i_exp ? ta.ema(src, 30) : ta.sma(src, 30)
ma35 = i_exp ? ta.ema(src, 35) : ta.sma(src, 35)
ma40 = i_exp ? ta.ema(src, 40) : ta.sma(src, 40)
ma45 = i_exp ? ta.ema(src, 45) : ta.sma(src, 45)
ma50 = i_exp ? ta.ema(src, 50) : ta.sma(src, 50)
ma55 = i_exp ? ta.ema(src, 55) : ta.sma(src, 55)
ma60 = i_exp ? ta.ema(src, 60) : ta.sma(src, 60)
ma65 = i_exp ? ta.ema(src, 65) : ta.sma(src, 65)
ma70 = i_exp ? ta.ema(src, 70) : ta.sma(src, 70)
ma75 = i_exp ? ta.ema(src, 75) : ta.sma(src, 75)
ma80 = i_exp ? ta.ema(src, 80) : ta.sma(src, 80)
ma85 = i_exp ? ta.ema(src, 85) : ta.sma(src, 85)
ma90 = i_exp ? ta.ema(src, 90) : ta.sma(src, 90)
ma100 = i_exp ? ta.ema(src, 100): ta.sma(src, 100)
// [추가] 200 SMA 계산 및 추세 색상 결정
sma200 = ta.sma(src, sma200_len)
isSma200Up = sma200 > sma200[1]
color_sma200 = isSma200Up ? color.rgb(75, 221, 94) : color.red
// 마드리드 리본 색상 판별 함수
maColor(_ma, _maRef) =>
diffMA = ta.change(_ma)
diffMA >= 0 and _ma > _maRef ? #00FF00 : // LIME
diffMA < 0 and _ma > _maRef ? #800000 : // MAROON
diffMA <= 0 and _ma < _maRef ? #FF0000 : // RED
diffMA >= 0 and _ma < _maRef ? #008000 : // GREEN (진초록)
#808080
// [조건 1] ma05, ma10, ma15 세 선 모두 diffMA >= 0 및 _ma < _maRef(ma100) 조건 만족
cond_ma05 = ta.change(ma05) >= 0 and ma05 < ma100
cond_ma10 = ta.change(ma10) >= 0 and ma10 < ma100
cond_ma15 = ta.change(ma15) >= 0 and ma15 < ma100
madrid_cond = cond_ma05 and cond_ma10 and cond_ma15
// [돈치안 채널 계산]
donchian_upper = ta.highest(high, donchian_len)[1]
donchian_lower = ta.lowest(low, donchian_len)[1]
donchian_mid = (donchian_upper + donchian_lower) / 2
// [조건 2] 1봉전 기준 10봉 이내 저가(low)가 돈치안 하단선 터치/하회
touched_lower_10 = ta.lowest(low, 10)[1] <= donchian_lower[1]
// [조건 3] 0봉전(당일) 종가가 돈치안 채널 중앙선 상향 돌파
x_over_mid = ta.crossover(close, donchian_mid)
// ==========================================
// 3. 매수 신호 조건 (BUY Signal)
// ==========================================
buy_signal = madrid_cond and touched_lower_10 and x_over_mid
// ==========================================
// 4. 차트 표현 (Visuals)
// ==========================================
// 마드리드 리본
plot(ma05, color=maColor(ma05, ma100), style=plot.style_line, title="MMA05", linewidth=3)
plot(ma10, color=maColor(ma10, ma100), style=plot.style_line, title="MMA10", linewidth=1)
plot(ma15, color=maColor(ma15, ma100), style=plot.style_line, title="MMA15", linewidth=1)
plot(ma20, color=maColor(ma20, ma100), style=plot.style_line, title="MMA20", linewidth=1)
plot(ma25, color=maColor(ma25, ma100), style=plot.style_line, title="MMA25", linewidth=1)
plot(ma30, color=maColor(ma30, ma100), style=plot.style_line, title="MMA30", linewidth=1)
plot(ma35, color=maColor(ma35, ma100), style=plot.style_line, title="MMA35", linewidth=1)
plot(ma40, color=maColor(ma40, ma100), style=plot.style_line, title="MMA40", linewidth=1)
plot(ma45, color=maColor(ma45, ma100), style=plot.style_line, title="MMA45", linewidth=1)
plot(ma50, color=maColor(ma50, ma100), style=plot.style_line, title="MMA50", linewidth=1)
plot(ma55, color=maColor(ma55, ma100), style=plot.style_line, title="MMA55", linewidth=1)
plot(ma60, color=maColor(ma60, ma100), style=plot.style_line, title="MMA60", linewidth=1)
plot(ma65, color=maColor(ma65, ma100), style=plot.style_line, title="MMA65", linewidth=1)
plot(ma70, color=maColor(ma70, ma100), style=plot.style_line, title="MMA70", linewidth=1)
plot(ma75, color=maColor(ma75, ma100), style=plot.style_line, title="MMA75", linewidth=1)
plot(ma80, color=maColor(ma80, ma100), style=plot.style_line, title="MMA80", linewidth=1)
plot(ma85, color=maColor(ma85, ma100), style=plot.style_line, title="MMA85", linewidth=1)
plot(ma90, color=maColor(ma90, ma100), style=plot.style_line, title="MMA90", linewidth=3)
// [추가] 200 SMA 점선 표현
plot(show_sma200 ? sma200 : na, title="200 SMA", color=color_sma200, style=plot.style_circles, linewidth=3)
// 돈치안 채널
plot(donchian_upper, title="Donchian Upper", color=color.new(color.blue, 60), linewidth=1)
plot(donchian_lower, title="Donchian Lower", color=color.new(color.blue, 60), linewidth=1)
plot(donchian_mid, title="Donchian Mid (White Thick)", color=color.white, linewidth=3)
// BUY 신호 표출
plotshape(buy_signal, title="BUY Signal", style=shape.triangleup, location=location.belowbar, color=color.white, size=size.small, text="BUY", textcolor=color.white)
// ==========================================
// 5. 알림 설정 (Alerts)
// ==========================================
alertcondition(buy_signal, title="[BUY] 마드리드 단기라인 진초록 + 돈치안 중앙선 돌파", message="ma05, ma10, ma15 상승 반등(GREEN) + 10봉 이내 하단 터치 + 돈치안 중앙선 돌파")
답변 1
예스스탁 예스스탁 답변
2026-09-02 10:06:23