トリプル移動平均チャネルトレンドフォロー戦略


作成日: 2023-11-06 16:58:57 最終変更日: 2023-11-06 16:58:57
コピー: 0 クリック数: 746
1
フォロー
1617
フォロワー

トリプル移動平均チャネルトレンドフォロー戦略

概要 (Overview)

この戦略は,三重移動平均の組み合わせを採用し,移動平均の順序的関係によってトレンドの方向を判断し,トレンド追跡を実現する. 急速移動平均,中速移動平均,遅い移動平均を順番に並べるときは,多めに行い,緩い移動平均,中速移動平均,急速移動平均を順番に並べるときは,空にする.

戦略原則

この戦略は,3つの異なる周期の移動平均を使用し,迅速な移動平均,中速の移動平均,そして遅い移動平均を含む.

応募条件:

  1. 動きが上昇傾向にあると考えると,動きが上昇傾向にあると考えると,動きが上昇傾向にあると考えると,動きが上昇傾向にあると考えると,動きが上昇傾向にあると考えると,動きが上昇傾向にあると考えると,動きが上昇傾向にあると考えると,動きが上昇傾向にあると考えると,動きが上昇傾向にあると考えると,動きが上昇傾向にあると考えると,動きが上昇傾向にあると考えると,動きが上昇傾向にあると考えると,動きが上昇傾向にあると考えると,動きが上昇傾向にあると考えると,動きが上昇傾向にあると考えると,動きが上昇傾向にあると考えると,動きが上昇傾向にあると考えると,動きが上昇傾向にあると考えると,動きが上昇傾向にあると考えると,動きが上昇傾向にあると考えると,動きが上昇傾向にあると考えられます.
  2. 空白: 遅い移動平均線 < 中速移動平均線 < 急速移動平均線が下落傾向にあると判断して空白する.

出場条件:

  1. 移動平均線出場:三つの移動平均線の順序が逆転時に平仓する.
  2. ストップ・ストップ・損失出場: ストップ・ストップ・損失の固定ポイントを設定し,ストップ・上昇幅は12%,ストップ・損失幅は1%で,ストップ・またはストップ・損失価格に達した後に平仓する.

この戦略はシンプルで直接的なもので,3つの移動平均を使って市場のトレンド方向を判断し,トレンドフォロー取引を実現し,トレンドが強い市場に適しています.

アドバンテージ分析

  • 3つの移動平均を使ってトレンドを判断し,市場の騒音をフィルターし,トレンドの方向性を識別します.
  • 異なる周期的な移動平均を用いて,トレンドの転換点をより正確に判断できます.
  • 移動平均指数と固定ストップ・ストップ・損失を組み合わせて資金のリスクを管理する.
  • 戦略はシンプルで直感的で,理解しやすい.
  • 移動平均の周期パラメータを最適化して,異なる周期状況に適合させる.

リスクと改善

  • 大周期的な状況では,移動平均は誤判を多く発生させ,不必要な損失を引き起こす可能性がある.
  • 他の指標やフィルタリング条件を追加して利得率を上げることも考えられます.
  • 移動平均周期パラメータの組み合わせを最適化して,より広範な市場状況に適合させる.
  • 傾向の強い指数と弱い指数を組み合わせて,追いつくのを避ける.
  • 自動ストップが追加され,損失の拡大を防ぐことができます.

結論から言うと

この三重移動平均線トレンドは,戦略の全体的な考え方を明確に理解しやすく,移動平均線を活用してトレンドの方向を判別し,簡単なトレンドフォロー取引を実現する.戦略の優点は,簡単に実現し,移動平均線周期パラメータを調整することで,異なる周期状況に適応することができる.しかし,ある程度の誤判のリスクもある.他の指標または条件を加えることで,不要な損失を減らすために,戦略の収益率を向上させ,最適化することができる.全体的に言えば,この戦略は,トレンド取引に興味のある初心者のための学習と実践に適している.

ストラテジーソースコード
/*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)