Trading View
[TradingView] 15-2.PineScript 적용 사례(횡보 시장)
코딩 Play
2024. 1. 29. 20:56
2. 횡보 시장 (Range-bound Markets)
- 상황: 시장이 특정 가격 범위 내에서 움직이며 명확한 추세가 없는 경우.
- 스크립트 사례: 오실레이터(예: RSI, 스토캐스틱)를 사용한 전략.
- 적용: 과매수/과매도 지점을 감지하고, 가격이 범위의 상단이나 하단에 도달했을 때 반대 방향으로 거래합니다.
횡보 시장용 코드 예시: RSI 기반 전략
//@version=4
strategy("RSI Range-bound Strategy", shorttitle="RSI Range", overlay=false)
rsiLength = input(14, title="RSI Length")
overbought = input(70, title="Overbought Level")
oversold = input(30, title="Oversold Level")
rsiValue = rsi(close, rsiLength)
longCondition = rsiValue < oversold
shortCondition = rsiValue > overbought
if (longCondition)
strategy.entry("Long", strategy.long)
if (shortCondition)
strategy.close("Long")
plot(rsiValue, "RSI", color=color.purple)
hline(overbought, "Overbought", color=color.red)
hline(oversold, "Oversold", color=color.green)
