OPEN-SOURCE SCRIPT

TSLA Scalping Signals (Volume + RSI + MACD + VWAP)

93
//version=5
indicator("TSLA Scalping Signals (Volume + RSI + MACD + VWAP)", overlay=true, timeframe="", timeframe_gaps=true)

// =========================
// 사용자 입력(파라미터)
// =========================
// RSI 길이와 과매도/과매수 기준
rsiLen = input.int(5, "RSI 길이", minval=2)
rsiLow = input.int(35, "RSI 과매도 기준", minval=5, maxval=50)
rsiHigh = input.int(70, "RSI 과매수 기준", minval=50, maxval=95)

// MACD 파라미터
fastLen = input.int(12, "MACD Fast", minval=1)
slowLen = input.int(26, "MACD Slow", minval=2)
sigLen = input.int(9, "MACD Signal", minval=1)

// 거래량 스파이크 판단용
volSmaLen = input.int(20, "거래량 SMA 길이", minval=5)
volSpikeMult = input.float(1.5, "거래량 스파이크 배수", minval=0.5, step=0.1)

// 손절/익절(선택)
useStops = input.bool(true, "손절/익절 사용")
stopATRlen = input.int(14, "ATR 길이", minval=5)
stopATRmult = input.float(1.2, "손절 ATR 배수", minval=0.5, step=0.1)
tpRR = input.float(1.5, "익절 R 비율(손절의 배수)", minval=0.5, step=0.1)

// =========================
// 지표 계산부
// =========================
// VWAP: 단타 기준 핵심 추세선
vwap = ta.vwap(close)

// RSI(단기)
rsi = ta.rsi(close, rsiLen)

// MACD
macd = ta.ema(close, fastLen) - ta.ema(close, slowLen)
sig = ta.ema(macd, sigLen)
hist = macd - sig

// 거래량 스파이크: 현재 거래량이 거래량 SMA * 배수 이상인지
volSma = ta.sma(volume, volSmaLen)
volSpike = volume > volSma * volSpikeMult

// =========================
// 진입/청산 조건
// =========================
// 롱 진입 조건:
// 1) 가격 VWAP 위
// 2) MACD 상향 교차
// 3) RSI가 rsiLow 아래→위로 돌파
// 4) 거래량 스파이크
longCond = close > vwap and ta.crossover(macd, sig) and ta.crossover(rsi, rsiLow) and volSpike

// 롱 청산 조건(부분 청산/전체 청산 판단은 사용자 재량):
// A) RSI 과매수 도달, 또는
// B) MACD 하향 교차, 또는
// C) 가격이 VWAP 아래로 종가 이탈하면서 거래량 약화(현재 거래량 < volSma)
exitCond = (rsi > rsiHigh) or ta.crossunder(macd, sig) or (close < vwap and volume < volSma)

// =========================
// 시각적 표시
// =========================
plot(vwap, "VWAP", linewidth=2)
plotshape(longCond, title="BUY", style=shape.labelup, text="BUY", location=location.belowbar, size=size.tiny)
plotshape(exitCond, title="SELL", style=shape.labeldown, text="SELL", location=location.abovebar, size=size.tiny)

// 보조 하단창: RSI, MACD는 별도 패널이 일반적이므로 값만 툴팁용 표시
// (원하면 아래 plot들을 꺼도 됨)
rsiPlot = plot(rsi, title="RSI(단기)", color=color.new(color.blue, 0), display=display.none)
h1 = hline(rsiLow, "RSI 과매도", color=color.new(color.teal, 50))
h2 = hline(rsiHigh, "RSI 과매수", color=color.new(color.red, 50))

// =========================
// 간단 손절/익절 레벨(선택)
// =========================
// 매수 발생 바의 가격을 기준으로 ATR 손절/익절 레벨 산출
atr = ta.atr(stopATRlen)
var float entryPrice = na
var float stopPrice = na
var float takePrice = na

// 롱 진입 시 가격 고정
if (longCond)
entryPrice := close
stopPrice := useStops ? (close - atr * stopATRmult) : na
takePrice := useStops ? (close + (close - stopPrice) * tpRR) : na

// 청산 신호 시 초기화
if (exitCond)
entryPrice := na
stopPrice := na
takePrice := na

plot(entryPrice, "Entry", color=color.new(color.green, 60), style=plot.style_circles, linewidth=2)
plot(stopPrice, "Stop", color=color.new(color.red, 60), style=plot.style_linebr, linewidth=2)
plot(takePrice, "Take", color=color.new(color.blue, 60), style=plot.style_linebr, linewidth=2)

// =========================
// 알림 조건
// =========================
alertcondition(longCond, title="BUY Signal", message="BUY signal: VWAP↑, MACD cross↑, RSI cross↑, Volume spike.")
alertcondition(exitCond, title="SELL Signal", message="SELL signal: RSI high or MACD cross↓ or below VWAP with weak volume.")

Clause de non-responsabilité

Les informations et les publications ne sont pas destinées à être, et ne constituent pas, des conseils ou des recommandations en matière de finance, d'investissement, de trading ou d'autres types de conseils fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.