모멘텀 브레이크업 전략

저자:차오장, 날짜: 2023-12-13 17:08:53
태그:

img

전반적인 설명

이 전략은 이동 평균, 라구레 RSI 지표 및 ADX 지표를 결합하여 브레이크아웃 거래를 구현합니다. 빠른 이동 평균이 느린 이동 평균보다 높을 때, 라구레 RSI가 80보다 높고 ADX가 20보다 높을 때, 빠른 이동 평균이 느린 이동 평균보다 낮을 때, 라구레 RSI가 20보다 낮고 ADX가 20보다 높을 때 짧은 거리를 이동합니다. 이 전략은 시장의 추진력을 포착하고 트렌드 개발의 시작에서 시장에 진출합니다.

원칙

이 전략은 주로 다음의 지표를 사용하여 진동과 진입 시기를 결정합니다.

  1. 이동 평균 조합: 16일 EMA, 48일 EMA, 200일 SMA. 단기 평균이 장기 평균을 넘을 때 상승 추세와 그 아래를 넘을 때 하락 추세가 결정됩니다.

  2. 과잉 구매 및 과잉 판매 구역을 결정하기 위한 라구레 RSI 지표. 80 이상의 RSI는 긴 신호이고 20 이하는 짧은 신호입니다.

  3. 트렌드 상태를 결정하기 위한 ADX 지표입니다. ADX 20 이상은 브레이크아웃 거래에 적합한 트렌드를 나타냅니다.

엔트리 신호는 이동 평균 조합의 방향에 의해 결정되며, 엔트리 타이밍은 Laguerre RSI에 의해 결정되며, 트렌드가 아닌 시장은 ADX에 의해 필터링됩니다. 출구 신호는 이동 평균이 다시 교차 할 때 생성됩니다. 전반적인 전략 판단 프레임워크는 상당히 합리적입니다. 다른 지표가 함께 일하면서 긴 / 짧은 엔트리와 출구를 결정합니다.

강점

이 전략의 장점은 다음과 같습니다.

  1. 트렌드 모멘텀을 포착: 전략은 트렌드 개발의 시작에서 시장에 진출하여 트렌드에서 기하급수적 이익을 포착합니다.

  2. 제한적 인 손실: 적절하게 설정 된 중지 손실은 개별 거래의 손실을 제한합니다. 손실 거래조차도 이익을 얻을 수있는 기회가 있습니다.

  3. 정확한 조합 지표: 이동 평균, Laguerre RSI 및 ADX는 시장 방향과 진입 시기를 비교적 정확하게 결정할 수 있습니다.

  4. 간단한 실행: 전략은 3가지 지표만을 사용하며 이해하기 쉽고 실행하기 쉽습니다.

위험성

이 전략에는 몇 가지 위험도 있습니다.

  1. 트렌드 역전 위험: 트렌드 추종 전략으로서, 트렌드 역전이 제때 감지되지 않으면 큰 손실이 발생할 수 있습니다.

  2. 마감 위험: 다양한 시장에서 계정 마감으로 이어지는 스톱이 발생할 수 있습니다.

  3. 매개 변수 최적화 위험: 실패를 피하기 위해 다른 시장에 대한 지표 매개 변수를 조정해야합니다.

대책:

  1. 단일 거래 손실 금액을 제한하기 위해 엄격한 스톱 손실.

  2. 지표 매개 변수와 돌출 기준을 최적화해야 합니다.

  3. 유출을 관리하기 위해 선물 헤지 등을 사용하십시오.

최적화 방향

전략을 최적화하는 몇 가지 방법은 다음과 같습니다.

  1. 매개 변수 최적화: 이동 평균 기간, 라구레 RSI 매개 변수, ADX 매개 변수 조합을 테스트하여 최적의 설정을 찾습니다.

  2. 브레이크아웃 최적화: 다른 이동 평균 브레이크아웃 문턱을 테스트하여 거래 빈도와 수익성을 균형 잡습니다.

  3. 입력 최적화: 더 정확한 입력 시기를 위해 Laguerre RSI와 결합한 다른 지표를 테스트하십시오.

  4. 출구 최적화: 이동 평균과 결합하여 다른 출구 신호를 조사합니다.

  5. 이익 취득 대 손해 중지 최적화: 수익을 최적화하기 위해 다른 전략을 테스트합니다.

요약

요약하자면, 이 전략은 유동 평균, 라구에르 RSI 및 ADX의 조합을 사용하여 진입 및 출구를 결정함으로써 트렌드 움직임을 효과적으로 포착합니다. 트렌드 발전에 일찍 들어가 트렌드 러닝을 자세히 따라, 기하급수적 이윤을 얻을 수 있으며, 스톱 손실은 손실을 제한하는 데 도움이됩니다. 이 전략은 시장 판단을 편안하게하는 투자자와 매개 변수 최적화 후 자동화 된 거래를하는 사람들에게 적합합니다. 전반적으로 전략은 강력한 실용적 유용성을 가지고 있습니다.


/*backtest
start: 2023-12-05 00:00:00
end: 2023-12-12 00:00:00
period: 1m
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("3MA + Laguerre RSI + ADX [Pt]", shorttitle = "3MA+LaRSI+ADX[Pt]", 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)
use_entry_sess = input.bool(false, 'Use Entry Session Window', group = "Trading Session")
t1_session = input("0930-1555:23456", "Entry Session", group="Trading Session", tooltip = "Entry Signal only generated within this period.") 
t1 = time(timeframe.period, t1_session)
window = true

margin_req = input.float(1, title="Margin Requirement / Leverage", step=0.1, group = "Trading Options")
qty_per_trade = input.float(100, title = "% of initial capital per trade", group = "Trading Options")
reinvest = input.bool(defval=false,title="Reinvest profit", group = "Trading Options")
reinvest_percent = input.float(defval=100, title = "Reinvest percentage", group="Trading Options")

close_eod = input.bool(false, "All trades will close at the close of trading window", group = "Trading Options")
close_b4_open = input.bool(false, "Position must hit either SL/PT before entering new trade", group = "Trading Options")

profit = strategy.netprofit 
strategy.initial_capital = 50000
float trade_amount = math.floor(strategy.initial_capital*margin_req / close) 

if strategy.netprofit > 0 and reinvest
    trade_amount := math.floor((strategy.initial_capital* (qty_per_trade/100)+(profit*reinvest_percent*0.01))*margin_req/ close) 
else
    trade_amount := math.floor(strategy.initial_capital* (qty_per_trade/100)*margin_req / close)  

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

group_ma = "Moving Average Ribbon"
group_larsi = "Laguerre RSI"
group_adx = "ADX"
group_SL = "Stop Loss / Profit Target"

// ----------------------------------------- MA Ribbon -------------------------------------

ema1_len = input.int(16, "Fast EMA Length", group = group_ma)
ema2_len = input.int(48, "Slow EMA Length ", group = group_ma)
sma1_len = input.int(200, "Slow SMA Length", group = group_ma)

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

plot(ema1, "EMA 1", color.white, linewidth = 2)
plot(ema2, "EMA 2", color.yellow, linewidth = 2)
plot(sma1, "SMA 1", color.purple, linewidth = 2)

ma_bull = ema1 > ema2 and ema2 > sma1   
ma_bear = ema1 < ema2 and ema2 < sma1

// ------------------------------------------ Laguerre RSI ---------------------------------------

alpha = input.float(0.2, title='Alpha', minval=0, maxval=1, step=0.1, group = group_larsi)

gamma = 1 - alpha
L0 = 0.0
L0 := (1 - gamma) * close + gamma * nz(L0[1])
L1 = 0.0
L1 := -gamma * L0 + nz(L0[1]) + gamma * nz(L1[1])

L2 = 0.0
L2 := -gamma * L1 + nz(L1[1]) + gamma * nz(L2[1])

L3 = 0.0
L3 := -gamma * L2 + nz(L2[1]) + gamma * nz(L3[1])

cu = (L0 > L1 ? L0 - L1 : 0) + (L1 > L2 ? L1 - L2 : 0) + (L2 > L3 ? L2 - L3 : 0)

cd = (L0 < L1 ? L1 - L0 : 0) + (L1 < L2 ? L2 - L1 : 0) + (L2 < L3 ? L3 - L2 : 0)

temp = cu + cd == 0 ? -1 : cu + cd
LaRSI = temp == -1 ? 0 : cu / temp
LaRSI := LaRSI * 100

bull_LaRSI = LaRSI > 80
bear_LaRSI = LaRSI < 20

// --------------------------------------- ADX  ------------------------

adxlen = input(14, title="ADX Smoothing", group = group_adx)
dilen = input(14, title="DI Length", group = group_adx)
dirmov(len) =>
	up = ta.change(high)
	down = -ta.change(low)
	plusDM = na(up) ? na : (up > down and up > 0 ? up : 0)
	minusDM = na(down) ? na : (down > up and down > 0 ? down : 0)
	truerange = ta.rma(ta.tr, len)
	plus = fixnan(100 * ta.rma(plusDM, len) / truerange)
	minus = fixnan(100 * ta.rma(minusDM, len) / truerange)
	[plus, minus]
adx(dilen, adxlen) =>
	[plus, minus] = dirmov(dilen)
	sum = plus + minus
	adx = 100 * ta.rma(math.abs(plus - minus) / (sum == 0 ? 1 : sum), adxlen)
sig = adx(dilen, adxlen)

active_adx = sig > 20 //and sig > sig[1]

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

use_SLPT = input.bool(false, 'Use Fixed SL / PT', group = group_SL)
SL = input.float(50, 'Stop loss in ticks', step = 1, group = group_SL) * syminfo.mintick
PT = input.float(100, "Profit target in ticks", step = 1, group = group_SL) * syminfo.mintick

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

if strategy.position_size > 0
    L_SL := L_SL[1]
    L_PT := L_PT[1]
else if strategy.position_size < 0
    S_SL := S_SL[1]
    S_PT := S_PT[1]
else
    L_SL := close - SL
    L_PT := close + PT
    S_SL := close + SL
    S_PT := close - PT

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

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

L_SL_line = plot(use_SLPT and strategy.position_size > 0 ? L_SL : na, "L SL", color.red, linewidth = 2, style = plot.style_linebr)
S_SL_line = plot(use_SLPT and strategy.position_size < 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 ------------------------------------------------------

L_entry1 = ma_bull and bull_LaRSI and active_adx
S_entry1 = ma_bear and bear_LaRSI and active_adx

L_exit1 = ta.crossunder(ema1, ema2)
S_exit1 = ta.crossover(ema1, ema2)

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

if L_entry1 and (use_entry_sess ? window : true) and (close_b4_open ? strategy.position_size == 0 : true)
    strategy.entry("Long", strategy.long, trade_amount)

if S_entry1 and (use_entry_sess ? window : true) and (close_b4_open ? strategy.position_size == 0 : true)
    strategy.entry("Short", strategy.short, trade_amount)

if use_SLPT
    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")
else
    if L_exit1
        strategy.close("Long", comment = "Exit Long")

    if S_exit1
        strategy.close("Short", comment = "Exit Short")

if use_entry_sess and not window and close_eod
    strategy.close_all(comment = "EOD close")


더 많은