クロス移動平均逆転戦略

作者: リン・ハーンチャオチャン,日付: 2024-02-20 13:59:46
タグ:

img

概要

これは単純な移動平均クロスオーバーに基づいた逆転戦略である. 1 日および 5 日間の単純な移動平均を使用する.より短いSMAがより長いSMAを横切ると,それは長い.より短いSMAがより長いSMAを横切ると,それは短い.これは典型的なトレンドフォロー戦略である.

戦略の論理

ストラテジーは,閉店価格の1日SMA (sma1) と5日SMA (sma5) を計算する. sma1が sma5を超えると,ロングポジションに入ります. sma1が sma5を下回ると,ショートポジションに入ります.ロングポジションを開いた後,ストップロスはエントリー価格より5USD低く設定され,150USD以上で利益を得ます.ショートポジションでは,ストップロスはエントリー価格より5USD高く,利益を得ることは150USD以下です.

利点分析

  • ストップロスの後に損失を伴う取引を避けるため,市場傾向を決定するためにダブルSMAを使用する
  • SMA パラメータ シンプルで合理的 バックテスト結果は良好
  • 価格変動に耐えるため ストップ損失が小さい
  • 十分なお金を稼ぐための大きな利益目標

リスク分析

  • ダブルSMAは,ウィップソーに傾向があり,揺れ動いているときにストップロスの可能性が高い
  • トレンドの動きを把握するのは難しい 長期取引の利益は限られている
  • 制限された最適化空間,過度に適合しやすい
  • パラメータは異なる取引手段に合わせて調整する必要がある

改善 の 方向

  • 間違った信号を避けるために他のフィルターを追加します.
  • ダイナミックストップ・ロストと得益
  • SMA パラメータを最適化
  • 波動性指数とポジションサイズを制御することを組み合わせる

結論

この単純なダブルSMA戦略は,戦略の迅速な検証のために理解し,実装することは簡単です.しかし,リスクの寛容性と利益の可能性は限られています.より多くの市場状況に適応するために,パラメータとフィルターにさらなる最適化が必要です.スタート量戦略として,繰り返す改善のための基本的な構成要素が含まれています.


/*backtest
start: 2023-02-19 00:00:00
end: 2024-02-19 00:00:00
period: 2d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5
strategy("Valeria 181 Bot Strategy Mejorado 2.21", overlay=true, margin_long=100, margin_short=100)
 
var float lastLongOrderPrice = na
var float lastShortOrderPrice = na

longCondition = ta.crossover(ta.sma(close, 1), ta.sma(close, 5))
if (longCondition)
    strategy.entry("Long Entry", strategy.long)  // Enter long

shortCondition = ta.crossunder(ta.sma(close, 1), ta.sma(close, 5))
if (shortCondition)
    strategy.entry("Short Entry", strategy.short)  // Enter short

if (longCondition)
    lastLongOrderPrice := close

if (shortCondition)
    lastShortOrderPrice := close

// Calculate stop loss and take profit based on the last executed order's price
stopLossLong = lastLongOrderPrice - 5  // 10 USDT lower than the last long order price
takeProfitLong = lastLongOrderPrice + 151  // 100 USDT higher than the last long order price
stopLossShort = lastShortOrderPrice + 5  // 10 USDT higher than the last short order price
takeProfitShort = lastShortOrderPrice - 150  // 100 USDT lower than the last short order price

// Apply stop loss and take profit to long positions
strategy.exit("Long Exit", from_entry="Long Entry", stop=stopLossLong, limit=takeProfitLong)

// Apply stop loss and take profit to short positions
strategy.exit("Short Exit", from_entry="Short Entry", stop=stopLossShort, limit=takeProfitShort)

もっと