오마와 아폴로 듀얼 레일 무역 전략

저자:차오장, 날짜: 2023-11-02 17:09:35
태그:

img

전반적인 설명

이 전략은 두 가지 주요 기술 지표: 오마 지표와 아폴로 지표를 결합하여 긴 포지션과 짧은 포지션의 듀얼 레일 거래를 구현합니다. 중장기 트렌드가 상승 추세로 판단되면 짧은 포지션을 설정하기 위해 단기 복귀 기회를 찾는 것이 기본 아이디어입니다. 중장기 트렌드가 하락 추세로 판단되면 짧은 포지션을 설정하기 위해 단기 리바운드에서 기회를 찾습니다.

전략 원칙

이 전략은 중장기 트렌드를 결정하기 위해 50일 및 200일 이동 평균을 사용합니다. 200일 라인 위의 50일 라인은 상승 추세를 나타냅니다.

다음으로, 전략은 오마 지표를 사용하여 단기 가격 반전 기회를 찾습니다. 오마 지표에는 간단한 이동 평균에 의해 평평화 된 RSI 지표의 결과인 %K 및 %D 라인이 포함되어 있습니다. %K가 과소매 영역 (80 이상) 에서 %D 이하로 떨어지면 가격이 과소매 상태에서 아래로 회전하고 있음을 나타냅니다.

또한, 더 이상 잘못된 신호를 필터하기 위해, 이 전략은 또한 아폴로 지표를 포함합니다. 아폴로 지표는 K 선의 %D 값의 극한점을 표시합니다. %K가 새로운 최저치를 형성하면 반향 힘이 상대적으로 약하다는 것을 의미합니다. 새로운 최고치를 형성하면 반향 힘이 상대적으로 강하다는 것을 의미합니다. 오마 지표의 신호와 결합하면, 이것은 진입의 정확성을 더욱 향상시킬 수 있습니다.

특히, 상승 추세에서, 이 전략은 오마 지표가 오버바운드 영역 아래의 기회를 보여주면서 동시에 새로운 높은 포인트 정보를 확인하여 반등의 힘을 확인합니다. 하락 추세에서, 오마 지표가 오버바운드 영역에서 위를 넘나드는 짧은 기회를 보여주면, 이 전략은 리바운드 힘의 약화를 확인하기 위해 동시에 새로운 낮은 포인트 정보를 확인합니다.

위의 과정을 통해 이 전략은 중장기 트렌드 판단과 단기 반전 지표의 장점을 최대한 활용하여 안정적인 이중 철도 거래 시스템을 구축합니다.

전략 의 장점

  1. 이 전략은 트렌드 트레이딩과 역트렌드 트레이딩을 결합하여 트렌드 판단과 역전 지표를 모두 사용하여 안정적인 하이브리드 트레이딩 프레임워크를 형성합니다.

  2. 이중 표시기 필터링을 통해 잘못된 신호 비율을 줄이고 신호의 신뢰성을 향상시킬 수 있습니다.

  3. 전략 매개 변수는 비교적 간단하고 이해하기 쉽고 최적화 가능하며 양적 거래에 적합합니다.

  4. 이 전략의 성과는 견고하고 좋은 승률과 위험/이익 비율이 특징입니다.

  5. 길고 짧은 두 개의 철도를 채택함으로써 단일 방향으로 제한되지 않고 지속적으로 거래 기회를 얻을 수 있습니다.

전략 의 위험

  1. 역전 전략으로서, 추세가 변할 때 연속적인 손실이 발생할 수 있습니다.

  2. 이 전략은 상대적으로 높은 감정적 통제를 필요로 합니다. 거래자가 어느 정도의 마감에 견딜 수 있어야 합니다.

  3. 이동 평균 기간과 같은 일부 매개 변수는 특정 주관성을 포함하고 백테스팅과 최적화를 통해 결정해야합니다.

  4. 오마와 아폴로 두 지표 모두 비정상적인 변동에 민감하고 극단적인 시장 조건에서 실패 할 수 있습니다.

  5. 이 전략은 범위에 따른 변동성 시장에 더 적합하며, 강한 트렌드 시장에서 성과가 떨어질 수 있습니다.

위험은 트렌드 필터링을 도입하기 위해 이동 평균 기간을 적절히 조정하고 스톱 로스/프로피트 취득을 추가하여 위험을 완화 할 수 있습니다. 시장이 강하게 트렌드가 될 때 그 환경에서 거래를 피하기 위해 전략을 중단하는 것을 고려하십시오.

최적화 방향

  1. 다른 매개 변수 조합을 테스트하여 더 나은 매개 변수 설정을 얻으려면, 예를 들어 EWMA 평형 이동 평균을 사용합니다.

  2. 신호 신뢰성을 확인하는 데 도움이 될 수 있는 분리를 판단하기 위해 부피 또는 BV 지표를 추가합니다.

  3. VIX와 같은 변동성 지수를 모니터링 지표로 추가하면 시장이 공황에 빠졌을 때 포지션 크기를 줄일 수 있습니다.

  4. 동적 ATR 스톱 로스를 채택하는 것과 같은 스톱 로스/이익 취득 전략을 최적화합니다.

  5. 매개 변수 설정을 동적으로 최적화하는 기계 학습 알고리즘을 도입합니다.

  6. 신호 품질을 향상시키기 위해 다중 요소 모델을 추가합니다.

요약

전체적으로, 이것은 안정적이고 효율적인 양적 거래 전략이다. 트렌드 판단과 역전 지표를 결합하고, 오마와 아폴로 지표를 사용하여 이중 검증을 채택하여 단기 가격 역전 기회를 효과적으로 발견할 수 있다. 순전히 트렌드 또는 역전 시스템을 사용하는 것과 비교하면, 이 전략 형태는 우수한 유출 통제와 함께 더 견고하며, 권장되는 양적 거래 전략이다. 물론, 사용자는 또한 관련 위험에 대해 인식해야 하며, 위험을 제어하고 최상의 성과를 달성하기 위해 매개 변수 최적화, 스톱 로스/프로프트 취득, 시장 체제 식별 등을 사용해야 한다.


/*backtest
start: 2023-10-25 00:00:00
end: 2023-10-28 00:00:00
period: 5m
basePeriod: 1m
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/
// © PtGambler

//@version=5
strategy("2 EMA + Stoch RSI + ATR [Pt]", shorttitle = "2EMA+Stoch+ATR", overlay=true, initial_capital = 10000, default_qty_type = strategy.percent_of_equity, default_qty_value = 100, calc_on_order_fills = false, max_bars_back = 500)

// ********************************** Trade Period / Strategy Setting **************************************
startY = input(title='Start Year', defval=2011, group = "Backtesting window")
startM = input.int(title='Start Month', defval=1, minval=1, maxval=12, group = "Backtesting window")
startD = input.int(title='Start Day', defval=1, minval=1, maxval=31, group = "Backtesting window")
finishY = input(title='Finish Year', defval=2050, group = "Backtesting window")
finishM = input.int(title='Finish Month', defval=12, minval=1, maxval=12, group = "Backtesting window")
finishD = input.int(title='Finish Day', defval=31, minval=1, maxval=31, group = "Backtesting window")
timestart = timestamp(startY, startM, startD, 00, 00)
timefinish = timestamp(finishY, finishM, finishD, 23, 59)

// ******************************************************************************************

group_ema = "EMA"
group_stoch = "Stochastic RSI"
group_atr = "ATR Stoploss Finder"

// ----------------------------------------- 2 EMA -------------------------------------

ema1_len = input.int(50, "EMA Length 1", group = group_ema)
ema2_len = input.int(200, "EMA Length 2", group = group_ema)

ema1 = ta.ema(close, ema1_len)
ema2 = ta.ema(close, ema2_len)

plot(ema1, "ema1", color.white, linewidth = 2)
plot(ema2, "ema2", color.orange, linewidth = 2)

ema_bull = ema1 > ema2
ema_bear = ema1 < ema2


// -------------------------------------- Stochastic RSI -----------------------------

smoothK = input.int(3, "K", minval=1, group = group_stoch)
smoothD = input.int(3, "D", minval=1, group = group_stoch)
lengthRSI = input.int(14, "RSI Length", minval=1, group = group_stoch)
lengthStoch = input.int(14, "Stochastic Length", minval=1, group = group_stoch)
src = close
rsi1 = ta.rsi(src, lengthRSI)
k = ta.sma(ta.stoch(rsi1, rsi1, rsi1, lengthStoch), smoothK)
d = ta.sma(k, smoothD)

var trigger_stoch_OB = k > 80
var trigger_stoch_OS = k < 20

stoch_crossdown = ta.crossunder(k, d)
stoch_crossup = ta.crossover(k, d)

P_hi = ta.pivothigh(k,1,1)
P_lo = ta.pivotlow(k,1,1)

previous_high = ta.valuewhen(P_hi, k, 1)
previous_low = ta.valuewhen(P_lo, k, 1)
recent_high = ta.valuewhen(P_hi, k, 0)
recent_low = ta.valuewhen(P_lo, k, 0)

// --------------------------------------- ATR stop loss finder ------------------------

length = input.int(title='Length', defval=14, minval=1, group = group_atr)
smoothing = input.string(title='Smoothing', defval='EMA', options=['RMA', 'SMA', 'EMA', 'WMA'], group = group_atr)
m = input.float(0.7, 'Multiplier', step = 0.1, group = group_atr)
src1 = input(high, "Source for upper band", group = group_atr)
src2 = input(low, "Source for lower band", group = group_atr)

showatr = input.bool(true, 'Show ATR Bands', group = group_atr)
collong = input.color(color.purple, 'Long ATR SL', inline='1', group = group_atr)
colshort = input.color(color.purple, 'Short ATR SL', inline='2', group = group_atr)

ma_function(source, length) =>
    if smoothing == 'RMA'
        ta.rma(source, length)
    else
        if smoothing == 'SMA'
            ta.sma(source, length)
        else
            if smoothing == 'EMA'
                ta.ema(source, length)
            else
                ta.wma(source, length)

a = ma_function(ta.tr(true), length) * m
up = ma_function(ta.tr(true), length) * m + src1
down = src2 - ma_function(ta.tr(true), length) * m

p1 = plot(showatr ? up : na, title='ATR Short Stop Loss', color=colshort)
p2 = plot(showatr ? down : na, title='ATR Long Stop Loss', color=collong)

// ******************************* Profit Target / Stop Loss *********************************************

RR = input.float(2.0, "Reward to Risk ratio (X times SL)", step = 0.1, group = "Profit Target")

var L_PT = 0.0
var S_PT = 0.0
var L_SL = 0.0
var S_SL = 0.0

BSLE = ta.barssince(strategy.opentrades.entry_bar_index(0) == bar_index)

if strategy.position_size > 0 and BSLE == 1
    L_PT := close + (close-down)*RR
    L_SL := L_SL[1]
    S_PT := close - (up - close)*RR
    S_SL := up
else if strategy.position_size < 0 and BSLE == 1
    S_PT := close - (up - close)*RR
    S_SL := S_SL[1]
    L_PT := close + (close-down)*RR
    L_SL := down
else if strategy.position_size != 0
    L_PT := L_PT[1] 
    S_PT := S_PT[1]
else
    L_PT := close + (close-down)*RR
    L_SL := down
    S_PT := close - (up - close)*RR
    S_SL := up

entry_line = plot(strategy.position_size != 0 ? strategy.opentrades.entry_price(0) : na, "Entry Price", color.white, linewidth = 1, style = plot.style_linebr)

L_PT_line = plot(strategy.position_size > 0 and BSLE > 0 ? L_PT : na, "L PT", color.green, linewidth = 2, style = plot.style_linebr)
S_PT_line = plot(strategy.position_size < 0 and BSLE > 0 ? S_PT : na, "S PT", color.green, linewidth = 2, style = plot.style_linebr)

L_SL_line = plot(strategy.position_size > 0 and BSLE > 0 ? L_SL : na, "L SL", color.red, linewidth = 2, style = plot.style_linebr)
S_SL_line = plot(strategy.position_size < 0 and BSLE > 0 ? S_SL : na, "S SL", color.red, linewidth = 2, style = plot.style_linebr)

fill(L_PT_line, entry_line, color = color.new(color.green,90))
fill(S_PT_line, entry_line, color = color.new(color.green,90))
fill(L_SL_line, entry_line, color = color.new(color.red,90))
fill(S_SL_line, entry_line, color = color.new(color.red,90))


// ---------------------------------- strategy setup ------------------------------------------------------

var L_entry_trigger1 = false
var S_entry_trigger1 = false

L_entry_trigger1 := ema_bull and close < ema1 and k < 20 and strategy.position_size == 0
S_entry_trigger1 := ema_bear and close > ema1 and k > 80 and strategy.position_size == 0

L_entry1 = L_entry_trigger1[1] and stoch_crossup and recent_low > previous_low
S_entry1 = S_entry_trigger1[1] and stoch_crossdown and recent_high < previous_high

//debugging
plot(L_entry_trigger1[1]?1:0, "L Entry Trigger")
plot(stoch_crossup?1:0, "Stoch Cross Up")
plot(recent_low > previous_low?1:0, "Higher low")

plot(S_entry_trigger1[1]?1:0, "S Entry Trigger")
plot(stoch_crossdown?1:0, "Stoch Cross down")
plot(recent_high < previous_high?1:0, "Lower high")

if L_entry1
    strategy.entry("Long", strategy.long)

if S_entry1
    strategy.entry("Short", strategy.short)

strategy.exit("Exit Long", "Long", limit = L_PT, stop = L_SL, comment_profit = "Exit Long, PT hit", comment_loss = "Exit Long, SL hit")
strategy.exit("Exit Short", "Short", limit = S_PT, stop = S_SL, comment_profit = "Exit Short, PT hit", comment_loss = "Exit Short, SL hit")

//resetting triggers
L_entry_trigger1 := L_entry_trigger1[1] ? L_entry1 or ema_bear or S_entry1 ? false : true : L_entry_trigger1
S_entry_trigger1 := S_entry_trigger1[1] ? S_entry1 or ema_bull or L_entry1 ? false : true : S_entry_trigger1

//Trigger zones
bgcolor(L_entry_trigger1 ? color.new(color.green ,90) : na)
bgcolor(S_entry_trigger1 ? color.new(color.red,90) : na)

더 많은