이 전략은 쌍평선 황금 포크 죽은 포크 원칙에 기초하여 설계되었다. 단기평선 상에 장기평선 상을 때, 더 많이 하고, 단기평선 밑에 장기평선 상을 할 때, 평점을 한다. 이 전략은 이해하기 쉽고, 초보자 학습에 적합하다.
이 전략은 주로 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)
이 전략의 원리는 간단하고 명확하며, 쌍평선형 황금 포크 사다리를 사용하여 판단하고, 약간의 트렌드 추적 능력을 가지고 있다.
이 전략은 다음과 같은 부분에서 최적화될 수 있습니다.
다양한 단기 및 장기 평균선 주기를 시도하여 최적의 조합을 찾을 수 있습니다. 예를 들어 (5, 10), (…, 10, 20), (…, 20, 60) 과 같은 파라미터 대조 테스트입니다.
수평선 교차시 거래량, 가격차별 등의 필터링 조건을 추가하여 불안정한 시장에서 과도한 거래를 방지할 수 있다.
스톱로스를 설정하거나 평균선을 스톱로스로 사용하면 단편 손실을 제어할 수 있다.
MACD, KDJ 등의 보조 지표와 결합하여 전략 효과를 높일 수 있다.
평균선 근처에서 더 좋은 입점들을 찾아, 평균선 가까이에서 포지션을 세우는 대신. 예를 들어, 평균선에서 벗어난 입점들.
쌍평선 전략의 개념은 간단하고 초보자가 쉽게 사용할 수 있다. 그러나 이 전략은 시장의 흔들림에 민감하며, 손실의 위험이 있다. 우리는 최적화 변수, 필터 조건의 추가, 중지 손실의 설정 및 기타 지표의 추가와 같은 방법으로 전략의 효과를 향상시킬 수 있다. 강한 추세에서 이 전략은 좋은 효과를 얻을 수 있다. 그러나 시장의 흔들림 기간에는 신중하게 사용하거나 중지 손실을 제어하는 것이 좋습니다.
||
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.
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.
The strategy can be optimized in the following aspects:
Test different short and long MA periods, such as (5, 10), (10, 20), (20, 60) etc to find the optimal combination.
Add filters like trading volume, price gap etc. near MA crossovers to avoid excessive trades in ranging markets.
Set stop loss price or use MA as stop loss line to control single trade loss.
Add auxiliary indicators like MACD, KDJ etc. to improve strategy performance.
Find better entry points near MAs instead of entering right at the crossover. For example, enter on MA divergence points.
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))