
이 전략은 오마 지수와 아폴로 지수 두 가지의 주류 기술 지표를 결합하여 다중 공평 쌍로 거래를 구현한다. 그것의 기본 아이디어는 중장선 트렌드가 다중으로 판단될 때, 짧은 선의 가격 회귀 진입 기회를 찾고 다중을 구축하는 것이다. 중장선 트렌드가 공중으로 판단될 때, 짧은 선의 가격 반발 진입 기회를 찾고 공중을 구축하는 것이다.
이 전략은 50일, 200일 두 개의 이동 평균을 사용하여 중장선 트렌드를 판단합니다. 50일선은 200일선의 위에 있는 다단계 트렌드를 나타냅니다. 반대로, 공중선 트렌드를 나타냅니다.
다음으로, 이 전략은 오마 지표를 사용하여 단선 가격 반전의 기회를 찾습니다. 오마 지표는 %K 라인과 %D 라인을 포함하며, 각각 간단한 이동 평균 평준화를 거친 RSI 지표의 결과입니다. %K 라인이 초과 판매 영역에서 ((80보다 높다) 아래로%D 라인을 돌파 할 때, 가격이 초과 구매 상태에서 반동으로 넘어가는 것을 나타냅니다.
또한, 잘못된 보고의 기회를 더욱 필터링하기 위해, 이 전략은 아폴로 지표를 도입했다. 아폴로 지표는 K선%D 값의 극치점 정보를 보여준다. %K선이 새로운 낮은 지점을 형성할 때, 이는 반발력이 약하다는 것을 의미하며, 새로운 높은 지점을 형성할 때, 이는 반발력이 강하다는 것을 의미한다. 오마 지표의 신호와 결합하면, 이것은 진입의 정확성을 더욱 향상시킬 수 있다.
구체적으로, 다단계 트렌드에서, 이 전략은 오마 지표가 오버셀 지역 아래에서 다단계 기회가 형성될 때, 동시에 새로운 고점 정보를 검사하여 반발의 강도를 확인합니다. 공대 트렌드에서, 이 전략은 오마 지표가 오버 바이 지역 위에서 공대 기회가 형성될 때, 동시에 새로운 낮은 지점 정보를 검사하여 반발의 강도를 확인합니다.
위와 같은 과정을 통해, 이 전략은 중장선 트렌드 판단과 단선 반전 지표의 장점을 최대한 활용하여 안정적인 다중 공평 쌍용 트레이드 시스템을 구축한다.
이 전략은 트렌드 판단과 반전 지표를 결합하여 트렌드 트레이딩과 역동적인 트레이딩의 장점을 모두 고려하여 안정적인 혼합 트레이딩 프레임워크를 형성한다.
이중 지표 필터링을 통해 잘못된 통보 비율을 줄이고 신호의 신뢰도를 높일 수 있다.
전략의 매개 변수는 단순하고 이해하기 쉽고 최적화 할 수 있으며, 양적 거래에 적합합니다.
이 전략은 안정적으로 실행되며, 좋은 승률과 적자비율을 가지고 있다.
다중공간 이중철도 방식을 채택하여, 단일 방향에만 국한되지 않고 지속적으로 거래 기회를 얻을 수 있습니다.
역전적 전략으로, 추세가 변하면 연쇄적인 손실이 발생할 수 있습니다.
이 전략은 거래자의 감정 통제에 대한 요구가 높으며, 일정 비율의 인출을 감수해야 한다.
이동 평균 주기 등 일부 파라미터에는 어느 정도 주관성이 존재하며, 피드백 최적화를 통해 적절한 파라미터를 결정해야 한다.
오마 지표와 아폴로 지표는 모두 비정상적인 변동기에 민감하며, 극단적인 상황에서는 실패할 수 있다.
이 전략은 불안정한 시장 환경에 더 적합하며, 추세가 뚜렷한 상황에서 효과가 떨어질 수 있다.
이동 평균 주기를 적절히 조정하여 트렌드 필터를 도입하고, 스톱 스톱 전략을 추가하여 위험을 회피 할 수 있습니다. 시장이 명백한 추세에 들어갔을 때, 전략을 일시 중지하여 그 환경을 피하는 것을 고려 할 수 있습니다.
더 나은 변수 설정을 얻기 위해 다양한 변수 조합을 테스트하십시오. 예를 들어, EWMA 평탄한 이동 평균과 같은 지표를 시도 할 수 있습니다.
볼륨이나 BV와 같은 지표를 추가하여 오차를 판단하면 신호의 신뢰성을 더욱 검증할 수 있다.
VIX와 같은 공포 지수를 추가하여 감시 지표로, 시장의 공포가 있을 때 지위를 낮추십시오.
ATR 중지와 같은 동적 중지 방법을 사용하는 등 중지 중지 전략을 최적화하십시오.
기계 학습 알고리즘을 도입하여 매개 변수 설정을 동적으로 최적화한다.
다인자 모형을 추가하여 신호 품질을 향상시킵니다.
이 전략은 전반적으로 안정적이고 효율적인 양적 거래 전략이다. 이 전략은 트렌드 판단과 반전 지표, 오마 지표와 아폴로 지표의 이중 검증 방식을 결합하여 짧은 선의 가격 반전 기회를 효과적으로 발견할 수 있다. 트렌드 시스템이나 반전 시스템을 사용하는 것에 비해 이 전략의 형태는 더 안정적이며, 회수 제어도 우수하며, 권장되는 양적 거래 전략이다. 물론, 사용자는 또한 그 안에 존재하는 위험 지점을 주의해야 하며, 파라미터 최적화, 손해 중지, 환경 식별 등의 방법으로 위험을 제어하여 전략을 최적화한다.
/*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)