
이 전략은 거래량과 가격 변화에 기반한 트렌드 추적 시스템으로, 순 거래량 흔들림 지표 ((NVO) 를 계산하여 시장의 방향을 예측한다. 이 전략은 여러 가지 이동 평균 유형을 결합한다 (EMA, WMA, SMA, HMA), 흔들림 지표와 EMA 중첩 라인의 위치 관계를 비교하여 시장의 흐름을 판단하고 적절한 시기에 거래한다. 이 전략에는 위험을 제어하고 이익을 잠금하기 위해 중단 및 중지 장치가 포함되어 있습니다.
전략의 핵심은 매일의 순 거래량 변동치를 계산하여 시장의 정서를 판단하는 것입니다. 구체적인 계산 단계는 다음과 같습니다:
거래 신호는 다음과 같은 규칙에 따라 생성됩니다.
위험 관리 제안:
신호 확인 메커니즘의 최적화:
위험 관리 최적화:
변수 최적화:
이 전략은 거래량과 가격 데이터를 종합적으로 분석하여 비교적 완전한 트렌드 추적 거래 시스템을 구축한다. 전략의 주요 특징은 여러 가지 기술 지표를 결합하고 유연한 변수 구성 옵션을 제공하는 것이다. 위험이 있음에도 불구하고 합리적인 위험 제어와 지속적인 최적화를 통해 전략은 실제 거래에서 안정적인 수익을 얻을 것으로 예상된다. 거래자는 실장에 사용하기 전에 충분한 피드백을 수행하고 특정 시장 상황에 따라 매개 변수를 적절하게 조정하는 것이 좋습니다.
/*backtest
start: 2024-02-25 00:00:00
end: 2025-02-22 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Binance","currency":"SOL_USDT"}]
*/
//@version=5
strategy("EMA-Based Net Volume Oscillator with Trend Change", shorttitle="NVO Trend Change", overlay=false, initial_capital=100000, default_qty_type=strategy.percent_of_equity, default_qty_value=100)
// Input parameters
maType = input.string("WMA", "Moving Average Type", options=["WMA", "EMA", "SMA", "HMA"])
maLength = input.int(21, "MA Length", minval=1)
emaOverlayLength = input.int(9, "EMA Overlay Length", minval=1)
oscillatorMultiplier = input.float(1.0, "Oscillator Multiplier", minval=0.1, step=0.1)
showHistogram = input.bool(true, "Show Histogram")
stopLossPerc = input.float(1.0, "Stop Loss (%)", tooltip="Set 999 to disable")
takeProfitPerc = input.float(2.0, "Take Profit (%)", tooltip="Set 999 to disable")
// Calculate Net Volume Oscillator
priceRange = high - low
multiplier = priceRange > 0 ? (close - low) / priceRange : 0.5
var float effectiveUpVol = 0.0
var float effectiveDownVol = 0.0
if close > close[1]
effectiveUpVol := volume * multiplier
effectiveDownVol := volume * (1 - multiplier)
else if close < close[1]
effectiveUpVol := volume * multiplier
effectiveDownVol := volume * (1 - multiplier)
else
effectiveUpVol := 0.0
effectiveDownVol := 0.0
netVolume = effectiveUpVol - effectiveDownVol
dailyNetOscillator = volume > 0 ? (netVolume / volume) * 100 : 0
// Apply selected Moving Average
var float oscillator = na
if maType == "WMA"
oscillator := ta.wma(dailyNetOscillator, maLength) * oscillatorMultiplier
else if maType == "EMA"
oscillator := ta.ema(dailyNetOscillator, maLength) * oscillatorMultiplier
else if maType == "SMA"
oscillator := ta.sma(dailyNetOscillator, maLength) * oscillatorMultiplier
else if maType == "HMA"
oscillator := ta.hma(dailyNetOscillator, maLength) * oscillatorMultiplier
// EMA Overlay
emaOverlay = ta.ema(oscillator, emaOverlayLength)
// Rate of Change (ROC) for Oscillator
roc = ta.roc(oscillator, 1) // 1-period rate of change
// Trading logic
longCondition = oscillator > emaOverlay
shortCondition = oscillator < emaOverlay
// Exit conditions
exitLong = oscillator < emaOverlay and strategy.position_size > 0
exitShort = oscillator > emaOverlay and strategy.position_size < 0
// Execute trades
if longCondition and strategy.position_size <= 0
strategy.entry("Long", strategy.long)
if exitLong
strategy.close("Long")
if shortCondition and strategy.position_size >= 0
strategy.entry("Short", strategy.short)
if exitShort
strategy.close("Short")
// Stop Loss and Take Profit
stopLossLong = stopLossPerc != 999 ? strategy.position_avg_price * (1 - stopLossPerc/100) : na
takeProfitLong = takeProfitPerc != 999 ? strategy.position_avg_price * (1 + takeProfitPerc/100) : na
stopLossShort = stopLossPerc != 999 ? strategy.position_avg_price * (1 + stopLossPerc/100) : na
takeProfitShort = takeProfitPerc != 999 ? strategy.position_avg_price * (1 - takeProfitPerc/100) : na
if (not na(stopLossLong) and not na(takeProfitLong) and strategy.position_size > 0)
strategy.exit("Long SL/TP", "Long", stop=stopLossLong, limit=takeProfitLong)
if (not na(stopLossShort) and not na(takeProfitShort) and strategy.position_size < 0)
strategy.exit("Short SL/TP", "Short", stop=stopLossShort, limit=takeProfitShort)
// Plotting
plot(oscillator, "Net Volume Oscillator", color.blue)
plot(emaOverlay, "EMA Overlay", color.orange)
hline(0, "Zero Line", color.gray)
// Histogram with Trend Change Visualization
var color histogramColor = na
if oscillator > 0
histogramColor := roc >= 0 ? color.new(color.green, 70) : color.new(color.lime, 70) // Green for bullish, light green for weakening
else if oscillator < 0
histogramColor := roc >= 0 ? color.new(color.red, 70) : color.new(color.maroon, 70) // Red for bearish, light red for weakening
plot(showHistogram ? oscillator : na, style=plot.style_histogram, color=histogramColor, title="Histogram")