SMAとATRに基づくトレンド追跡戦略

作者: リン・ハーンチャオチャン,日付: 2024-01-18 16時04分51秒
タグ:

img

I. 戦略名

この戦略はSMAとATRに基づくトレンド追跡戦略.

戦略の概要

この戦略は,SMAインジケーターを使用して価格トレンド方向を決定し,トレンドを追跡するためにATRインジケーターでストップ・ロスのポジションを設定します.価格が上昇傾向を崩し,価格が傾向トレンドを崩し,トレンドトレードを実行するために価格がダウントレンドを壊したとき,ショートになります.

戦略の原則

1. 入り口 の 信号

(1) 閉じる価格が上昇し,SMAより高くなったときにロングに行く.
(2) 閉じる価格が下がり,SMAより低いときにショートに行く.

2. 損失 設定 を 停止 する

ATR インディケーターの値と設定されたストップ・ロスの倍数を,ストップ・ロスの位置として使う.

3. 損失 を 更新 する こと を 止める

各バーが閉じる後,ストップ・ロスのポジションを確認し,現在の価格に近いストップ・ロスの値に更新します.

4. 出口 信号

価格がストップ・ロスの線に触れたら ストップ・ロスをアクティブにします

IV 戦略の利点

1. 強い 傾向 を 追跡 する 能力

ATR インジケーターのダイナミックストップ・ロスの設定により,トレンドの自動追跡が可能になります.

2. 精力 を 抑え て いる こと

厳格なストップ・ロスのルールは,取引ごとに最大引き上げを制御するのに役立ちます.

3. シンプルなパラメータ設定

3つのパラメータだけで 調整と最適化が容易になります

V. 戦略 の リスク

1. ストップ・ロスのリスクが過度に緩やかになる

ストップ・ロスの倍数が高く設定された場合,ストップ・ロスのポジションが緩すぎたため,引き上げが増加する可能性があります.

2. 偽発症 の 危険性

価格の誤ったブレイクは,トレンドの方向を誤る可能性があります.他の指標を使用してシグナルをフィルタリングする必要があります.

3. パラメータ 最適化 の リスク

パラメータ最適化への過度な依存は曲線フィッティングにつながる可能性がある.パラメータの安定性は注意深く評価されるべきである.

戦略の最適化の方向性

1.ストップ・ロスのアルゴリズムを最適化

他のタイプのストップ損失アルゴリズムは,移動ストップ損失,比例ストップ損失などでテストすることができます.

2. フィルター の 信号 を 追加 する

偽のブレイクをフィルタリングするために他の指標を追加することができます.例えば,取引量条件を追加します.

3. パラメータの安定性を評価する

パラメーターの適応性や異なる製品と時間枠を評価するためのバックテスト履歴

VII.要約

この戦略の全体的な考えは明確である.SMAを通じてトレンド方向を判断し,ATRを使用して,良い引き下げ制御でトレンドを追跡する.中長期トレンド取引に適している.しかし,パラメータは依然としてライブ取引で適切な調整を必要とし,過剰な最適化のリスクは防止されるべきである.


/*backtest
start: 2024-01-16 00:00:00
end: 2024-01-16 17:00:00
period: 1m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © omererkan

//@version=5
strategy(title="SMA with ATR", overlay=true)

smaLen = input.int(100, title="SMA Length")

atrLen     = input.int(10, title="ATR Length")
stopOffset = input.float(4, title="Stop Offset Multiple", step=0.25)


smaValue  = ta.sma(close, smaLen)
stopValue = ta.atr(atrLen) * stopOffset


lowerCloses = close < close[1] and 
     close[1] < close[2] and
     close[2] < close[3]

enterLong = close > smaValue and 
     lowerCloses


longStop = 0.0
longStop := if enterLong and strategy.position_size < 1
    close - stopValue
else
    math.max(close - stopValue, longStop[1])


higherCloses = close > close[1] and 
     close[1] > close[2] and
     close[2] > close[3]

enterShort = close < smaValue and 
     higherCloses


shortStop = 0.0
shortStop := if enterShort and strategy.position_size > -1
    close + stopValue
else
    math.min(close + stopValue, shortStop[1])


plot(smaValue, color=#4169e1, linewidth=2, title="SMA")

plot(strategy.position_size > 0 ? longStop : na, color=color.lime,
     style=plot.style_linebr, title="Long stop", linewidth=2)

plot(strategy.position_size < 0 ? shortStop : na, color=color.red,
     style=plot.style_linebr, title="Short stop", linewidth=2)


if enterLong
    strategy.entry("EL", strategy.long)

if enterShort
    strategy.entry("ES", strategy.short)


if strategy.position_size > 0
    strategy.exit("SL Long", from_entry="EL", stop=longStop)

if strategy.position_size < 0
    strategy.exit("SL Short", from_entry="ES", stop=shortStop)


if enterLong
    strategy.cancel("Exit Short")

if enterShort
    strategy.cancel("Exit Long")


もっと