OPEN-SOURCE SCRIPT
已更新

TJR Swing High/Low + BOS

902
TJR Swing High/Low + BOS
Version 1.0.0

Marks swing highs, swing lows and Breaks of Structure using TJR's 2-candle method, so you can see how market structure is forming and where the trend shifts.

WHAT IT DRAWS
• Swing highs and lows: read from the stream of real candles. A colour flip from bull to bear marks a swing high at the higher of the two paired candle highs; a colour flip from bear to bull marks a swing low at the lower of the two paired candle lows. Each line sits on whichever paired candle holds the extreme, one candle wide.
• Historical swings: the current swing plus up to two previous swings per type are kept, so up to three swing high lines and three swing low lines can show at once. Older lines hold their price and restyle to a shared historical look. Two depth dropdowns, one for highs and one for lows, choose how many are shown: current only, current plus one, or current plus two.
• Break of Structure: one horizontal line at the broken swing's price, from that swing's origin to one bar past the break. Only the most recent break is shown. It is drawn solid on the break, then once the break candle plus one further candle have closed it restyles to the chosen historical style, which defaults to dotted.

HOW IT WORKS
• Doji handling: a doji, defined as a candle whose close equals its open, is ignored entirely and the real candles on either side of it are compared directly.
• Break of Structure logic: a trend state machine is driven by the current swing high and low. From a cold start a close beyond either current swing sets the trend. Once a trend is set, only the opposite swing is watched, so in a bullish trend a close below the current swing low is a bearish break, and in a bearish trend a close above the current swing high is a bullish break.
• Repaint-safe: the indicator acts only on confirmed, closed bars, so lines do not flicker or repaint on the live forming bar. It uses no external data requests, no alerts and no tables.

WHAT IT RUNS ON
Standard Japanese candlestick charts only. Heikin Ashi, Renko, Kagi, Point and Figure and Range charts are refused, because on those chart types the candle open, high, low and close are synthetic and the structure they imply would be misleading. On any of those the indicator stops with a message and draws nothing.

INPUTS
• Swing High: history depth, colour, opacity, line style and thickness.
• Swing Low: history depth, colour, opacity, line style and thickness.
• Historical Swings: colour, opacity, line style and thickness, shared by all aged tiers.
• Break of Structure: thickness and the historical style applied once the break has aged.

HOW TO USE
Add it to any standard candlestick chart. Use the swing highs and lows to see where structure is forming, and the Break of Structure line to see when a swing has been broken and the trend has shifted.

FEEDBACK
Please let me know if you experience any issues, or have feedback for improvements or additions in the comments below. Thank you, Tom
版本注释
Version 1.1.0

Added a Break of Structure input, Extend past BOS candle (bars), that sets how far the BOS line runs to the right of the break candle: one, two or three bars, with two as the default. Earlier versions always drew the line one bar past the break, so on the default the line now reaches one bar further.
版本注释
Version 1.2.0

The settings panel is reworked into the house two-tier layout, and the Break of Structure section now keeps two lines instead of one.

ADDED
• BOS -1 Ago line: the Break of Structure before the latest is now kept alongside the most recent one, with its own colour, opacity, line style, thickness and its own Extend past BOS candle value that sets how many candles the line runs to the right past the break candle. When a new break forms, the current line demotes to this tier and adopts its styling.
• Show Swings master toggle: shows or hides the swing high and swing low tabs. Hiding is display only, swing detection keeps running so the Break of Structure engine still reads the levels.
• Show BOS master toggle: shows or hides the Break of Structure lines. Hiding is display only, trend detection keeps running so the levels stay tracked.

CHANGED
• Settings panel restructured into the two-tier layout: a Most Recent Swing High & Low parent (Show Swings toggle) over Swing High and Swing Low sub-sections, and a Break of Structure parent (Show BOS toggle) over Most Recent BOS and BOS -1 Ago sub-sections.
• The Most Recent BOS line is now fully self-styled, with its own colour, opacity, line style and thickness, and stays solid for its whole life. It no longer takes its colour from the broken swing and no longer ages to a historical style.
• Hopefully makes it easier to see where there has been an older BOS in one direction then a turn in the market and the most recent BOS in the other direction.

REMOVED
• Swing history: the previous-swing tiers (Swing -1 and Swing -2), the two history depth dropdowns, and the shared Historical Swings style group. Only the most recent swing high and swing low are drawn.
• The Break of Structure aging-to-historical-style behaviour and its BOS Level Historical Style input.

免责声明

这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。