양평선 역전 전략


생성 날짜: 2023-09-21 16:40:01 마지막으로 수정됨: 2023-09-21 16:40:01
복사: 0 클릭수: 606
avatar of ChaoZhang ChaoZhang
1
집중하다
1617
수행원

개요

이 전략은 쌍평선 황금 포크 죽은 포크 원칙에 기초하여 설계되었다. 단기평선 상에 장기평선 상을 때, 더 많이 하고, 단기평선 밑에 장기평선 상을 할 때, 평점을 한다. 이 전략은 이해하기 쉽고, 초보자 학습에 적합하다.

전략 원칙

이 전략은 주로 sma ((close, 14) 와 sma ((close, 28) 두 개의 평균선 지표에 기초한다.

먼저, 길고 짧은 평균선을 정의해 봅시다.

short_ma = sma(close, 14)
long_ma = sma(close, 28)

그리고는 골든 포크의 판단에 따라 출전한다:

longCondition = crossover(short_ma, long_ma)
shortCondition = crossunder(short_ma, long_ma)

단기 평균선에서 장기 평균선을 착용할 때 더 많이 하세요.

strategy.entry("Buy", strategy.long, when = longCondition) 

단기 평균선 아래에서 장기 평균선을 통과할 때 평점:

strategy.close_all(when = shortCondition)

이 전략의 원리는 간단하고 명확하며, 쌍평선형 황금 포크 사다리를 사용하여 판단하고, 약간의 트렌드 추적 능력을 가지고 있다.

우위 분석

  • 이 전략은 이해하기 쉽고, 초보자들도 쉽게 사용할 수 있습니다.
  • 평균선에서 동그라미를 이용하여 동그라미를 판단하고, 동그라미를 추적할 수 있다.
  • 사용자 정의 평균주기, 최적화 정책 변수
  • 단위 손실을 제어하기 위해 스톱포트를 설정할 수 있습니다.

위험 분석

  • 이중 평행 전략은 시장의 변동에 민감하며 여러 손실 거래가 발생할 수 있습니다.
  • 평균선은 지연되어 있고 가격 전환점을 놓칠 수 있습니다.
  • 중간 지점 근처에 입장을 세우는 것은 감금될 수 있습니다.
  • 평균선 주기 변수를 최적화해야 하며, 다른 주기 효과에는 차이가 있을 수 있다.
  • 트렌드가 급격히 변할 때 빠르게 멈추지 않는 것

최적화 방향

이 전략은 다음과 같은 부분에서 최적화될 수 있습니다.

  1. 평균주기 변수를 최적화하여 최적의 변수 조합을 찾습니다.

다양한 단기 및 장기 평균선 주기를 시도하여 최적의 조합을 찾을 수 있습니다. 예를 들어 (5, 10), (…, 10, 20), (…, 20, 60) 과 같은 파라미터 대조 테스트입니다.

  1. 가짜 신호를 방지하기 위한 필터링 조건을 추가합니다.

수평선 교차시 거래량, 가격차별 등의 필터링 조건을 추가하여 불안정한 시장에서 과도한 거래를 방지할 수 있다.

  1. 더 많은 손실을 막는 전략

스톱로스를 설정하거나 평균선을 스톱로스로 사용하면 단편 손실을 제어할 수 있다.

  1. 다른 지표와 함께

MACD, KDJ 등의 보조 지표와 결합하여 전략 효과를 높일 수 있다.

  1. 최적화된 입점

평균선 근처에서 더 좋은 입점들을 찾아, 평균선 가까이에서 포지션을 세우는 대신. 예를 들어, 평균선에서 벗어난 입점들.

요약하다

쌍평선 전략의 개념은 간단하고 초보자가 쉽게 사용할 수 있다. 그러나 이 전략은 시장의 흔들림에 민감하며, 손실의 위험이 있다. 우리는 최적화 변수, 필터 조건의 추가, 중지 손실의 설정 및 기타 지표의 추가와 같은 방법으로 전략의 효과를 향상시킬 수 있다. 강한 추세에서 이 전략은 좋은 효과를 얻을 수 있다. 그러나 시장의 흔들림 기간에는 신중하게 사용하거나 중지 손실을 제어하는 것이 좋습니다.

||

Overview

This strategy is designed based on the golden cross and death cross of dual moving averages. It goes long when the short period moving average crosses above the long period moving average, and closes position when the short period moving average crosses below the long period moving average. The strategy is simple and easy to understand, suitable for beginners to learn.

Strategy Logic

The strategy is mainly based on the sma(close, 14) and sma(close, 28) indicators.

First define the short and long moving averages:

short_ma = sma(close, 14)  
long_ma = sma(close, 28)

Then determine entry and exit based on golden cross and death cross:

longCondition = crossover(short_ma, long_ma)
shortCondition = crossunder(short_ma, long_ma) 

Go long when the short MA crosses above the long MA:

strategy.entry("Buy", strategy.long, when = longCondition)

Close position when the short MA crosses below the long MA:

strategy.close_all(when = shortCondition) 

The logic is simple and clear, utilizing the crossovers of dual MAs to determine entries and exits. It has some trend following capacity.

Advantage Analysis

  • Simple logic, easy for beginners to use
  • Utilizes MA crossovers to determine trends
  • Customizable MA periods for parameter optimization
  • Allows stop loss to control single trade loss

Risk Analysis

  • Sensitive to market fluctuation, may generate multiple losing trades
  • Lagging nature of MAs, may miss price reversal points
  • Prone to being trapped near MA crossover points
  • Need to optimize MA periods, different periods may lead to different results
  • Unable to quickly cut loss when trend changes violently

Optimization Directions

The strategy can be optimized in the following aspects:

  1. Optimize MA periods to find the best combination

Test different short and long MA periods, such as (5, 10), (10, 20), (20, 60) etc to find the optimal combination.

  1. Add filters to avoid false signals

Add filters like trading volume, price gap etc. near MA crossovers to avoid excessive trades in ranging markets.

  1. Incorporate stop loss

Set stop loss price or use MA as stop loss line to control single trade loss.

  1. Combine with other indicators

Add auxiliary indicators like MACD, KDJ etc. to improve strategy performance.

  1. Optimize entry points

Find better entry points near MAs instead of entering right at the crossover. For example, enter on MA divergence points.

Summary

The dual MA strategy is simple for beginners to use. But it is sensitive to market fluctuations and has risks of losses. We can improve it by optimizing parameters, adding filters, incorporating stop loss, combining other indicators etc. It can perform well in strong trends but should be used with caution or proper stop loss in ranging markets.
[/trans]

전략 소스 코드
/*backtest
start: 2023-08-21 00:00:00
end: 2023-09-20 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Binance","currency":"BTC_USDT"}]
*/

//@version=2
// strategy("Tester", pyramiding = 50, default_qty_type = strategy.cash, default_qty_value = 20, initial_capital = 2000, commission_type = strategy.commission.percent, commission_value = 0.25)

minGainPercent = input(0.6)
gainMultiplier = minGainPercent * 0.01 + 1


longCondition = crossover(sma(close, 14), sma(close, 28))
shortCondition = crossunder(sma(close, 14), sma(close, 28))


avg_protection = input(1)
gain_protection = input(1)


strategy.entry("Buy", strategy.long, when = longCondition    and (avg_protection >= 1 ? (na(strategy.position_avg_price) ? true : close <= strategy.position_avg_price) : true))
strategy.close_all(when = shortCondition  and (gain_protection >=1 ? (close >= gainMultiplier * strategy.position_avg_price) : true))