전략에 따른 이동 평균 크로스오버 트렌드

저자:차오장, 날짜: 2024-02-05 14:12:27
태그:

img

전반적인 설명

이동 평균 크로스오버 트렌드 다음 전략은 시장 트렌드를 추적하는 양적 거래 전략이다. 이 전략은 빠르고 느린 이동 평균을 계산하고 크로스오버가 발생하면 시장 트렌드의 전환점을 파악하여 거래 신호를 생성합니다.

전략 논리

이 전략의 핵심 원칙은 다른 매개 변수와 함께 기하급수적인 이동 평균 (EMA) 을 사용하여 시장 추세를 판단하는 것입니다. 전략은 빠른 EMA와 느린 EMA를 정의합니다. 빠른 EMA가 느린 EMA를 넘을 때 시장에서 상승 추세 반전을 나타냅니다. 빠른 EMA가 느린 EMA를 넘을 때 하향 추세 반전을 나타냅니다.

상향 크로스에서는 전략이 긴 포지션을 열고 하향 크로스에서는 전략이 짧은 포지션을 열고 수익을 취하거나 손실을 멈추기 전까지 포지션을 유지합니다. 또는 반대 방향으로 다시 크로스오버가 발생합니다.

이점 분석

이 전략은 다음과 같은 장점을 가지고 있습니다.

  1. 전략 논리는 간단하고 명확하고, 이해하기 쉽고 실행하기 쉽고, 초보자에도 적합합니다.
  2. EMA를 사용하여 가격을 매끄럽게 할 수 있다면 시장 소음을 효과적으로 필터링하고 동향을 식별 할 수 있습니다.
  3. 매개 변수들은 다양한 주기에 따른 시장에 적응하기 위해 유연하게 조정될 수 있습니다.
  4. 이 전략은 안정성을 높이기 위해 여러 시간 프레임 버전으로 확장 될 수 있습니다.

위험 분석

이 전략은 또한 몇 가지 위험을 안고 있습니다.

  1. 다양한 시장에서는 수익성에 영향을 미치는 여러 개의 스톱 손실이 발생할 수 있습니다.
  2. 이는 심각한 손실로 이어질 수 있는 트렌드 유형 (승향 또는 하락) 을 효과적으로 식별할 수 없습니다.
  3. 부적절한 EMA 매개 변수 설정으로 인해 거래가 너무 많거나 탐지 지연이 발생할 수 있습니다.

위험을 줄이기 위해 다른 지표를 결합하여 트렌드 유형을 결정하거나 더 넓은 스톱 로스 비율을 설정하는 것을 고려하십시오.

최적화 방향

이 전략은 다음 측면에서도 최적화 될 수 있습니다.

  1. 트렌드 유형에 대한 판단을 강화하여 트렌드에 반대하는 포지션을 개설하지 않도록 한다.
  2. 신호 품질을 향상시키기 위해 여러 시간 프레임 판단을 추가합니다.
  3. 동적으로 정지 손실을 조정하고 출구 포인트를 최적화하기 위해 수익 비율을 취하십시오.
  4. 다른 지표를 결합하여 잘못된 거래를 필터링합니다.

결론

요약하자면, 이동 평균 크로스오버 트렌드 다음 전략은 간단하고 실용적인 트렌드 트레이딩 전략이다. 전략의 핵심 아이디어는 명확하고 구현하기 쉽고 최적화에도 여지가 있습니다. 매개 변수를 조정하고, 멀티 타임프레임 분석, 동적 스톱 등을 추가함으로써 전략의 안정성과 수익성을 지속적으로 향상시킬 수 있습니다.


/*backtest
start: 2024-01-28 00:00:00
end: 2024-02-04 00:00:00
period: 5m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5
strategy('Zhukov trade', overlay=true, calc_on_every_tick=true, currency=currency.USD)

// INPUT:

// Options to enter fast and slow Exponential Moving Average (EMA) values
emaFast = input.int(title='Fast EMA', defval=10, minval=1, maxval=9999)
emaSlow = input.int(title='Slow EMA', defval=20, minval=1, maxval=9999)

// Option to select trade directions
tradeDirection = input.string(title='Trade Direction', options=['Long', 'Short', 'Both'], defval='Both')

// Options that configure the backtest date range
startDate = input(title='Start Date', defval=timestamp('01 Jan 2023 00:00'))
endDate = input(title='End Date', defval=timestamp('31 Dec 2030 23:59'))

// Set take profit and stop loss percentages
take_profit_percent = input(1.0, title ="Take Profit Percent") / 100.0
stop_loss_percent = input(1.0, title ="Stop Loss Percent") / 100.0

// CALCULATIONS:

// Use the built-in function to calculate two EMA lines
fastEMA = ta.ema(close, emaFast)
slowEMA = ta.ema(close, emaSlow)
emapos = ta.ema(close, 200)

// PLOT:

// Draw the EMA lines on the chart
plot(series=fastEMA, color=color.new(color.orange, 0), linewidth=2)
plot(series=slowEMA, color=color.new(color.blue, 0), linewidth=2)
plot(series=emapos, color=color.new(color.red, 0), linewidth=2)

// CONDITIONS:

// Check if the close time of the current bar falls inside the date range
inDateRange = true

// Translate input into trading conditions
longOK = tradeDirection == 'Long' or tradeDirection == 'Both'
shortOK = tradeDirection == 'Short' or tradeDirection == 'Both'

// Decide if we should go long or short using the built-in functions
longCondition = ta.crossover(fastEMA, slowEMA) and inDateRange
shortCondition = ta.crossunder(fastEMA, slowEMA) and inDateRange

// ORDERS:

// Submit entry (or reverse) orders
if longCondition and longOK
    strategy.entry(id='long', direction=strategy.long)

if shortCondition and shortOK
    strategy.entry(id='short', direction=strategy.short)

// Exit orders
if strategy.position_size > 0 and longOK
    strategy.exit(id='exit long', from_entry='long', limit=strategy.position_avg_price * (1 + take_profit_percent), stop=strategy.position_avg_price * (1 - stop_loss_percent))

if strategy.position_size < 0 and shortOK
    strategy.exit(id='exit short', from_entry='short', limit=strategy.position_avg_price * (1 - take_profit_percent), stop=strategy.position_avg_price * (1 + stop_loss_percent))


더 많은