KF Market Structure
- 指标
- 版本: 1.0
KF Market Structure — Smart Money Concepts Trend & Breakout Analyzer
KF Market Structure is a clean, rule-based Smart Money Concepts (SMC) indicator for MetaTrader 5 that automatically detects and visualizes market structure: Swing Highs, Swing Lows, Break of Structure (BOS), and Change of Character (CHoCH). Built strictly for closed bar evaluation, it provides an objective structural baseline for Price Action traders and automated trading strategies without erratic signals.
Whether you trade Forex, Gold, or Crypto, understanding whether the current move is a trend continuation (BOS) or a structural trend reversal (CHoCH) is essential. KF Market Structure gives you crisp chart lines, clear text annotations, and dedicated data buffers ready for Expert Advisor (EA) integration via iCustom.
KEY FEATURES
- Closed Bar Evaluation: Evaluates strictly closed bars (shift 1 and older). The live forming candle (shift 0) never produces permanent structural signals.
- Strict Closing-Price Break: Penumbra/wicks crossing swing levels without a closing price break are treated as liquidity sweeps/wicks, not structural breaks.
- Objective Trend Engine: Tracks market state transitions between Bullish (+1.0), Bearish (-1.0), and None (0.0).
- Trend Continuation (BOS): Marks breakouts in the direction of the prevailing trend as Break of Structure (BOS).
- Structural Reversal (CHoCH): Marks the first breakout against the prevailing trend as Change of Character (CHoCH).
- Visual Chart Overlays: Displays break lines and text tags ("BOS" / "CHoCH") with customizable colors and dash styles.
- Automatic Chart Cleanup: Chart objects are automatically limited (default 200) and completely removed upon deinitialization.
- Multi-Channel Notifications: Pop-up alerts, sound notifications, and mobile push notifications for closed-bar breaks with baseline anti-spam guards.
- Lightweight & Backtest Safe: Core calculations are separated from visual rendering; visual objects are skipped during non-visual backtesting to maintain fast execution.
INDICATOR BUFFERS FOR EXPERT ADVISORS (iCustom)
Automate your trading by reading dedicated buffers via iCustom:
- Buffer 0 (Plot 0): Swing High price level (High price of confirmed swing bar; EMPTY_VALUE otherwise)
- Buffer 1 (Plot 1): Swing Low price level (Low price of confirmed swing bar; EMPTY_VALUE otherwise)
- Buffer 2 (Calculations): Structure Signal Code on the breakout bar:
* +1.0 = Bullish BOS (Trend continuation)
* -1.0 = Bearish BOS (Trend continuation)
* +2.0 = Bullish CHoCH (Trend reversal from Bearish to Bullish)
* -2.0 = Bearish CHoCH (Trend reversal from Bullish to Bearish)
* +3.0 = Initial Bullish Break (First trend initialization from neutral state)
* -3.0 = Initial Bearish Break (First trend initialization from neutral state)
* 0.0 = No breakout
- Buffer 3 (Calculations): Active Market Trend:
* +1.0 = Bullish
* -1.0 = Bearish
* 0.0 = None / Undetermined
TECHNICAL NOTE ON SWING CONFIRMATION
A swing point at bar k requires N subsequent bars to close before it is objectively confirmed. Consequently, confirmed swing arrows appear N bars after the actual peak/trough formed. Once plotted, swing levels are immutable. Breakout signals (Buffer 2) appear immediately on the closed breakout candle (bar 1).
INPUT PARAMETERS
- Swing Confirmation Length (N Bars): Number of bars required on each side to confirm a swing pivot (default: 3).
- Max History Bars to Scan: Historical depth scanned for structure analysis (default: 500).
- Show Swing Points (High/Low): Toggle arrows on confirmed swing points.
- Draw Break Structure Lines: Toggle horizontal lines from broken swings to the breakout bar.
- Show Structure Labels (BOS/CHoCH): Toggle text annotations on breakout candles.
- Maximum Chart Objects Limit: Upper cap for active chart objects to ensure smooth rendering (default: 200).
- Bullish Structure Color: Color for bullish lines and tags (default: DodgerBlue).
- Bearish Structure Color: Color for bearish lines and tags (default: Crimson).
- Structure Line Style: Line style for break levels (default: DASH).
- Structure Line Width: Line thickness (default: 1).
- Alert Dialog Popup: Terminal pop-up alert on new closed bar break.
- Push Notifications to Mobile: MetaTrader 5 mobile push notifications.
- Play Sound Alert: Audio chime alert.
- Sound File Name: Audio file name (default: "alert.wav").
RECOMMENDED ECOSYSTEM PRODUCTS
Looking for advanced Smart Money Concepts features like Fair Value Gaps (FVG) and Order Blocks? Explore our upcoming institutional suite on MQL5 Market:
- KF Candle Scanner — Rule-based candlestick pattern scanner (available now on MQL5 Market).
- KF Spread Swap Monitor — Real-time spread and swap tracking utility (available now on MQL5 Market).
REQUIREMENTS
- MetaTrader 5 Terminal (Build 4000 or higher).
- Works on all standard timeframes (M1 to MN1).
- Compatible with all major Forex pairs, Gold (XAUUSD), Indices, and Crypto.
- No DLLs or external dependencies required.
RISK WARNING
Trading foreign exchange, commodities, and financial instruments involves substantial risk and is not suitable for all investors. Market structure mapping and swing levels are interpretative technical indicators based on historical price data. Past performance and backtest results do not guarantee future performance.
