OPEN-SOURCE SCRIPT

Market structure

Mis à jour
Hi all!

This script shows you the market structure. You can choose to show internal market structure (with pivots of a default length of 5) and swing market structure (with pivots of a default length of 50). For these two trends it will show you:
• Break of structure (BOS)
• Change of character (CHoCH) (mandatory)
• Equal high/low (EQH/EQL)

It's inspired by "Smart Money Concepts (SMC) [LuxAlgo]" by LuxAlgo that will also show you the market structure.

It will create the two market structures depending on the pivots found. Both of these market structures can be enabled/disabled. The pivots length can be configured separately. The pivots found will be the 'base' of this indicator and will show you when price breaks it. When that happens a break of structure or a change of character will be created. The latest 5 pivots found within the current trends will be kept to take action on. The internal market structure is shown with dashed lines and swing market structure is shown with solid lines.

A break of structure is removed if an earlier pivots within the same trend is broken. Like in the images below, the first pivot (in the first image) is removed when an earlier pivot's higher price within the same trend is broken (the second image):
snapshot

snapshot

Equal high/lows have a pink zone (by default but can be changed by the user). These zones can be configured to be extended to the right (off by default). Equal high/lows are only possible if it's not been broken by price and if a later bar has a high/low within the limit it's added to the zone (without it being more 'extreme' (high or low) then the previous price). A factor (percentage of width) of the Average True Length (of length 14) that the pivot must be within to to be considered an Equal high/low. This is configurable and sets this 'limit' and is 10 by default.

You are able to show the pivots that are used. "HH" (higher high), "HL" (higher low), "LH" (lower high), "LL" (lower low) and "H"/"L" (for pivots (high/low) when the trend has changed) are the labels used.

This script has proven itself useful for me to quickly see how the current market is. You can see the pivots (price and bar) where break of structure or change of character happens to see the current trends. I hope that you will find this useful for you.

When programming I focused on simplicity and ease of read. I did not focus on performance, I will do so if it's a problem (haven't noticed it is one yet).

You can set alerts for when a change of character happens. You can configure it to fire on when it happens (all or once per bar) but it defaults to 'once_per_bar_close' to avoid repainting. This has the drawback to alert you when the bar closes.

TLDR: this is an indicator showing you the market structure (break of structures and change of characters) using swing points/pivots. Two trends can be shown, internal (with pivots of length of 5) and swing (with pivots of the length of 50).

Best of trading luck!
Notes de version
- Use my new library 'MarketStructure' (tradingview.com/script/tqFlUGel-MarketStructure/)
- Bump Pine Script version to 6
Notes de version
- Remove unused setting for alert frequency
- Fix tags
Notes de version
- Add liquidation. The indicator will create lines and zones for spotted liquidity. It will draw a line (with dotted style) at the price level that was liquidated, but is will also draw a zone from that level to the bar that broke the pivot high or low price. If that zone is large the liquidation is big and might be significant. This can be disabled in the settings. You can also change the confirmation candles (that does not close above or below the pivot level) needed after a liquidation and how many pivots back to look at.

The lines and boxes drawn will have orange colors.

snapshot

- Bump 'MarketStructure' to 4

- Remove the setting for 'Source'. Before you were able to set the source of structure changes. It will now always use the close value.
Notes de version
- Bump 'MarketStructure' to 5 which contains buggfix for when a pivot with lower/higher price to cause an invalid break of structure
Notes de version
- Change default pivot lengths to 5 and 15 (has been 5/50 and 3/15)
- Bump 'MarketStructure" to 7 which contains:
  • Add alerts to break of structure and equal high/low
  • Remove 'ChangeOfCharcterBroken'. Pivots are now cleared when a change of character happens. This means that no break of stucture or change of character can happen on a pivot that was befor the change of character.
  • To figure out if the current pivot was the latest of its type (high or low) the library now uses the last `bar_index`
marketstructurepriceactionsupportandresitanceTrend Analysis

Script open-source

Dans le plus pur esprit TradingView, l'auteur de ce script l'a publié en open-source, afin que les traders puissent le comprendre et le vérifier. Bravo à l'auteur! Vous pouvez l'utiliser gratuitement, mais la réutilisation de ce code dans une publication est régie par nos Règles. Vous pouvez le mettre en favori pour l'utiliser sur un graphique.

Vous voulez utiliser ce script sur un graphique ?

Clause de non-responsabilité