デュアル移動平均トレンドフォロー戦略


作成日: 2023-09-24 13:14:08 最終変更日: 2023-09-24 13:14:08
コピー: 0 クリック数: 694
1
フォロー
1617
フォロワー

概要

この戦略は,長期RMA平均線と短期EMA平均線の組み合わせを使用してトレンド判断を行い,高低点の突破でトレンド追跡ストップを可能にします.また,偽の突破をフィルタリングするために無取引区間を設定します.

戦略原則

  1. 長期周期RMAと短期周期EMAを使用してトレンドの方向を判断する.短期EMAの下には長期RMAを空見信号として,上には多見信号として穿戴する.

  2. 価格が最近一定周期の最高値を破るとき,最高値を追跡する方法で止まる.価格が最近一定周期の最低値を破るとき,最低価格を追跡する方法で止まる.

  3. 取引のない区間を設定し,価格がその区間に入るとポジションを開かない. 区間の範囲はRMA平均線によって一定の割合で決定される.

  4. 入場後にストップ価格を設定し,一定割合で利益から退出する.

戦略的優位性

  1. 双均線配列は,トレンドの方向を正確に判断する.

  2. ストップ・トラッキングは,ストップ・トラッキングをトレンドで実行します.

  3. 偽の突破信号を有効にフィルターする無取引区間を設定する.

  4. ストップセットは,戦略が十分な利潤を蓄積した後に積極的に平仓することを可能にします.

戦略リスク

  1. 双均線が死叉を生じるときに遅延があり,損失が拡大する.

  2. ストップポイントが価格に近すぎると,前期ノイズに打たれる可能性があります.

  3. 取引のない区間の設定が大きすぎると,取引の機会が逃されます.

  4. 損失を一時停止しなければ,さらに拡大する可能性があります.

対応方法:

  1. 平均線パラメータを最適化し,遅延確率を下げる.

  2. ストップポイントを適切に緩め,過敏を防ぐ.

  3. テストは,無取引区間の範囲を調整し,機会を逃さないようにします.

  4. 損失の最大限を制限する他の方法を追加します.

戦略最適化の方向性

  1. 他の均線指標の組み合わせをテストし,よりマッチングな組み合わせを探します.

  2. 価格格差やMACDなどの判断指標を増加させ,戦略の安定性を高める.

  3. 機械学習アルゴリズムの最適化パラメータを導入し,戦略をより賢くする.

  4. 逆転取引を避けるために,トレンドの強さや弱さを示す指標を組み合わせる.

  5. 資金管理戦略の最適化と戦略の成功率の向上

要約する

この戦略は,二重均等線の判断トレンドの方向を使用し,高低点追跡ストップと取引なし区間のフィルタリングでトレンドの利潤をロックする. 戦略の枠組みは,シンプルで明確で,拡張性強で,パラメータ区間の調整,ストップ・ストップ・ストラトジーの最適化,その他の補助判断指標の導入などによって最適化することができ,戦略は,異なる市場で良い効果を発揮することができる.

ストラテジーソースコード
/*backtest
start: 2023-08-24 00:00:00
end: 2023-09-12 00:00:00
period: 3h
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/
// © PatrickGwynBuckley

//@version=5
//var initialCapital = strategy.equity

strategy("PB Trend Scalper", "PB Trend Scalper", overlay = true)
shortma = input.int(55, title="quick ma's")
longma = input.int(100, title="long ma's")
ema55h = ta.ema(high, shortma)
ema55l = ta.ema(low, shortma)
ema200h = ta.rma(high, longma)
ema200l = ta.rma(low, longma)
stock = ta.stoch(close, high, low, 14)

lev = input.int(3, title="leverage")
hhVal = input.int(170, title="Highest high period")
llVal = input.int(170, title="Lowest low period")

hh = ta.highest(high, hhVal)
ll = ta.lowest(low, llVal)
//plot(stock)

plot(hh, color=color.new(color.green, 50))
plot(ll, color=color.new(color.red, 50))
var float downtrade = 0
p = input.float(3.0, title="no trade zone")
l = 3
emadistlong = ema200h + ((ema200h/100)*p)
emadistshort = ema200l - ((ema200h/100)*p)

plot(ema55h)
plot(ema55l)
ntl = plot(emadistlong, color=color.new(color.red, 10))
nts = plot(emadistshort, color=color.new(color.red, 10))
fill(ntl, nts, color=color.new(color.red, 90))

//position size

EntryPrice = close
//positionValue = initialCapital
positionSize = (strategy.equity*lev) / EntryPrice

//plot(strategy.equity)


//standard short

if ema55h < ema200l and close[2] < ema55l and close[1] > ema55l and high[1] < ema55h and close < ema55h and ema55h < emadistshort and strategy.opentrades == 0// and stock > 85 
    strategy.entry("short", strategy.short, qty=positionSize, comment="short")
    downtrade := 1

//reset count    
if (ta.crossunder(ema55h, ema200l)) and downtrade == 1
    downtrade := 0

//standard long    
if ema55l > ema200h and close[2] > ema55h and close[1] < ema55h and low[1] > ema55l and close > ema55l and ema55l > emadistlong and strategy.opentrades <= 1// and stock < 15 
    strategy.entry("long", strategy.long, qty=positionSize, comment="long")
    downtrade := 0

//RESET COUNT ON MA CROSS
if (ta.crossover(ema55l, ema200h)) and downtrade == 0
    downtrade := 1
    
longclose2 = low < ll[1] or low < emadistshort //close < open and open<open[1] and open[2] < open[3] and open[3] < emadistshort//close < ta.lowest(low, 20)//
shortclose2 = high > hh[1] or high>emadistlong//close > open and open>open[1] and open[2]>open[3] and open[3] > emadistlong//high > emadistlong//close > ta.highest(high, 20)//

sl = 3.5
tp = input.float(6.9, title="take profit %")
tp2 = 10


strategy.exit("long exit", "long", profit = (strategy.position_avg_price*(tp)))//, loss = (strategy.position_avg_price*(sl)))
strategy.close("long", when = longclose2, comment = "long exit")
//strategy.close("long", when = (downtrade == 1), comment = "long exit")
//strategy.exit("long exit", "long2", profit = (strategy.position_avg_price*(tp2)))//, loss = (strategy.position_avg_price*(sl)))
//strategy.close ("long2", when = longclose2, comment = "long exit")
//strategy.close("long", when = (downtrade == 1), comment = "long exit")

strategy.exit("short exit", "short", profit = (strategy.position_avg_price*(tp)))//, loss = (strategy.position_avg_price*(sl)))//, loss = 300)
strategy.close("short", when = shortclose2, comment = "short exit")
//strategy.close("short", when = (downtrade == 0), comment = "short exit")
//strategy.exit("short exit", "short2", profit = (strategy.position_avg_price*(tp2)))//, loss = (strategy.position_avg_price*(sl)))
//strategy.close ("short2", when = shortclose2, comment = "short exit")
//strategy.close("short2", when = (downtrade == 0), comment = "short exit")

//if (strategy.exit("long exit", "long"))
    //downtrade := 1
//else 
   // downtrade := 0