
ダイナミックタイムフィルター サポート/レジスタンス トラッキング ストップレード取引システムは,精密な入場信号,スマートタイムフィルター,自己適応のリスク管理を組み合わせた高度な量化取引戦略である.このシステムは,特定の時間ウィンドウ内で高確率の取引機会を特定しようとするトレーダーのために設計され,ダイナミックタイムフィルター ストップレードと部分ポジション管理技術を採用して取引パフォーマンスを最適化します.戦略の核心は,サポートとレジスタンス ポジションのダイナミックな識別によって,取引時間フィルターと取引量確認を組み合わせて,正確な取引信号を提供することです.
この戦略の基本原則は,精密な入学,最適な時間,状態の管理という3つのコア要素の協同作用に基づいています.
入学システム: 策略は,重要な価格レベルを動的に識別して逆転の機会を探します.それは,サポートとレジスタンスを計算するために構成可能な逆転期を使用し,価格がこれらの重要な領域と相互作用するときにエントリーシグナルを誘発します.エントリー条件は,価格とサポート/レジスタンスレベルとの相互作用,取引量確認,および選択可能なトレンドフィルター確認を含む.価格がサポートレベルに接触し,取引量が平均より高く,取引量が平均より高く,取引がサポートバッファローズよりも高いときに,システムは複数の信号を生成します.
タイムフィルタリング: 戦略は,取引者が最適な取引時間を定義できるように,包括的な時間フィルタリングシステムを実装しています.
リスク管理システム: 戦略は3つのレベルでのリスク管理を行っています.
この戦略は,コードを深く分析することで,以下の利点があります.
統合入口信号: 価格行動,取引量確認,トレンド一致性との組み合わせにより,取引信号の信頼性が向上する. システムは,重要なサポート値とレジスタンス値の近くに高い確率の逆転点を探し,偽の突破のリスクを軽減する.
フレキシブルな時間フィルタリング: 取引者が最適な取引時間に焦点を当て,低流動性または高変動の市場環境を避ける. これは取引効率を向上させ,不利な市場条件下で取引する可能性を減らすのに役立ちます. 多時間帯取引とカスタム取引時間設定をサポートし,世界中の取引者に適用できます.
アドバンストなリスク管理機能: ダイナミック・トラッキング・ストップ・システムは,市場の波動に自動的に調整し,利益を保護し,有利なポジションを継続させるのに役立ちます. 多層のストップ・ターゲットと部分的な平仓オプションは,異なる価格レベルで利益をロックすることを可能にします.
全面的な視覚的フィードバック詳細なグラフ要素とリアルタイムメジャーボードが提供され,市場状況と戦略のパフォーマンスをトレーダーに直感的に理解できます. 入場エリアの突出表示,ダイナミックなリスク/リターンラインとストップ・ロスの可視化が取引意思決定プロセスをより透明にします.
高度なカスタマイズ性戦略は,コア戦略パラメータから時間フィルタ制御,リスク管理オプションまで,さまざまな取引スタイルと市場条件に適応する幅広いカスタマイズ能力を提供します.
この戦略には多くの利点があるものの,いくつかの潜在的なリスクがあります.
パラメータ最適化のリスク策略は,逆行期,ATR倍数,トレンドフィルター設定などの複数のパラメータ設定に依存します. これらのパラメータは,異なる市場環境に対応するために,注意深く最適化され,定期的に調整する必要があります.パラメータの過剰最適化は,将来の市場条件に不適切なパフォーマンスを引き起こす可能性があります.
市場条件の感受性: 波動性が高い市場や流動性が低い市場では,サポートとレジスタンスレベルは予想以上に信頼できないかもしれません. 極端な市場条件では,価格が急激に重要なレベルを突破して,ストップが引き起こされる可能性があります.
タイムフィルター制限タイムフィルタは,不利な取引時間を回避するのに役立ちますが,いくつかの高品質の取引機会を逃す可能性があります. 市場は,特に重要なイベントや突発的なニュース中に,常に既定の時間パターンを遵守しません.
ストップ・トラップを追跡する: 動的市場では,動的追跡ストップが早期に誘発され,本来有利な取引が早期に終了する可能性があります. 異なる追跡ストップ設定 (保守的,均衡的,激進的) は,異なる市場環境で異なるパフォーマンスを発揮します.
信号の衝突: 価格が複数のサポートとレジスタンスレベルに近づいたり,時間フィルタが入場シグナルと衝突したときに,混合シグナルが発生する可能性があります. これは,追加の判断やより複雑な決定ルールを必要とします.
コード分析により,以下のような最適化方向が考えられます.
適応パラメータの調整: 最近の市場波動性と取引のパフォーマンスに合わせて,逆転期とATR倍数などの重要なパラメータを自動的に調整するメカニズムを実現する.これは,手動の介入を必要とせずに,異なる市場環境に戦略をうまく適応させるのに役立ちます.
市場構造分析の強化より複雑な価格構造の識別方法,例えば,より高いレベルのサポートとレジスタンス領域の特定,トレンドチャネルまたは価格形態の識別を統合する.これは入場信号の質と信頼性を向上させることができる.
タイムフィルタリングを最適化する:データ分析により特定の市場の最適な取引時間を特定し,歴史的なパフォーマンスに応じて取引時間ウィンドウを自動的に調整する.季節的なパターンと市場特定のイベント (経済データ発表など) の統合を考慮するフィルタリング.
リスク管理の改善: よりスマートなポジション管理システムを設計し,歴史の変動,現在の市場条件,戦略のパフォーマンスに応じてポジションのサイズを動的に調整する. 利潤の取引に利潤のパーセントに基づいた階層的な平仓戦略を追加する.
統合された機械学習モデル: 機械学習アルゴリズムを使用して,サポートとレジスタンス位置の信頼性を予測するか,特定の市場条件下での入場信号の成功確率を推定する. これは潜在的に低品質の取引信号をフィルターするのに役立ちます.
ダイナミックタイムフィルター サポート レジスタンス トラッキング ストップ・ローズ取引システムは,正確な入場信号,インテリジェントなタイムフィルター,自己適応のリスク管理を組み合わせた,機能的な取引戦略である.それは,時間フィルターと交付量確認を活用しながら,重要なサポートとレジスタンスで高確率の逆転機会を探し,取引品質を向上させる.
この戦略の主要な優位性は,包括的な時間フィルタリングシステム,ダイナミック・トラッキング・ストップ・ローズ技術,高度にビジュアル化されたユーザー・インタフェースにあります.これらの機能は,様々な市場条件と取引スタイルに適した強力で柔軟な取引ツールを作成します.
しかし,この戦略の潜在力を最大限に発揮するためには,トレーダーは,異なる市場環境におけるそのパフォーマンス特性を理解し,慎重にパラメータを最適化する必要があり,特定の市場と個人の取引目標に応じてカスタマイズされた調整が必要になる可能性があります.推奨された最適化措置を実行することにより,戦略の性能と強性をさらに高め,トレーダーにより信頼性の高い市場分析と取引実行ツールを提供することができます.
/*backtest
start: 2025-08-13 00:00:00
end: 2025-08-20 00:00:00
period: 10m
basePeriod: 10m
exchanges: [{"eid":"Futures_OKX","currency":"ETH_USDT","balance":5000}]
*/
//@version=5
strategy("FlowStateTrader", overlay=true)
// Input Parameters
lookbackPeriod = input.int(20, "Lookback Period for Key Levels", minval=5, maxval=100)
atrPeriod = input.int(14, "ATR Period", minval=5, maxval=50)
atrMultiplierSL = input.float(1.5, "SL ATR Multiplier", minval=0.5, maxval=5.0, step=0.1)
atrMultiplierTP1 = input.float(1.5, "TP1 ATR Multiplier", minval=0.5, maxval=5.0, step=0.1)
atrMultiplierTP2 = input.float(2.0, "TP2 ATR Multiplier", minval=0.5, maxval=5.0, step=0.1)
rewardToRisk = input.float(2.0, "Reward to Risk Ratio", minval=1.0, maxval=5.0, step=0.1)
// Trend Filter Settings
enableTrendFilter = input.bool(true, "Enable Trend Filter")
trendMAPeriod = input.int(20, "Trend MA Period", minval=5, maxval=200)
trendMAType = input.string("EMA", "Trend MA Type", options=["EMA", "SMA"])
// TIME FILTER SETTINGS
enableTimeFilter = input.bool(false, "Enable Time-Based Filter", tooltip="Filter trades based on specific time windows")
// 12-hour format time inputs
startHour12 = input.int(9, "Start Hour (1-12)", minval=1, maxval=12, tooltip="Trading start hour in 12-hour format")
startAMPM = input.string("AM", "Start AM/PM", options=["AM", "PM"])
endHour12 = input.int(4, "End Hour (1-12)", minval=1, maxval=12, tooltip="Trading end hour in 12-hour format")
endAMPM = input.string("PM", "End AM/PM", options=["AM", "PM"])
// Timezone selection
timeZone = input.string("UTC", "Time Zone", options=["UTC", "EST", "PST", "CST"], tooltip="Time zone for trading hours")
// Additional controls
avoidLunchHour = input.bool(true, "Avoid Lunch Hour (12:00-1:00 PM)", tooltip="Skip trading during typical lunch break")
weekendsOnly = input.bool(false, "Weekends Only", tooltip="Only trade on weekends")
weekdaysOnly = input.bool(false, "Weekdays Only", tooltip="Only trade on weekdays")
// Strategy Settings
entryQty = input.int(10, "Entry Quantity (Contracts)", minval=1, maxval=1000)
enablePartialClose = input.bool(true, "Enable Partial Close at TP1")
partialCloseQty = input.int(1, "Contracts to Close at TP1", minval=1, maxval=100)
enableAlerts = input.bool(true, "Enable Strategy Alerts")
// Dashboard Settings
dashboardSize = input.string("Medium", "Dashboard Size", options=["Small", "Medium", "Large"], tooltip="Control the size of the information dashboard")
enableScorecard = input.bool(true, "Enable Performance Scorecard", tooltip="Show performance metrics in lower right corner")
// Trailing Stop Settings
enableTrailingStop = input.bool(true, "Enable Trailing Stop")
trailMode = input.string("Balanced", "Trailing Stop Mode", options=["Conservative", "Balanced", "Aggressive"], tooltip="Conservative: Protect more profit | Balanced: Good middle ground | Aggressive: Let winners run longer")
// Set trailing parameters based on mode
trailActivationMultiplier = trailMode == "Conservative" ? 0.8 : trailMode == "Balanced" ? 1.0 : 1.2
trailDistanceMultiplier = trailMode == "Conservative" ? 0.6 : trailMode == "Balanced" ? 0.8 : 1.0
// TIME FILTER FUNCTIONS
// Convert 12-hour format to 24-hour format
convertTo24Hour(hour12, ampm) =>
var int hour24 = na
if ampm == "AM"
hour24 := hour12 == 12 ? 0 : hour12
else // PM
hour24 := hour12 == 12 ? 12 : hour12 + 12
hour24
// Convert timezone to UTC offset
getUTCOffset(tz) =>
var int offset = na
if tz == "UTC"
offset := 0
else if tz == "EST"
offset := -5 // EST is UTC-5
else if tz == "CST"
offset := -6 // CST is UTC-6
else if tz == "PST"
offset := -8 // PST is UTC-8
offset
getCurrentHour() =>
hour(time, "UTC")
getCurrentDayOfWeek() =>
dayofweek(time)
isWeekend() =>
currentDay = getCurrentDayOfWeek()
currentDay == dayofweek.saturday or currentDay == dayofweek.sunday
isWeekday() =>
not isWeekend()
isInTradingWindow() =>
if not enableTimeFilter
true
else
// Convert 12-hour inputs to 24-hour UTC
startHour24 = convertTo24Hour(startHour12, startAMPM)
endHour24 = convertTo24Hour(endHour12, endAMPM)
utcOffset = getUTCOffset(timeZone)
// Convert local time to UTC
startHourUTC = (startHour24 - utcOffset + 24) % 24
endHourUTC = (endHour24 - utcOffset + 24) % 24
currentHour = getCurrentHour()
// Handle trading window logic
var bool inWindow = false
// Handle same-day window vs overnight window
if startHourUTC <= endHourUTC
// Same day window (e.g., 9 AM to 4 PM)
inWindow := currentHour >= startHourUTC and currentHour <= endHourUTC
else
// Overnight window (e.g., 10 PM to 6 AM)
inWindow := currentHour >= startHourUTC or currentHour <= endHourUTC
// Apply day-of-week filters
if weekendsOnly and not isWeekend()
inWindow := false
if weekdaysOnly and not isWeekday()
inWindow := false
// Apply lunch hour filter (12:00-1:00 PM in selected timezone)
if avoidLunchHour and inWindow
lunchStart24 = 12 // 12 PM
lunchEnd24 = 13 // 1 PM
lunchStartUTC = (lunchStart24 - utcOffset + 24) % 24
lunchEndUTC = (lunchEnd24 - utcOffset + 24) % 24
// Check if current hour falls in lunch period
if lunchStartUTC <= lunchEndUTC
// Normal case: lunch doesn't cross midnight
if currentHour >= lunchStartUTC and currentHour < lunchEndUTC
inWindow := false
else
// Edge case: lunch period crosses midnight (shouldn't happen but safety check)
if currentHour >= lunchStartUTC or currentHour < lunchEndUTC
inWindow := false
inWindow
// Combined time filter
isGoodTradingTime() =>
isInTradingWindow()
// ATR and Volume Calculation
atr = ta.atr(atrPeriod)
volumeSMA = ta.sma(volume, atrPeriod)
// Trend Filter
trendMA = enableTrendFilter ? (trendMAType == "EMA" ? ta.ema(close, trendMAPeriod) : ta.sma(close, trendMAPeriod)) : na
isBullishTrend = enableTrendFilter ? close > trendMA : true
isBearishTrend = enableTrendFilter ? close < trendMA : true
// Key Levels Identification (Support & Resistance Zones)
support = ta.lowest(low, lookbackPeriod)
resistance = ta.highest(high, lookbackPeriod)
supportBuffer = support - atr * 0.5
resistanceBuffer = resistance + atr * 0.5
// Define Entry Conditions (with time filter)
isBullishEntry = (close > supportBuffer) and (low <= support) and (volume > volumeSMA) and isBullishTrend and isGoodTradingTime()
isBearishEntry = (close < resistanceBuffer) and (high >= resistance) and (volume > volumeSMA) and isBearishTrend and isGoodTradingTime()
// Calculate Stop Loss and Take Profit Levels
bullishSL = support - atr * atrMultiplierSL
bullishTP1 = support + atr * rewardToRisk * atrMultiplierTP1
bullishTP2 = support + atr * rewardToRisk * atrMultiplierTP2
bearishSL = resistance + atr * atrMultiplierSL
bearishTP1 = resistance - atr * rewardToRisk * atrMultiplierTP1
bearishTP2 = resistance - atr * rewardToRisk * atrMultiplierTP2
// Strategy Position Management
var float longEntryPrice = na
var float shortEntryPrice = na
var bool tp1HitLong = false
var bool tp1HitShort = false
// Trailing Stop Variables
var float longTrailStop = na
var float shortTrailStop = na
var bool longTrailActive = false
var bool shortTrailActive = false
// Calculate position sizing
finalQty = entryQty
// Long Entry
if isBullishEntry and strategy.position_size == 0
strategy.entry("Long", strategy.long, qty=finalQty)
longEntryPrice := close
tp1HitLong := false
// Reset trailing stop variables
longTrailStop := na
longTrailActive := false
if enableAlerts
alert("Long Entry Signal at " + str.tostring(close) + " - Qty: " + str.tostring(finalQty), alert.freq_once_per_bar)
// Short Entry
if isBearishEntry and strategy.position_size == 0
strategy.entry("Short", strategy.short, qty=finalQty)
shortEntryPrice := close
tp1HitShort := false
// Reset trailing stop variables
shortTrailStop := na
shortTrailActive := false
if enableAlerts
alert("Short Entry Signal at " + str.tostring(close) + " - Qty: " + str.tostring(finalQty), alert.freq_once_per_bar)
// Long Position Management
if strategy.position_size > 0
// Calculate current profit
currentProfit = close - strategy.position_avg_price
profitInATR = currentProfit / atr
// Trailing Stop Logic
if enableTrailingStop and profitInATR >= trailActivationMultiplier
// Activate trailing stop
if not longTrailActive
longTrailActive := true
longTrailStop := close - atr * trailDistanceMultiplier
else
// Update trailing stop (only move up, never down)
newTrailStop = close - atr * trailDistanceMultiplier
longTrailStop := math.max(longTrailStop, newTrailStop)
// Determine which stop loss to use
effectiveStopLoss = enableTrailingStop and longTrailActive ? longTrailStop : bullishSL
// Stop Loss (either original or trailing)
strategy.exit("Long SL", "Long", stop=effectiveStopLoss)
// Take Profit 1 (Partial Close by Contracts)
if enablePartialClose and not tp1HitLong and high >= bullishTP1 and strategy.position_size >= partialCloseQty
strategy.close("Long", qty=partialCloseQty, comment="Long TP1", immediately=true)
tp1HitLong := true
// Take Profit 2 (Close Remaining Position) or Full Close if Partial is Disabled
if (enablePartialClose and tp1HitLong and high >= bullishTP2) or (not enablePartialClose and high >= bullishTP1)
strategy.close("Long", comment=enablePartialClose ? "Long TP2" : "Long TP1", immediately=true)
// Short Position Management
if strategy.position_size < 0
// Calculate current profit (for shorts, profit when price goes down)
currentProfit = strategy.position_avg_price - close
profitInATR = currentProfit / atr
// Trailing Stop Logic
if enableTrailingStop and profitInATR >= trailActivationMultiplier
// Activate trailing stop
if not shortTrailActive
shortTrailActive := true
shortTrailStop := close + atr * trailDistanceMultiplier
else
// Update trailing stop (only move down, never up)
newTrailStop = close + atr * trailDistanceMultiplier
shortTrailStop := math.min(shortTrailStop, newTrailStop)
// Determine which stop loss to use
effectiveStopLoss = enableTrailingStop and shortTrailActive ? shortTrailStop : bearishSL
// Stop Loss (either original or trailing)
strategy.exit("Short SL", "Short", stop=effectiveStopLoss)
// Take Profit 1 (Partial Close by Contracts)
if enablePartialClose and not tp1HitShort and low <= bearishTP1 and math.abs(strategy.position_size) >= partialCloseQty
strategy.close("Short", qty=partialCloseQty, comment="Short TP1", immediately=true)
tp1HitShort := true
// Take Profit 2 (Close Remaining Position) or Full Close if Partial is Disabled
if (enablePartialClose and tp1HitShort and low <= bearishTP2) or (not enablePartialClose and low <= bearishTP1)
strategy.close("Short", comment=enablePartialClose ? "Short TP2" : "Short TP1", immediately=true)
// Reset flags when position closes
if strategy.position_size == 0
tp1HitLong := false
tp1HitShort := false
// Reset trailing stop variables
longTrailStop := na
shortTrailStop := na
longTrailActive := false
shortTrailActive := false
// Visualization - Entry Zones
var box bullishBox = na
var box bearishBox = na
var label bullishZoneLabel = na
var label bearishZoneLabel = na
// Bullish Entry Zone
// Bearish Entry Zone
// Visualization - Risk/Reward Lines for Active Positions
var line longTP1Line = na
var line longTP2Line = na
var line longSLLine = na
var line shortTP1Line = na
var line shortTP2Line = na
var line shortSLLine = na
// Labels for TP/SL Values
// Short Position Lines and Labels
// Support and Resistance Lines
plot(support, "Support", color=color.green, linewidth=1, style=plot.style_line)
plot(resistance, "Resistance", color=color.red, linewidth=1, style=plot.style_line)
// Plot Trend MA if enabled
plot(enableTrendFilter ? trendMA : na, "Trend MA", color=color.blue, linewidth=2)
// Plot Trailing Stops if active
plot(strategy.position_size > 0 and longTrailActive ? longTrailStop : na, "Long Trail Stop", color=color.orange, linewidth=2, style=plot.style_stepline)
plot(strategy.position_size < 0 and shortTrailActive ? shortTrailStop : na, "Short Trail Stop", color=color.orange, linewidth=2, style=plot.style_stepline)