BankNifty スーパートレンド トレーディング戦略

作者: リン・ハーンチャオチャン開催日:2023年12月29日17時09分57秒
タグ:

img

概要

この戦略は,スーパートレンド指標を用いたBankNiftyの5分間のKラインに基づいた取引戦略です.この戦略は主にトレンドを特定するためにスーパートレンド指標を使用し,取引セッションとリスク管理規則を組み合わせます.

戦略原則

戦略は,まず,取引セッションや日付範囲などの入力変数を定義します. 取引セッションは,午前9時15分から午後3時10分までのインド取引セッションに設定されています.

超トレンドインジケーターは,トレンドの方向性を特定します.

トレーディングセッションの開始時に,戦略はトレードに入る前に3個のキャンドルが形成されるのを待つ.これは偽のブレイクをフィルタリングすることです.

長い信号はスーパートレンド指標の方向がダウンからアップに変化する時であり,短い信号はスーパートレンドの方向が上からダウンに変化する時です.

入力すると,ストップ・ロスは設定されます.固定ストップ・ロストポイントとトライリング・ストップ・ロストパーセントの両方が入力変数によって調整できます.

取引セッションの終わりに 戦略はすべてのオープンポジションを閉鎖します

戦略 の 利点

これは,傾向を特定するために指標を使用する単純な取引戦略です.以下の利点があります:

  1. トレンドの方向性を判断するためにスーパートレンド指標を使用し,効果的にトレンドを特定することができます.
  2. 取引セッションを組み合わせることで,最も不安定な開閉セッションを回避できます.
  3. 利益をロックするために後続ストップ損失を設定します
  4. 多くのパラメータは入力変数によって自由に調整できます.高度な適応性

戦略 の リスク

この戦略にはいくつかのリスクもあります:

  1. スーパートレンド指標は遅れている 最良のエントリーポイントを見逃す可能性があります
  2. 単一指標判断は,誤ったブレイクによって影響を受けやすい,勝利率は低い可能性があります
  3. 市場動向を考慮しない,市場全体から逸脱する可能性がある
  4. 誤ったストップ損失設定により,予想以上の損失が発生する可能性があります.

これらのリスクは,スーパートレンド指標のパラメータを最適化したり,他の指標判断を追加することによって軽減できます.

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

戦略は,次の側面でも最適化できます.

  1. 他の指標判断を組み合わせた戦略に追加し,安定性を向上させる
  2. 市場からの逸脱を避けるため,市場全体の傾向判断を追加する
  3. 超トレンド指標のパラメータを最適化し,最高の長さとファクタを見つけます
  4. トレンドとともにストップ損失を追うようなストップ損失戦略を調整
  5. 異なる製品でテストして 最高のマッチを見つける

結論

概要すると,これはBankNifty 5分チャートに基づいたスーパートレンド指標取引戦略である.トレンド方向を決定するためにスーパートレンド指標を使用し,取引セッションとリスク管理ルールを組み合わせて取引する.複雑な定量戦略と比較して,この戦略は理解し実行しやすいシンプルで明確なルールを持っています.サンプル戦略として,将来の最適化と改善のための基礎と方向性を提供します.継続的な精製と強化を通じて,戦略が信頼性と収益性の高い定量取引戦略になることができることを望みます.


/*backtest
start: 2023-11-28 00:00:00
end: 2023-12-28 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5
strategy("BankNifty 5min Supertrend Based Strategy, 09:15 Entry with Date Range and Risk Management")

// Session and date range input variables
session = input("0915-1510", "Session", group="Indian Session Time")
start_date = input(title="Start Date", defval=timestamp("01 Jan 2022 00:00:00"), group="Backtest Specific Range")
end_date = input(title="End Date", defval=timestamp("01 Dec 2023 23:59:59"))
atrPeriod = input(50, "ATR Length", group="SuperTrend Setting")
factor = input.float(3.0, "Factor", step=0.1)

useDelay = input(true, "Use Delay?", group="Delay at Session Start")
Delay = useDelay ? input(10, title="Delay N numbers of candle", group="Delay at Session Start") : na

useDelay_stopLoss = input(true, "Use Stoploss Points?", group="Risk Management")
stopLoss = useDelay_stopLoss ? input(100, "Stop Loss Points", group="Risk Management"): na

useDelay_stopLossPerc1 = input(true, "Use Stoploss Trail?", group="Risk Management")
stopLossPerc1 =useDelay_stopLossPerc1 ? input.float(0.1, "Stop Loss Trail%", step=0.1,maxval = 1, group="Risk Management"): na
// Check if current time is within the specified session and date range
inSession = true

[supertrend, direction] = ta.supertrend(factor, atrPeriod)

// Wait for 3 candles to form at the start of every session
var candlesFormed = 0
if inSession and not inSession[1]
    candlesFormed := 1
else if inSession and candlesFormed > 0
    candlesFormed := candlesFormed + 1
else
    candlesFormed := 0


//

// Only enter trades if 3 candles have formed at the start of the session
entryce = (ta.change(direction) < 0) or (candlesFormed >= Delay and direction < 0)
exitce = ta.change(direction) > 0
entrype = (ta.change(direction) > 0) or (candlesFormed >= Delay and direction > 0)
exitpe = ta.change(direction) < 0
var entryPrice = 0.0
if entryce and inSession
    // Enter long trade
    onePercent = strategy.position_avg_price *stopLossPerc1
    entryPrice := close
    strategy.entry("My Long Entry Id", strategy.long, comment="long" )
    // Set stop loss at x% below entry price
    strategy.exit("My Long Exit Id", "My Long Entry Id", stop=(entryPrice - stopLoss),trail_points=onePercent )
    
if entrype and inSession
    onePercent1 = strategy.position_avg_price *stopLossPerc1
    entryPrice := close
    // Enter short trade
    strategy.entry("My Short Entry Id", strategy.short, comment="short")
    // Set stop loss at x% above entry price
    strategy.exit("My Short Exit Id", "My Short Entry Id", stop=(entryPrice + stopLoss),trail_points=onePercent1)

// Close all trades at end of session
if not inSession and strategy.opentrades > 0
    strategy.close_all()

// Plot Supertrend with changing colors
plot(supertrend, title="Supertrend", color=direction == 1 ? color.red : color.green, linewidth=2)





もっと