SMAボラティリティ偏差取引戦略


作成日: 2023-12-19 10:52:10 最終変更日: 2023-12-19 10:52:10
コピー: 1 クリック数: 788
1
フォロー
1621
フォロワー

SMAボラティリティ偏差取引戦略

SMAボラティリティ偏差取引戦略

戦略概要

この戦略は,シンプルな移動平均といくつかの数学的な計算を使用して,買い/売却のポイントを決定します. 100日SMAを基準線として使用します. 閉盘価格がこのラインより低ければ,その線より低い程度に基づいて開店ポイントを選択します. この値は (低偏移量) 構成可能なパーセントです.

戦略原則

この戦略は,3つのSMA線を使用します. 快線 (デフォルトで14日),慢線 (デフォルトで100日),参照線 (デフォルトで30日).

閉盤価格が基準線より低いとき,そして慢線に対する低偏移が配置された低偏移より大きいとき,そして快線が上がり,慢線が下がり,多頭に入ります。これらの条件を満たすと,快線と慢線が交差する可能性が非常に高いので,良い入場点です。

閉盘価格が参照線より高く,慢線に対する高偏移が配置された高偏移より大きいとき,閉盘価格が連続3K線で上昇し,利益が実現し,快線が慢線より高いとき,平仓多単.価格が大きく上昇し続けると,追跡ストップが起動する.

各取引のポジションは,権利利権の一定比率に基づいて入って,この方法でポジションをコントロールする.

戦略的優位分析

  1. 価格曲線を平らにするためのSMAの優位性を活用し,市場騒音をフィルターします.
  2. SMAクロスには一定のトレンド予測能力があります.
  3. SMA線に対する偏移量設定で,偽突破を避ける.
  4. トレンドとクロスインジケーターを組み合わせて,意思決定の正確さを向上させる.
  5. ストップ・ローズ・トラッキングを利用して収益を固定し,撤回を回避する.

戦略的リスク分析

  1. 価格の転換点を逃す可能性が高い.
  2. 偏移量設定が不適切である場合,偏移量設定が不適切である場合,偏移量設定が不適切である場合,偏移量設定が不適切である場合,偏移量設定が不適切である場合.
  3. トラッキングストップパラメータの設定が不適切である場合,早すぎるストップまたは過剰なストップが発生する可能性があります.
  4. 価格の急激な変動に対応できない市場.

対応する最適化策

  1. 他の先行指標と組み合わせた入場フィルター
  2. 偏移量に対する反復テスト最適化.
  3. 止損パラメータを反復テストし,最適パラメータを見つけます.
  4. 高波動期にポジションを下げること.

戦略最適化の方向性

  1. 異なる周期のSMAをテストし,最適なパラメータを探します.
  2. 市場構造とトレンドを判断する他の指標に追加
  3. ストップ・ローズ・パラメータを最適化して,より多くの収益をロックします.
  4. 市場変動に応じてポジションの調整
  5. 複数の品種に適用し,組み合わせる

要約する

SMA波動偏移取引戦略は,偏移を異なるSMA平均線に参照して設定し,最適な入場時間を探す.同時に,退出機構は,止損を追跡して利益をロックする.この戦略は,簡単に理解し,簡単に実施できます.SMAパラメータ,偏移設定,止損水平を最適化することによって,よりよい効果を得ることができます.この戦略は,中長期周期で安定した利益を追求する投資家に適しています.

ストラテジーソースコード
/*backtest
start: 2022-12-12 00:00:00
end: 2023-12-18 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// @version=4
// Author: Sonny Parlin (highschool dropout)
strategy(shorttitle="SMA+Strategy", title="SMA Offset Strategy",
                                      overlay=true,  currency=currency.USD,
                                      initial_capital=10000)

// Inputs and variables
ss = input(14, minval=10, maxval=50, title="SMA Fast (days)")
ff = input(100, minval=55, maxval=200, title="SMA Slow (days)")
ref = input(30, minval=20, maxval=50, title="SMA Reference (days)")
lowOffset = input(0.001, "Low Offset (%)", minval=0, step=0.001)
highOffset = input(0.0164, "High Offset (%)", minval=0, step=0.0001)
orderStake = input(0.96, "Order Stake (%)", minval=0, step=0.01)

// SMA
smaFast = sma(close, ss)
smaSlow = sma(close, ff)
smaRef = sma(close, ref)
distanceLow = (close - smaSlow) / close
distanceHigh = (close - smaSlow) / close

// Set up SMA plot but don't show by default
plot(smaFast, "smaFast", color=#00ff00, display = 0)
plot(smaSlow, "smaSlow", color=#ff0000, display = 0)
plot(smaRef, "smaRef", color=#ffffff, display = 0)

// The buy stratey:
// guard that the low is under our sma low reference line by our lowOffset %, 
// default is 0.001. (low < smaRef) and (distanceLow > lowOffset)
// SMA fast is on the rise and SMA slow is falling and they are very likely
// to cross. (rising(smaFast,1)) and (falling(smaSlow, 1)) 
enterLong = (low < smaRef) and (distanceLow > lowOffset) and (rising(smaFast,1)) and (falling(smaSlow, 1)) 

// The sell Strategy:
// Guard that close is higher than our sma high reference line by our 
// highOffset %, default is 0.0164. (close > smaRef) and (distanceHigh > highOffset)
// Guard that close has risen by 3 candles in a row (rising(close,3)) 
// Guard that we currently have profit (strategy.openprofit > 0)
// Guard that SMA fast is higher than smaSlow (smaFast > smaSlow)
// If it keeps going up past our close position the trailing stoploss will kick in!
enterShort = (close > smaRef) and (distanceHigh > highOffset) and (rising(close,3)) and (strategy.openprofit > 0) and (smaFast > smaSlow)

// Order size is based on total equity
// Example 1:
// startingEquity = 2000
// close = 47434.93
// orderStake = 0.45
// (2,000 × orderStake) / close = orderSize = 0.0189733599 = approx $900

// Example 2:
// startingEquity = 2000
// close = 1.272
// orderStake = 0.45
// (startingEquity × orderStake) / close = orderSize = 707.5471698113 = approx $900
orderSize = (strategy.equity * orderStake) / close

// Trailing Stoploss
// I'm using 1.35 as my default value, play with this for different results.
longTrailPerc = input(title="Trailing Stoploss (%)",
     type=input.float, minval=0.0, step=0.1, defval=1.35) * 0.01
     
longStopPrice = 0.0

longStopPrice := if (strategy.position_size > 0)
    stopValue = close * (1 - longTrailPerc)
    max(stopValue, longStopPrice[1])
else
    0

if (enterLong)
    strategy.entry("Open Long Position", strategy.long, orderSize, when=strategy.position_size <= 0)
    
if (enterShort)
    strategy.exit(id="Close Long Position", stop=longStopPrice)


//plot(strategy.equity)