複数のタイムフレームのMAトレンド 戦略をフォロー

作者: リン・ハーンチャオチャン,日付: 2024-01-04 17:43:17
タグ:

img

概要

この戦略は,中長期トレンドを追跡するために,マルチタイムフレーム移動平均クロスオーバーに基づいています.上昇を追求し,指数関数的な資本成長を達成するためにピラミッド位置を採用しています.最大の利点は,中長期トレンドとピラミッドエントリをバッチと段階に分け,過剰なリターンを得ることができるということです.

戦略の論理

  1. 9日MAS,100日MAS,200日MASをベースに複数のタイムフレームを構築する.
  2. 短期間のMAが長期間のMAを超えると購入信号を生成する.
  3. 7段階のピラミッド型エントリを採用します.新しいエントリを追加する前に既存のポジションを確認し,すでに6つのポジションが開いているときにピラミッド型を停止します.
  4. リスク管理のために 3%のTP/SLを固定する.

上記は取引の基本的な論理です

利点

  1. 中長期のトレンドを効果的に把握し 指数関数的な成長を楽しむ
  2. マルチタイムフレームMAクロスオーバーは短期間のノイズを回避します
  3. 固定TP/SLは各ポジションのリスクを制御する.
  4. ピラミッドの入力は 過剰な利益を得るため

リスク と 解決策

  1. トレンド逆転で損失を削減できない場合,大きな損失のリスク.解決策は,MA期間を短縮し,ストップ損失を迅速にすることです.
  2. マージンコールリスクは,許容範囲を超えた損失の場合です. 解決策は,初期ポジションサイズを下げることです.
  3. 700%以上の損失のリスクが強いダウントレンドの場合 解決策は固定ストップ損失パーセントを上げることです

オプティマイゼーションの方向性

  1. 最適なパラメータを見つけるために,異なるMA組み合わせをテストする.
  2. ピラミッドの段階の量を最適化して 最適の数を見つけるためにテストします
  3. 固定 TP/SL 設定をテストする.より高い収益性のために TP 範囲を拡大する.

概要

この戦略は,中長期のトレンドを捉えるのに非常に適しています. パラメットのピラミッドエントリは非常に高いリスク・リターン比を達成することができます. パラメータチューニングによって制御されるべきいくつかの運用リスクもあります. 全体的にこれはライブ取引の検証とさらなる最適化に値する有望な戦略です.


/*backtest
start: 2023-12-27 00:00:00
end: 2024-01-03 00:00:00
period: 1m
basePeriod: 1m
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/
    // © Coinrule
    
//@version=3
strategy(shorttitle='Pyramiding Entry On Early Trends',title='Pyramiding Entry On Early Trends (by Coinrule)', overlay=false, pyramiding= 7, initial_capital = 1000, default_qty_type = strategy.percent_of_equity, default_qty_value = 20, commission_type=strategy.commission.percent, commission_value=0.1)
    
    
//Backtest dates
fromMonth = input(defval = 1,  title = "From Month")     
fromDay   = input(defval = 10,    title = "From Day")       
fromYear  = input(defval = 2020, title = "From Year")       
thruMonth = input(defval = 1,    title = "Thru Month")     
thruDay   = input(defval = 1,    title = "Thru Day")     
thruYear  = input(defval = 2112, title = "Thru Year")       
    
showDate  = input(defval = true, title = "Show Date Range")
    
start     = timestamp(fromYear, fromMonth, fromDay, 00, 00)        // backtest start window
finish    = timestamp(thruYear, thruMonth, thruDay, 23, 59)        // backtest finish window
window()  => true       // create function "within window of time"
    
    
//MA inputs and calculations
inSignal=input(9, title='MAfast')
inlong1=input(100, title='MAslow')
inlong2=input(200, title='MAlong')
    
MAfast= sma(close, inSignal)
MAslow= sma(close, inlong1)
MAlong= sma(close, inlong2)
    
    
Bullish = crossover(close, MAfast) 
    
longsignal = (Bullish and MAfast > MAslow and MAslow < MAlong and window())
    
//set take profit
    
ProfitTarget_Percent = input(3)
Profit_Ticks = (close * (ProfitTarget_Percent / 100)) / syminfo.mintick
    
//set take profit
    
LossTarget_Percent = input(3)
Loss_Ticks = (close * (LossTarget_Percent / 100)) / syminfo.mintick
    
    
//Order Placing
    
strategy.entry("Entry 1", strategy.long, when = (strategy.opentrades == 0) and longsignal)
    
strategy.entry("Entry 2", strategy.long, when = (strategy.opentrades == 1) and longsignal)
        
strategy.entry("Entry 3", strategy.long, when = (strategy.opentrades == 2) and longsignal)
    
strategy.entry("Entry 4", strategy.long, when = (strategy.opentrades == 3) and longsignal)
    
strategy.entry("Entry 5", strategy.long, when = (strategy.opentrades == 4) and longsignal)
        
strategy.entry("Entry 6", strategy.long, when = (strategy.opentrades == 5) and longsignal)
        
strategy.entry("Entry 7", strategy.long, when = (strategy.opentrades == 6) and longsignal)
    
    
    
if (strategy.position_size > 0)
    strategy.exit(id="Exit 1", from_entry = "Entry 1", profit = Profit_Ticks, loss = Loss_Ticks)
    strategy.exit(id="Exit 2", from_entry = "Entry 2", profit = Profit_Ticks, loss = Loss_Ticks)
    strategy.exit(id="Exit 3", from_entry = "Entry 3", profit = Profit_Ticks, loss = Loss_Ticks)
    strategy.exit(id="Exit 4", from_entry = "Entry 4", profit = Profit_Ticks, loss = Loss_Ticks)
    strategy.exit(id="Exit 5", from_entry = "Entry 5", profit = Profit_Ticks, loss = Loss_Ticks)
    strategy.exit(id="Exit 6", from_entry = "Entry 6", profit = Profit_Ticks, loss = Loss_Ticks)
    strategy.exit(id="Exit 7", from_entry = "Entry 7", profit = Profit_Ticks, loss = Loss_Ticks)
     


もっと