SimpleCryptoLife

[SCL] True Market Structure

See market structure at a glance with Higher Highs and Lower Lows. Bullish / Bearish /Ranging market bias is automatically derived. Optionally get alerted for breaks in market structure. Uses true Local Highs/Lows instead of simply the highest/lowest "pivot" for x bars. Can be useful as a support for learning market structure or for alerts for a change in structure while you're not at the computer.
Versionshinweise: Fixed some broken logic. It confirms Highs and Lows better now. This is why you keep the debug handy, kids.
Versionshinweise: Updated comments to match the fixed functions.
Note to the Pinescripters: I was having problems accessing past states of variables within functions using , which is why you'll see the workaround with variable_1, passing in a hardcoded .
Versionshinweise: Fixed a case where we could confirm fractals out of sequence.
Added a new setting: "Use Short Label Text"; off by default. This makes the label text much shorter and people will probably prefer it after they get used to the indicator.
Removed the setting to display market bias in labels, because it's superseded by the new setting.

Note about rogue wicks
If we get a candle with a high wick but a normal close, after a Local High but before that Local High is confirmed by the appropriate close, the high wick will never be counted as a Local High, even if it ends up coming in sequence after a Local Low.
Basically, candidates for Local Highs are only accepted AFTER the previous Local High is confirmed (or on the very same bar), and I'm probably going to keep it that way. Not only would it be extremely time-consuming to code and test doing it differently, I'm not convinced it would be the right thing to do.
Same thing goes for Lows.
This case is quite rare (I don't even have a screenshot handy). Also, note that forcing confirmations with a low number could change this behaviour and confirm the wick.
For any other cases where you think the script isn't picking out Highs and Lows correctly, please do drop a comment with a screenshot of the chart and your current settings.
Versionshinweise: Fixed the spelling on the short label text. Hat tip to @crossc for letting me know
Versionshinweise: Simplified the display mode inputs. There's only one colour scheme now, which is according to market bias. I think that's more useful than just red/green.

Added a minimalist mode, because having all the labels displayed when using the indicator regularly cluttered up the chart a bit. This mode only shows the most recent High and Low (the code that deletes old labels might be interesting if you need to script with labels printed in arbitrary locations). The defaults are the same as before.
Versionshinweise: Added a new display option. You can show only those breaks in market structure that are reversals, or you can show both reversal and continuation breaks.

For fun: find an asset that trends nicely and hide everything except reversal breaks.
Versionshinweise: Attempting to fix a user-reported issue with Bearish Breaks.
Versionshinweise: + Added a label to show the current market bias, with three settings: Short Text, Full Text, and Off. The label is coloured according to the bias.

+ Added an option to fill the background with the market bias colour.

With the range of visualisations now available, you can see market structure in as much or as little detail as you want, with the best chance of avoiding visual conflict with whatever other indicators you might be using.

+ Fixed the market bias to be set properly on breaks. Needed now it's more visible!

+ Increased the maximum number of labels shown to 100. If you want to do historical analysis, you can increase this number up to the system limit of 500 manually.

+ Added lines that show where price needs to close in order to flip market bias to bullish or bearish. You *could* also add lines to show the close needed to flip to ranging. If people want this feature I might add it.
NOTE: This feature repaints in the sense that it extends the line back in time to the High or Low that set that price.
Importantly, it can change intra-candle. A candle close is needed to confirm a Local High/Low, and while a candle is open it uses the current price as the "working close". So if we are in the very first candle of a changed market bias, the most recent Local High/Low is actually waiting for the current candle to close in order to be confirmed. If the current candle then reverses, the line will revert back to using the previously confirmed High/Low. Although this looks jarring when it happens, it's technically correct. Coding it to always use a High/Low that's confirmed on close instead is probably not worth the effort and would be less useful most of the time. The general principle is the same as for most indicators - for the current candle, Things Can Change until it's closed.

If you have questions, please read the full description of the settings in the top part of the script first.
Open-source Skript

Ganz im Sinne von TradingView hat der Autor dieses Skripts es als Open-Source veröffentlicht, damit Trader es verstehen und überprüfen können. Ein Hoch auf den Autor! Sie können es kostenlos verwenden, aber die Wiederverwendung dieses Codes in einer Publikation unterliegt den Hausregeln. Sie können das Skript den Favoriten hinzufügen, um es auf dem Chart zu verwenden.

Möchten Sie dieses Skript auf einem Chart verwenden?

Kommentare

Sir, i Appreciate you So Much
It is the Best Way to Identify Market Structure 👍
Antworten
@moayedi, Thanks for your appreciation. It took me a long time! I'm glad it's useful.
Antworten
This code with my Ichimoku knowledge is powerful as hell. Thanks for this!
Antworten
@JettaFX, Thanks for your kind comment. I'm glad that it's useful to you.
Antworten
True Market Structure, is such a great and well thought code/script. Thank you for your contribution to the community with this. I have a question as a trading associate and I have implemented this into our templates. The default setting for xBars is 20. My associate changed it 2 stating that it fits the higher timeframe (i.e. Daily TF) well thus when scaling down to lower timeframe it would give better insight on smaller structure breaks and would be more detailed in price action. SO my question what are your thoughts on this as you created the code, do you think using a smaller number of xBars would be of benefit, or is the default setting secured for all timeframes?
Antworten
SimpleCryptoLife TheEconomyCreator
@TheEconomyCreator, Thanks for your kind words and the sharp question. I'm afraid there is no "right" setting. It really is up to you and your trading style. Your associate is right that having a lower number of Force Confirmations will show more detail. But then, so would moving to a lower timeframe.
I opened this setting to the user so that people who wanted something more like the usual pivot indicators could have it. I believe my indicator will still give more disciplined results than a simple Williams-based indicator even with a low Force Confirmations setting.
I would think that with a VERY low setting such as 2 or 3, the highs and lows that it picks out would start to become indistinguishable from a Williams-based indicator. You can verify that if you like by choosing one and running them side by side. If so, I'm not sure what the benefit of using mine would be. Perhaps only colours or extra alerts or something.

There is some interpretation possible with market structure, so in the end you have to find what works for you. I can imagine that it could also change depending on the behaviour of the assets that you like to trade.
There is always a tradeoff. A lower number will give more "false alarms" and shorter trends, but be more responsive, in much the same way as would using a lower period for EMAs. You can't say that a faster EMA is better, just different.
For me personally, I like the default (which leaves it alone unless there's some long timeout), because what is special here is the strict rules-based approach to defining Highs and Lows and their interpretation in terms of the state of the market. It's not so easy to see by eye which ones qualify, especially if you're not used to it. The recent peaks and troughs that would be counted by using low values we can see pretty easily by eye without using the indicator.
I hope these thoughts can be helpful in some way. Thanks again for your feedback.
Antworten
TheEconomyCreator SimpleCryptoLife
@SimpleCryptoLife, Great feedback, very detailed. This is exactly what I was thinking already, so your answer to my question is much appreciated. Again thanks for taking the time thoroughly plan out and code this indicator!

Great asset to the TradingView community.
Antworten
awesome ,been using it for a while and it really good thanks
Antworten
SimpleCryptoLife zmarquise666
@zmarquise666, Thanks very much. It's encouraging to hear that my scripts are helping traders.
Antworten
Thanks!
Antworten
Startseite Aktien-Screener Forex-Screener Krypto-Screener Wirtschaftskalender Über Chartmerkmale Preise Einen Freund empfehlen Hausregeln Hilfe Center Webseite & Brokerlösungen Widgets Charting Lösungen Lightweight Charting Library Blog & News Twitter
Profil Profileinstellungen Konto und Abrechnung Angeworbene Freunde Coins Meine Support Tickets Hilfe Center Private Nachrichten Chat Abmelden