삼중 이동 평균 채널 트렌드 전략

저자:차오장, 날짜: 2023-11-06 16:58:57
태그:

img

전반적인 설명

이 전략은 이동 평균의 순서를 기반으로 트렌드 방향을 결정하기 위해 이동 평균의 세 가지 조합을 사용하여 트렌드 다음을 달성합니다. 빠른 이동 평균, 중간 이동 평균 및 느린 이동 평균이 순서대로 배치되면 길게 이동합니다. 느린 이동 평균, 중간 이동 평균 및 빠른 이동 평균이 순서대로 배치되면 짧게 이동합니다.

전략 원칙

이 전략은 빠른 이동 평균, 중간 이동 평균, 느린 이동 평균을 포함한 다른 기간을 가진 세 개의 이동 평균을 사용합니다.

입국 조건:

  1. 롱: 빠른 MA > 중간 MA > 느린 MA, 시장은 상승 추세로 간주됩니다.
  2. 짧은: 느린 MA < 중간 MA < 빠른 MA, 시장은 하락 추세로 간주됩니다, 짧은 이동.

출입 조건:

  1. MA 출구: 3개의 이동 평균의 순서가 역전될 때 포지션을 닫습니다.
  2. TP/SL 출구: TP의 12%와 SL의 1%와 같은 고정된 수익점 및 스톱 로스 포인트를 설정하고, 가격이 TP 또는 SL에 도달하면 출구합니다.

전략은 간단하고 직접적이며, 세 개의 이동 평균을 사용하여 트렌드를 따르는 거래의 시장 트렌드 방향을 결정합니다. 강한 트렌드를 가진 시장에 적합합니다.

이점 분석

  • 트렌드를 결정하고 시장 소음을 필터링하기 위해 3개의 이동 평균을 사용하세요.
  • 다른 기간의 이동 평균은 트렌드 반전 지점을 더 정확하게 결정할 수 있습니다.
  • 이동 평균 지표와 고정 TP/SL를 결합하여 자본 위험을 관리합니다.
  • 전략 논리는 간단하고 직관적이며 이해하기 쉽고 구현하기 쉽습니다.
  • MA 기간 매개 변수들은 다양한 주기의 시장 조건에 적응하기 위해 쉽게 최적화 될 수 있습니다.

위험 과 개선

  • 장기주기 시장에서는 이동평균이 더 많은 잘못된 신호를 가지고 불필요한 손실을 초래할 수 있습니다.
  • 수익성을 높이기 위해 다른 지표 또는 필터를 추가하는 것을 고려하십시오.
  • 더 광범위한 시장 조건에 적응하기 위해 이동 평균 기간 매개 변수 조합을 최적화하십시오.
  • 트렌드 강도 지표와 결합하여 픽을 구매하고 바닥을 판매하는 것을 피하십시오.
  • 손실을 늘리지 않도록 자동 정지 기능을 추가합니다.

결론

트리플 이동 평균 트렌드 다음 전략은 명확하고 이해하기 쉬운 논리를 가지고 있으며, 트렌드를 따르는 간단한 트렌드에 대한 트렌드 방향을 결정하기 위해 이동 평균을 사용합니다. 이점은 구현이 쉽고 MA 기간 매개 변수를 조정하면 다른 주기의 시장 조건에 적응 할 수 있다는 것입니다. 그러나 불필요한 손실을 줄이고 전략 수익성을 향상시키기 위해 다른 지표 또는 조건을 추가하여 개선 할 수있는 잘못된 신호의 특정 위험이 있습니다. 전반적으로이 전략은 트렌드 거래에 관심이있는 초보자에게 배우고 연습하기에 적합합니다.


/*backtest
start: 2023-10-06 00:00:00
end: 2023-11-05 00:00:00
period: 1h
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/
// © Jompatan

//@version=5
strategy('Strategy Triple Moving Average', overlay=true, initial_capital = 1000, commission_value=0.04, max_labels_count=200)

//INPUTS
mov_ave = input.string(defval="EMA", title='Moving Average type:', options= ["EMA", "SMA"])

period_1 = input.int(9,  title='Period 1', inline="1", group= "============== Moving Average Inputs ==============")
period_2 = input.int(21, title='Period 2', inline="2", group= "============== Moving Average Inputs ==============")
period_3 = input.int(50, title='Period 3', inline="3", group= "============== Moving Average Inputs ==============")

source_1 = input.source(close, title='Source 1', inline="1", group= "============== Moving Average Inputs ==============")
source_2 = input.source(close, title='Source 2', inline="2", group= "============== Moving Average Inputs ==============")
source_3 = input.source(close, title='Source 3', inline="3", group= "============== Moving Average Inputs ==============")


//EXIT CONDITIONS
exit_ma   = input.bool(true, title= "Exit by Moving average condition", group="================ EXIT CONDITIONS ================")
exit_TPSL = input.bool(false, title= "Exit by Take Profit and StopLoss", group="================ EXIT CONDITIONS ================")
TP        = input.int(12, title='Take Profit', step=1, group="================ EXIT CONDITIONS ================")
SL        = input.int(1, title='Stop Loss', step=1, group="================ EXIT CONDITIONS ================")
plot_TPSL = input.bool(false, title='Show TP/SL lines', group="================ EXIT CONDITIONS ================")


//Date filters
desde = input(defval= timestamp("01 Jan 2023 00:00 -3000"), title="From", inline="12", group= "============= DATE FILTERS =============")
hasta = input(defval= timestamp("01 Oct 2099 00:00 -3000"), title="To  ", inline="13", group= "============= DATE FILTERS =============")
enRango = true

//COMMENTS
//entry_long_comment  = input.string(defval=" ", title="Entry Long comment: ", inline="14", group="============= COMMENTS =============")
//exit_long_comment   = input.string(defval=" ", title="Exit Long comment:  ", inline="15", group="============= COMMENTS =============")
//entry_short_comment = input.string(defval=" ", title="Entry Short comment:", inline="16", group="============= COMMENTS =============")
//exit_short_comment  = input.string(defval=" ", title="Exit Short comment: ", inline="17", group="============= COMMENTS =============")

//============================================================

//Selecting Moving average type
ma1 = mov_ave == "EMA" ? ta.ema(source_1, period_1) : ta.sma(source_1, period_1)
ma2 = mov_ave == "EMA" ? ta.ema(source_2, period_2) : ta.sma(source_2, period_2)
ma3 = mov_ave == "EMA" ? ta.ema(source_3, period_3) : ta.sma(source_3, period_3)

//============================================================
//Entry Long condition: Grouped Moving average from: (ma fast > ma middle > ma slow)
long_condition = (ma1 > ma2) and (ma2 > ma3)

//Entry Short condition: Grouped Moving average from: (ma fast < ma middle < ma slow)
short_condition = (ma1 < ma2) and (ma2 < ma3)

//============================================================

cantidad       = strategy.equity / close
comprado_long  = strategy.position_size > 0
comprado_short = strategy.position_size < 0

var long_profit_price  = 0.0
var long_stop_price    = 0.0
var short_profit_price = 0.0
var short_stop_price   = 0.0

//============================================================

//ENTRY LONG
if not comprado_long and not comprado_short and long_condition and not long_condition[1] and enRango
    strategy.entry('Long', strategy.long, qty=cantidad, comment= "Entry Long")
    if exit_TPSL
        long_profit_price := close * (1 + TP/100)
        long_stop_price   := close * (1 - SL/100)
    else
        long_profit_price := na
        long_stop_price   := na
//============================================================


//ENTRY SHORT
if not comprado_long and not comprado_short and short_condition and not short_condition[1] and enRango
    strategy.entry('Short', strategy.short, qty=cantidad, comment= "Entry Short")
    if exit_TPSL
        short_profit_price := close * (1 - TP/100)
        short_stop_price   := close * (1 + SL/100)
    else
        short_profit_price := na
        short_stop_price   := na
//============================================================


//EXIT LONG 
if comprado_long and exit_ma and long_condition[1] and not long_condition
    strategy.close('Long', comment='Exit-Long(MA)')
if comprado_long and exit_TPSL
    strategy.exit('Long', limit=long_profit_price, stop=long_stop_price, comment='Exit-Long(TP/SL)')
//============================================================


//EXIT SHORT 
if comprado_short and exit_ma and short_condition[1] and not short_condition
    strategy.close('Short', comment='Exit-Short(MA)')
if comprado_short and exit_TPSL
    strategy.exit('Short', limit=short_profit_price, stop=short_stop_price, comment='Exit-Short(TP/SL)')
//============================================================



//PLOTS
plot(ma1, linewidth=2, color=color.rgb(255, 255, 255))
plot(ma2, linewidth=2, color=color.rgb(144, 255, 252))
plot(ma3, linewidth=2, color=color.rgb(49, 167, 255))
//Plot Take Profit line
plot(plot_TPSL ? comprado_long  ? long_profit_price : comprado_short ? short_profit_price : na : na, color=color.new(color.lime, 30), style= plot.style_linebr)
//Plot StopLoss line
plot(plot_TPSL ? comprado_long ? long_stop_price : comprado_short ? short_stop_price : na : na, color=color.new(color.red, 30), style= plot.style_linebr)









더 많은