SMA, EMA 및 볼륨에 기초한 간단한 모멘텀 전략

저자:차오장, 날짜: 2023-12-08 11:15:30
태그:

img

전반적인 설명

이것은 단순한 내일 모멘텀 전략으로, 단축하지 않고 길게 진행됩니다. 가격과 모멘텀이 상승하는 최적의 시점에 시장에 진입하려고 SMA, EMA 및 볼륨 지표를 사용합니다. 그것의 장점은 트렌드 인식 기능이있는 동안 간단하다는 것입니다.

전략 원칙

엔트리 신호 로직은: SMA가 EMA보다 높고, 중간 바의 가장 낮은 가격이 시작 상승 트렌드 바의 오픈 가격보다 높고, 연속적인 3 바 또는 4 바 상승 트렌드 패턴이있을 때 엔트리 신호가 생성됩니다.

출구 신호 논리는: SMA가 EMA 아래를 넘으면 출구 신호가 생성됩니다.

이 전략은 단지 길고 짧지 않습니다. 그것의 입출구 논리는 지속적인 상승 추세를 인식하는 데 어느 정도의 능력을 가지고 있습니다.

이점 분석

이 전략의 장점:

  1. 논리는 간단하고 이해하기 쉽고 실행하기 쉽습니다.

  2. 매개 변수 조정의 유연성을 위해 SMA, EMA 및 볼륨과 같은 일반적인 기술 지표를 활용합니다.

  3. 지속적인 상승 추세에서 기회를 잡을 수 있는 능력이 있습니다.

위험 분석

이 전략의 위험은:

  1. 하락 추세 또는 고집 시장을 감지 할 수 없으므로 큰 마감으로 이어집니다.

  2. 단축 기회를 활용할 수 없고, 하락 추세에 대비할 수 없고, 좋은 수익 기회를 놓칠 수 없습니다.

  3. 부피 표시기가 고주파 데이터에서 잘 작동하지 않아 매개 변수를 조정해야 합니다.

  4. 스톱 로스를 사용하여 위험을 통제할 수 있습니다.

최적화 방향

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

  1. 평균 회전 기회에 대한 단축 기능을 추가합니다.

  2. 더 나은 트렌드 검출을 위해 MACD와 RSI와 같은 더 고급 인디케이터를 사용하는 것

  3. 스톱 로스 로직을 최적화하여 드라운 다운을 줄이세요.

  4. 최적의 매개 변수를 찾기 위해 매개 변수를 조정하고 다양한 시간 프레임을 테스트합니다.

결론

요약하면 이것은 진입 시기를 위해 SMA, EMA 및 볼륨을 활용하는 전략을 따르는 매우 간단한 추세입니다. 그것의 장점은 간단하고 구현하기가 쉽고 초보자에게 배우기 좋지만 통합 또는 하락 추세를 감지 할 수 없으며 위험이 있습니다. 단축, 최적화 지표 및 스톱 로스 등을 도입하여 개선이 가능합니다.


/*backtest
start: 2023-11-07 00:00:00
end: 2023-12-02 00:00:00
period: 2h
basePeriod: 15m
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/
// © slip_stream

//@version=4

// Simple strategy for riding the momentum and optimising the timings of truer/longer price moves upwards for an long posistions on a daily basis (can be used, but with less effect
// on other time frames. Volume settings would have to be adjusted by the user accordingly. (short positions are not used).
// This strategy has default settings of a short(er) SMA of 10, a long(er) EMA of 20, and Volume trigger of 10 units and above. All these settings can be changed by the user
// using the GUI settings and not having to change the script.

// The strategy will only open a long position when there is a clear indication that price momentum is upwards through the SMA moving and remaining above the EMA (mandatory) and price period indicators
// of either 1) a standard 3 bar movement upwards, 2) a standard but "aggressive" 3 or 4 bar play where the low of the middle resting bars can be equal to or higher than (i.e. not
// the more standard low of about half) of the opening of the ignition bar. The "aggression" of the 3/4 bar play was done in order to counteract the conservatisme of having a mandatory
// SMA remaining higher than the EMA (this would have to be changed in the script by the user if they want to optimise to their own specifications. However, be warned, all programmatic
// settings for the maximum acceptable low of the middle resting bars runs a risk of ignoring good entry points due to the low being minutely e.g. 0.01%, lower than the user defined setting)


strategy(title = "Simple Momentum Strategy Based on SMA, EMA and Volume", overlay = true, pyramiding = 1, initial_capital = 100000, currency = currency.USD)


// Obtain inputs
sma_length = input(defval = 10, minval=1, type = input.integer, title = "SMA (small length)")
ema_length = input(defval = 20,minval=1, type = input.integer, title = "EMA (large length)")
volume_trigger = input(defval = 10, title = "Volume Trigger", type = input.integer)
sma_line = sma(close, sma_length)
ema_line = ema(close, ema_length)


// plot SMA and EMA lines with a cross for when they intersect
plot(sma_line, color = #8b0000, title = "SMA")
plot(ema_line, color = #e3d024, title = "EMA")
plot(cross(sma_line, ema_line) ? sma_line : na, style = plot.style_cross, linewidth = 4, color = color.white)


// Create variables
// variables to check if trade should be entered
//three consecutive bar bar moves upwards and volume of at least one bar is more than 10
enter_trade_3_bar_up = sma_line > ema_line and close[1] >= close [2] and close[3] >= close[4] and close[2] >= close[3] and (volume[1] >= volume_trigger or volume[2] >= volume_trigger or volume[3] >= volume_trigger)
// aggressive three bar play that ensures the low of the middle bar is equal to or greater than the open of the instigator bar. Volume is not taken into consideration (i.e. aggressive/risky)
enter_3_bar_play = sma_line > ema_line and close[1] > close[3] and low[2] >= open[3]
// aggressive four bar play similar to the 3 bar play above
enter_4_bar_play = sma_line > ema_line and close[1] > close[4] and low[2] >= open[4]
trade_entry_criteria = enter_trade_3_bar_up or enter_3_bar_play or enter_4_bar_play // has one of the trade entry criterias returned true?

// exit criteria for the trade: when the sma line goes under the ema line
trade_exit_criteria = crossunder (sma_line, ema_line)


if (year >= 2019)
    strategy.entry(id = "long", long = true, qty = 1, when = trade_entry_criteria)
    strategy.close(id = "long", when = trade_exit_criteria, qty = 1)
    // for when you want to brute force close all open positions: strategy.close_all (when = trade_exit_criteria)

더 많은