OPEN-SOURCE SCRIPT

Market structure

アップデート済
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):
スナップショット

スナップショット

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!
リリースノート
- Use my new library 'MarketStructure' (tradingview.com/script/tqFlUGel-MarketStructure/)
- Bump Pine Script version to 6
リリースノート
- Remove unused setting for alert frequency
- Fix tags
リリースノート
- 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.

スナップショット

- 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.
リリースノート
- Bump 'MarketStructure' to 5 which contains buggfix for when a pivot with lower/higher price to cause an invalid break of structure
リリースノート
- 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`
リリースノート
Change how the break of structure is drawn. Don't need to check if the pivot is the latest and only delete the ones on the 'wrong side'. Higher low price in a downtrend and lower high in an uptrend. This is possible through the bump of 'MarketStructure' to 8.

It changes the behaviour of a break of structure. The first image is how it used to be and the second is how it will be now:

スナップショット

スナップショット

As you can see the later pivot break is now shown as the break of structure (because it has the lowest price).

Hope this update finds you well, good luck trading!
リリースノート
This update will keep pivots for change of characters if they are 'within' the break of that pivot and the pivot point itself. All pivots will be disabled (when a CHoCH happens) for break of structures. This will have the effect that low pivots in the bullish trends will now cause a CHoCH to a bearish trend, like this:

From this
スナップショット

To this
スナップショット

This will however also cause false CHoCHs like this:

From this
スナップショット

To this
スナップショット

As you can see in the images the indicator now creates a CHoCH to a bearish trend. This turns out to be false and causes a trend change back to bullish.

This is done through the library 'MarketStructure' that is now at version 9.

Hope that this change makes sense!
リリースノート
- Add an area between the latest high and low pivot. This could be the current trading range of the pivots break some sort of structure, like a break of structure or a change of character. As it is now it's not taken into consideration if the latest high/low pivot has a structure break. I might be able to change this in the future, unfortunately not now though.
- Change back the default pivot length to 50 on the swing market structure.
リリースノート
- Introduce the concept of "CHoCH+" also called Change of Character plus. Labels for a change of character can now have either the text "CHoCH" or "CHoCH+". A Change of Character plus is formed when price fails to form a higher high or a lower low before reversing. Note that a pivot that is created after the change of character might have a higher high or a lower low, thus not making the break a "CHoCH+". This is not changed after the pivot is found but is kept as is. This is done through the library 'MarketStructure'.
marketstructurepriceactionsupportandresitanceTrend Analysis

オープンソーススクリプト

TradingViewの精神に則り、このスクリプトの作者は、トレーダーが理解し検証できるようにオープンソースで公開しています。作者に敬意を表します!無料で使用することができますが、このコードを投稿で再利用するには、ハウスルールに準拠する必要があります。 お気に入りに登録してチャート上でご利用頂けます。

チャートでこのスクリプトを利用したいですか?

免責事項