트리플 이동 평균 채널 추세 추종 전략


생성 날짜: 2023-11-06 16:58:57 마지막으로 수정됨: 2023-11-06 16:58:57
복사: 0 클릭수: 746
avatar of ChaoZhang ChaoZhang
1
집중하다
1617
수행원

트리플 이동 평균 채널 추세 추종 전략

개요 (Overview)

이 전략은 삼중 이동 평균 조합을 사용하여 이동 평균의 순차 관계에 따라 추세 방향을 판단하여 추세를 추적합니다. 빠른 이동 평균, 중간 이동 평균, 느린 이동 평균을 순차적으로 배열 할 때, 더 많이하십시오. 느린 이동 평균, 중간 이동 평균, 빠른 이동 평균을 순차적으로 배열 할 때, 공백하십시오.

전략 원칙 (Strategy Principle)

이 전략은 3개의 다른 기간의 이동 평균을 사용합니다. 빠른 이동 평균, 중간 이동 평균, 그리고 느린 이동 평균을 포함합니다.

입장 조건:

  1. 더 많이 하라: 빠른 이동 평균 > 중간 이동 평균 > 느린 이동 평균이 상승 추세라고 생각되면 더 많이 하라.
  2. 공백: 느린 이동 평균 <중간 이동 평균 <빠른 이동 평균이 있을 때, 거래가 하향 추세에 있다고 생각하여 공백한다.

출전 조건:

  1. 이동 평균 출전: 3개의 이동 평균 순서가 반전될 때 평지한다.
  2. 스톱 스톱 손실 출구: 고정 스톱 스톱 손실 지점을 설정합니다. 스톱 스톱 가격에 도달 한 후 평정 위치. 스톱 스톱 손실 지점은 12%이며, 스톱 스톱 손실 지수는 1%입니다.

이 전략은 간단하고 직설적이며, 세 개의 이동 평균을 사용하여 시장의 경향 방향을 판단하고, 트렌드 추적 거래를 가능하게 하며, 트렌드성이 강한 시장에 적합하다.

장점 분석 (Advantage Analysis)

  • 세 개의 이동 평균을 사용하여 트렌드를 판단하고, 시장 소음을 필터링하고, 트렌드 방향을 식별합니다.
  • 다른 주기적인 이동 평균을 사용하면 트렌드 전환점을 더 정확하게 판단 할 수 있습니다.
  • 이동 평균 지표와 고정 스톱 스톱 손실을 결합하여 자금 위험을 관리한다.
  • 전략은 간단하고 직관적이며, 실행에 옮기기 쉽다.
  • 이동 평균 주기 변수를 최적화하여 다른 주기 상황에 맞게 조정할 수 있다.

위험과 개선

  • 큰 주기적 상황에서는 이동 평균이 더 많은 잘못된 판단을 일으킬 수 있으며, 불필요한 손실을 초래할 수 있다.
  • 다른 지표 또는 필터링 조건을 추가하여 수익률을 높이는 것을 고려할 수 있습니다.
  • 이동 평균의 주기적 변수 조합을 최적화하여 보다 광범위한 시장 상황에 맞게 조정할 수 있다.
  • 트렌드 강점과 약한 지표를 결합하여 추세를 따라오는 것을 피할 수 있습니다.
  • 손실을 확대하지 않도록 자동으로 중지 할 수 있습니다.

[결과]

이 트리플 이동 평균 트렌드는 전략의 전체적인 생각을 명확하게 이해하고, 이동 평균을 사용하여 추세 방향을 판단하고, 간단한 추세 따라 거래를 구현한다. 전략의 장점은 쉽게 구현할 수 있으며, 이동 평균 주기 변수를 조정하여 다른 주기적 상황에 적응할 수 있다. 그러나 또한 잘못된 판단의 위험이 있다. 다른 지표 또는 조건을 추가하여 최적화하여 불필요한 손실을 줄이고, 전략의 수익률을 높일 수 있다.

전략 소스 코드
/*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)