日中のトレンドブレイク戦略

作者: リン・ハーンチャオチャン, 日付: 2023-09-18 13:11:51
タグ:

概要

これは,スーパートレンド指標に基づいて戦略をフォローする日中の短期トレンドです.ユーザーは,戦略が実行される日中の取引セッションを定義できます.

この戦略では,シグナルが変化するときに2倍の量を使用してポジションを逆転させ,イントラデイセッションの終わりに開いたポジションを正方形にします.

戦略の論理

  1. ユーザが定義した倍数とATR期間に基づいてスーパートレンド指標を計算する.

  2. サポートとレジスタンスとしてスーパートレンドラインを描画します.

  3. ロング/ショート条件を決定します. スーパートレンドラインの上の閉じる状態はロング状態です. スーパートレンドラインの下の閉じる状態はショート状態です.

  4. 現在のバーがユーザーによって定義された日内セッション内にあるかどうかを確認します.

  5. 長期・短期信号は,日内セッションが活発で,長期・短期条件が満たされている場合にのみ発行する.

  6. スーパートレンドの方向が変わるときに,対照的な取引を倍数で行うことでポジションを逆転します.

  7. スーパートレンドの方向性が変わらず,日中のセッションが終了したときのオープンポジションを平方にします.

利点分析

  1. スーパートレンドはトレンドを特定し 誤った信号を減少させます

  2. スーパートレンドと 接近価格を組み合わせると 早期に停止されないのです

  3. ポジションをタイムリーに逆転させると損失が減ります

  4. 日中のセッションは夜間リスクを回避します

  5. 強制出口は,クォーターを消すのを忘れてしまう危険を回避します.

リスク分析

  1. 不適切なスーパートレンドパラメータは 戦略の不良なパフォーマンスにつながります

  2. 取引頻度とコストを増加させる.

  3. セッション終了時に強制退場すると 損失が起こる可能性があります

  • リスク1はパラメータの最適化によって軽減できる.

  • リスク2はストップ・ロスを通して制御できる.

  • リスク3は,ストップ・ロストまたはトレンド・フィルターを使用して回避できます.

増進 の 機会

  1. MA,KDJなど様々な傾向指標をテストします

  2. ストップ・ロスト・ロジックを追加します

  3. トレンドフィルターを追加して 強制退出損失を回避します

  4. マルチプリキュアとATR期間パラメータを最適化します

  5. 異なる機器でテストする

結論

この戦略は,短期的なトレンドブレイクを資本するためにスーパートレンドとイントラデイセッション管理を組み合わせます.ポジション逆転と強制退出はリスクを効果的に制御します.パラメータ最適化,ストップ損失,トレンドフィルタリングを通じてさらなる改善が可能です.


/*backtest
start: 2023-08-18 00:00:00
end: 2023-09-17 00:00:00
period: 1h
basePeriod: 15m
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/
// © Pritesh-StocksDeveloper

//@version=4
strategy("Supertrend - Intraday", overlay=true, calc_on_every_tick = true)

// ********** Strategy inputs - Start **********

// Used for intraday handling
// Session value should be from market start to the time you want to square-off 
// your intraday strategy
// Important: The end time should be at least 2 minutes before the intraday
// square-off time set by your broker
var i_marketSession = input(title="Market session", type=input.session, 
     defval="0915-1455", confirm=true)

var float i_multiplier = input(title = "Multiplier", type = input.float, 
     defval = 4, confirm=true)

var int i_atrPeriod = input(title = "ATR Period", type = input.integer, 
     defval = 14, confirm=true)

// ********** Strategy inputs - End **********


// ********** Supporting functions - Start **********

// A function to check whether the bar or period is in intraday session
barInSession(sess) => time(timeframe.period, sess) != 0

// ********** Supporting functions - End **********


// ********** Strategy - Start **********

[superTrend, dir] = supertrend(i_multiplier, i_atrPeriod)

colResistance = dir == 1 and dir == dir[1] ? color.new(color.red, 0) : color.new(color.red, 100)
colSupport = dir == -1 and dir == dir[1] ? color.new(color.green, 0) : color.new(color.green, 100)

plot(superTrend, color = colResistance, linewidth=2)
plot(superTrend, color = colSupport, linewidth=2)

// Long/short condition
longCondition = close > superTrend
shortCondition = close < superTrend

// See if intraday session is active
bool intradaySession = barInSession(i_marketSession)

// Trade only if intraday session is active
 
// Long position
// When longCondition and intradaySession both are true
strategy.entry(id = "Long", long = strategy.long, 
     when = longCondition and intradaySession)
 
// Short position
// When shortCondition and intradaySession both are true
strategy.entry(id = "Short", long = strategy.short, 
     when = shortCondition and intradaySession)
 
// Square-off position (when session is over and position is open)
squareOff = (not intradaySession) and (strategy.position_size != 0)
strategy.close_all(when = squareOff, comment = "Square-off")

// ********** Strategy - End **********

もっと