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 .
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.
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.
For fun: find an asset that trends nicely and hide everything except reversal breaks.
+ 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.
Updated the colours so that you won't get compilation warnings from TradingView because of the impending deprecation of "transp".
Hopefully this addition doesn't cause any other problems.
⭐️ Pro scripts: https://simplecrypto.life/pro-scripts/
📗 Articles: https://simplecrypto.life/articles/
🙋Get help with Pinescript: https://simplecrypto.life/get-help-with-pinescript/
이 스크립트의 오써는 참된 트레이딩뷰의 스피릿으로 이 스크립트를 오픈소스로 퍼블리쉬하여 트레이더들로 하여금 이해 및 검증할 수 있도록 하였습니다. 오써를 응원합니다! 스크립트를 무료로 쓸 수 있지만, 다른 퍼블리케이션에서 이 코드를 재사용하는 것은 하우스룰을 따릅니다. 님은 즐겨찾기로 이 스크립트를 차트에서 쓸 수 있습니다.
이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.