OPEN-SOURCE SCRIPT

Contrarian Market Structure Break

202
Market Structure Break application was inspired and adapted from Market Structure Oscillator indicator developed by Lux Algo. So much credit to their work.

This indicator pairs nicely with the Contrarian 100 MA and can be located here:
Contrarian 100 MA




Indicator Description: Contrarian Market Structure BreakOverview

The "Contrarian Market Structure Break" indicator is a versatile tool tailored for traders seeking to identify potential reversal opportunities by analyzing market structure across multiple timeframes. Built on Institutional Concepts of Structure (ICT), this indicator detects Break of Structure (BOS) and Change of Character (CHoCH) patterns across short-term, intermediate-term, and long-term swings, plotting them with customizable lines and labels. It generates contrarian buy and sell signals when price breaks key swing levels, with a unique "Blue Dot Tracker" to monitor consecutive buy signals for trend confirmation. Optimized for the daily timeframe, this indicator is adaptable to other timeframes with proper testing, making it ideal for traders of forex, stocks, or cryptocurrencies.

How It Works
The indicator combines three key components to provide a comprehensive view of market dynamics: Multi-Timeframe Market Structure Analysis: It identifies swing highs and lows across short-term, intermediate-term, and long-term periods, plotting BOS (continuation) and CHoCH (reversal) events with customizable line styles and labels.

Contrarian Signal Generation: Buy and sell signals are triggered when the price crosses below swing lows (buy) or above swing highs (sell), indicating potential reversals in overextended markets.

Blue Dot Tracker: A unique feature that counts consecutive buy signals ("blue dots") and highlights a "Hold Investment" state with a yellow background when three or more buy signals occur, suggesting a potential trend continuation.

Signals are visualized as small circles below (buy) or above (sell) price bars, and a table in the bottom-right corner displays the blue dot count and recommended action (Hold or Flip Investment), enhancing decision-making clarity.

Mathematical Concepts Swing Detection: The indicator identifies swing highs and lows by comparing price patterns over three bars, ensuring robust detection of pivot points. A swing high occurs when the middle bar’s high is higher than the surrounding bars, and a swing low occurs when the middle bar’s low is lower.

Market Structure Logic: BOS is detected when the price breaks a prior swing high (bullish) or low (bearish) in the direction of the current trend, while CHoCH signals a potential reversal when the price breaks a swing level against the trend. These are calculated across three timeframes for a multi-dimensional perspective.

Blue Dot Tracker: This feature counts consecutive buy signals and tracks the entry price. If three or more buy signals occur without a sell signal, the indicator enters a "Hold Investment" state, marked by a yellow background, until the price exceeds the entry price or a sell signal occurs.

Entry and Exit Rules Buy Signal (Blue Dot Below Bar): Triggered when the closing price crosses below a swing low on either the intermediate-term or long-term timeframe, suggesting an oversold condition and potential reversal upward. Short-term signals can be enabled but are disabled by default to reduce noise.

Sell Signal (White Dot Above Bar): Triggered when the closing price crosses above a swing high on either the intermediate-term or long-term timeframe, indicating an overbought condition and potential reversal downward.

Blue Dot Tracker Logic: After a buy signal, the indicator increments a blue dot counter and records the entry price. If three or more consecutive buy signals occur (blueDotCount ≥ 3), the indicator enters a "Hold Investment" state, highlighted with a yellow background, suggesting a potential trend continuation. The "Hold Investment" state ends when the price exceeds the entry price or a sell signal occurs, resetting the counter.

Exit Rules: Traders can exit buy positions when a sell signal appears, the price exceeds the entry price during a "Hold Investment" state, or based on additional confirmation from BOS/CHoCH patterns or other technical analysis tools. Always use proper risk management.

Recommended Usage
The indicator is optimized for the daily timeframe, where it effectively captures significant reversal and continuation patterns in trending or ranging markets. It can be adapted to other timeframes (e.g., 1H, 4H, 15M) with careful testing of settings, particularly enabling/disabling short-term structure analysis to suit market conditions. Backtesting is recommended to optimize performance for your chosen asset and timeframe.

Customization Options Market Structure Display: Toggle short-term, intermediate-term, and long-term structures on or off, with customizable line styles (solid, dashed, dotted) and colors for bullish and bearish breaks.

Labels: Enable or disable BOS/CHoCH labels for each timeframe to reduce chart clutter.
Signal Visibility: Hide buy/sell signals if desired for a cleaner chart.
Blue Dot Tracker: Monitor the blue dot count and action (Hold or Flip Investment) via the table display, which is fully customizable in terms of position and appearance.

Why Use This Indicator?
The "Contrarian Market Structure Break" indicator offers a robust framework for identifying high-probability reversal and continuation setups using ICT principles. Its multi-timeframe analysis, clear signal visualization, and innovative Blue Dot Tracker provide traders with actionable insights into market dynamics. Whether you're a swing trader or a day trader, this indicator’s flexibility and intuitive design make it a valuable addition to your trading arsenal.

Note for TradingView Moderators
This script complies with TradingView's House Rules by providing an educational and transparent description without performance claims or guarantees. It is designed to assist traders in technical analysis and should be used alongside proper risk management and personal research. The code is original, well-documented, and includes customizable inputs and clear visual outputs to enhance the user experience.

Tips for Users:
Backtest thoroughly on your chosen asset and timeframe to validate signal reliability. Combine with other indicators or price action analysis for confirmation of entries and exits. Adjust timeframe settings and enable/disable short-term structures to match market volatility and your trading style.

Hope the "Contrarian Market Structure Break" indicator enhances your trading strategy and helps you navigate the markets with confidence! Happy trading!

Penafian

Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.