변경된 OBV 및 MACD 양적 거래 전략

저자:차오장, 날짜: 2023-11-15 17:58:42
태그:

img

전반적인 설명

이 전략은 거래 신호를 생성하기 위해 변화된 밸런스 볼륨 (OBV) 및 MACD를 사용합니다. 가격 지표 MACD와 변화된 OBV를 분량 및 가격의 포괄적 인 지표로 결합하여 가격과 부피가 강해지면 거래 기회를 포착하는 것을 목표로합니다.

전략 논리

  1. 단순한 이동 평균 (SMA) 을 계산하여 시장 트렌드를 결정합니다.

  2. 변경된 OBV를 계산합니다. OBV를 더 민감하게 만들기 위해 가까운 가격과 이전 가까운 가격 관계에 기반한 OBV 계산을 수정합니다.

  3. 변경된 OBV에서 MACD를 계산합니다. MACD는 볼륨 모멘텀 변화를 식별하기 위해 빠른 라인, 느린 라인 및 히스토그램으로 구성됩니다.

  4. MACD가 황금색을 넘어서고 상승하면 구매 신호가 생성됩니다.

  5. MACD가 저하가 되면 판매 신호가 발사됩니다.

  6. 트렌드 없는 시장에서 불필요한 거래를 피하기 위해 SMA를 확인하십시오.

이점 분석

  1. 변형된 OBV는 초기 부피 변화를 감지하는 데 더 민감합니다.

  2. MACD는 볼륨 동력 변화와 핵심 수준을 명확히 나타냅니다.

  3. 부피와 가격의 결합 신호는 정확도를 향상시킵니다.

  4. SMA는 시장 트렌드를 결정함으로써 잘못된 신호를 필터합니다.

  5. 명확한 전략 논리와 큰 최적화 공간

위험 분석

  1. 변경된 OBV는 잘못된 신호를 생성 할 수 있습니다. 다른 지표에 의해 필터 필요.

  2. MACD 매개 변수 설정이 잘못되면 거래가 잘못되거나 잘못된 신호가 발생할 수 있습니다.

  3. 손실을 피하기 위해 주식 세부 사항에 주의하십시오.

  4. 전략이 특별한 시나리오에서 작동하지 않을 수 있기 때문에 시장 상태를 모니터링하십시오.

  5. 백테스트의 과잉 리스크는 라이브 트레이딩에서 더 나쁜 성과로 이어질 수 있습니다.

최적화 방향

  1. 다른 SMA 기간 조합을 테스트하여 시장 트렌드 결정을 최적화합니다.

  2. 매크드 매개 변수를 테스트하여 볼륨 모멘텀 변화를 더 잘 식별합니다.

  3. KDJ, RSI 등과 같은 다른 지표를 필터로 추가합니다.

  4. 트레이드당 손해 제한에 스톱 로스를 추가합니다.

  5. 전체 수익성을 높이기 위해 자금 관리를 최적화하십시오.

  6. 주류들 간의 테스트 매개 변수 차이

결론

이 전략은 변화된 OBV와 MACD를 결합하여 볼륨과 가격 합성을 달성합니다. 볼륨 동력 변화를 일찍 포착하고 거래 신호를 생성 할 수 있습니다. OBV 또는 MACD만을 사용하는 것과 비교하면이 전략은 더 신뢰할 수있는 거래 기회를 제공합니다. 그러나 잘못된 신호 위험이 존재하며, 라이브 거래에서 안정적인 수익을 얻기 위해 지표와 매개 변수에 대한 추가 최적화와 돈 관리가 필요합니다. 전반적으로 전략은 명확한 논리를 가지고 있으며 잠재력을 탐구하기 위해 테스트하고 최적화 할 가치가 있습니다.


/*backtest
start: 2022-11-14 00:00:00
end: 2023-11-14 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © stocktechbot

//@version=5
strategy("Altered OBV On MACD", overlay=true, margin_long=100, margin_short=100)

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © stocktechbot
//@version=5
//SMA Tredline
out = ta.sma(close, 200)
outf = ta.sma(close, 50)
outn = ta.sma(close, 90)
outt = ta.sma(close, 21)
outthree = ta.sma(close, 9)
//sma plot
offset = input.int(title="Offset", defval=0, minval=-500, maxval=500)
plot(out, color=color.blue, title="MA200", offset=offset)
plot(outf, color=color.maroon, title="MA50", offset=offset)
plot(outn, color=color.orange, title="MA90", offset=offset)
plot(outt, color=color.olive, title="MA21", offset=offset)
plot(outthree, color=color.fuchsia, title="MA9", offset=offset)

fast_length = input(title="Fast Length", defval=12)
slow_length = input(title="Slow Length", defval=26)
chng = 0
obv = ta.cum(math.sign(ta.change(close)) * volume)
if close < close[1] and (open < close)
    chng := 1
else if close > close[1]
    chng := 1
else
    chng := -1
obvalt = ta.cum(math.sign(chng) * volume)
//src = input(title="Source", defval=close)
src = obvalt
signal_length = input.int(title="Signal Smoothing",  minval = 1, maxval = 50, defval = 9)
sma_source = input.string(title="Oscillator MA Type",  defval="EMA", options=["SMA", "EMA"])
sma_signal = input.string(title="Signal Line MA Type", defval="EMA", options=["SMA", "EMA"])

// Calculating
fast_ma = sma_source == "SMA" ? ta.sma(src, fast_length) : ta.ema(src, fast_length)
slow_ma = sma_source == "SMA" ? ta.sma(src, slow_length) : ta.ema(src, slow_length)
macd = fast_ma - slow_ma
signal = sma_signal == "SMA" ? ta.sma(macd, signal_length) : ta.ema(macd, signal_length)
hist = macd - signal
//hline(0, "Zero Line", color=color.new(#787B86, 50))
//plot(hist, title="Histogram", style=plot.style_columns, color=(hist>=0 ? (hist[1] < hist ? col_grow_above : col_fall_above) : (hist[1] < hist ? col_grow_below : col_fall_below)))
//plot(macd, title="MACD", color=col_macd)
//plot(signal, title="Signal", color=col_signal)
[macdLine, signalLine, histLine] = ta.macd(close, 12, 26, 9)
//BUY Signal
mafentry =ta.sma(close, 50) > ta.sma(close, 90)
//matentry = ta.sma(close, 21) > ta.sma(close, 50)
matwohun = close > ta.sma(close, 200)
twohunraise = ta.rising(out, 2)
twentyrise = ta.rising(outt, 2)
macdrise = ta.rising(macd,2)
macdlong = ta.crossover(macd, signal)
longCondition=false
if macdlong and macdrise
    longCondition := true

if (longCondition)
    strategy.entry("My Long Entry Id", strategy.long)
//Sell Signal
mafexit =ta.sma(close, 50) < ta.sma(close, 90)
matexit = ta.sma(close, 21) < ta.sma(close, 50)
matwohund = close < ta.sma(close, 200)
twohunfall = ta.falling(out, 3)
twentyfall = ta.falling(outt, 2)
shortmafall = ta.falling(outthree, 1)
macdfall = ta.falling(macd,1)
macdsell = macd < signal
shortCondition = false
if macdfall and macdsell and (macdLine < signalLine) and ta.falling(low,2)
    shortCondition := true


if (shortCondition)
    strategy.entry("My Short Entry Id", strategy.short)


더 많은