OPEN-SOURCE SCRIPT

Mark Structure

Updated
Mark Structure is building the market swing structure, minor and sub structure and marks all possible insignificant pivots
Building such structure is really complex task to do, that has a lot of obstacles and challenges. I'm doing my best to develop this indicator behaving in absolutely expectable and right way. Fill free to leave any comments or bug reports.
it supports:
- Marking all pivots with labels or join them continuously with trend lines.
- Marking minor and sub structured swings with labels or join them continuously with trend lines. Marking BOS or SMS BOS, which are mbos. Minor and substructure are structures inside swing structure and it can differ from the structure of lower timeframe
- Marking swings of swing structure with labels or join them continuously with trend lines. Marking BOS or SMS BOS of swing structure
- Changing bullish and bearish colors of each kind of structures
- Changing pivot labelings
- Changing colors of BOSs
Remarks:
- As I told you guys before, it has a lot of challenging cases. eg we have swing low and high on the same candle and in order to decide which pivot goes first I take lower time frame data to figure out what pivot is the first, but it happens that on lower time frame the same issue takes place, due to limitation of TradingView I can't go infinitely to lower timeframes to solve this issue, so I mark those cases with labels
- Another issue is very beginning of the trend its hard to detect swing structure there due to missing historical data. so skip a few waves in the very beginning
- Don't expect to have minor and sub structure in each swing waves, its totally fine when you don't have them at all
- Swing structure is the most significant structure and shows real price direction. Trend change is confirmed when for bull->bear the last HL<LL and LL-LH-LL are confirmed, for bear->bull LH>HH and HH-HL-HH are confirmed. You can change labelling for unconfirmed swing trend in the settings. By default its already done
Release Notes
- minor bug fixes
- added BOS line style
- in order to detect aggressive trend change the sms bos logic is added to the kernel
- added combining waves with swings number less than 4. 3 swings trend doesn't have enough swings to confirm real trend change. Thus I've added option to turn on the combination, by default its on
Release Notes
fixed issue - Add to Chart operation failed, reason: Script has too many local scopes: 618. The limit is 500
Release Notes
sometimes it happens that obvious 5 bars swing gets eliminated due to strict 5 bars condition, thus Ive added 4 bars hybrid option. its something in the middle between noisy 3 and strictly 5 bars patterns
3 bars pattern condition:
at least 1 candle from each side must be lower or higher for lows and highs correspondingly
4 bars pattern condition:
at least 1-2 candle(total conditioned candles must be 3 or more) from each side must be lower or higher for lows and highs correspondingly
5 bars pattern condition:
at least 2 candles from each side must be lower or higher for lows and highs correspondingly
Release Notes
minor fixes
Release Notes
This release expresses new feature and its all about BOS
Since v3.0 you can control how the swing structure is being built. The main sign of changing trend is the break of its structure(BOS) which has 2 behaviour classic and sms. Both versions are confirmed when pivots meet last LH or HL for classic BOS or first LL or HH for sms BOS meet candle on its horizontal level. That first candle can intercept that line either by body or by wick and now you can choose which interception behaviour you would like to use. More than that the price can build a lot of swings before intercepting classic BOS line and already have confirmed SMS BOS for this case you can set priority of finding BOS. SMS,BOS will confirm structure if SMS BOS happens prior to classic BOS. If you choose BOS,SMS then if both BOS types got detected then classic BOS will be used

So you have a lot of power to affect building structure in a way you would like to see it. Enjoy
Release Notes
bug fixes - bug with detecting swing low and high on the same candle, it didnt do it in a right way
Release Notes
This release (v4.0) adds new functionality detecting structure swing by body only. You can find it in Swing Structure section and it's called Mode with value named By Body.
This is very important for those who is paying attention to wicks as liquidity collection, thus updating swing by wicks is not necessarily changing the structure direction, its just engulfing liquidity unless it's confirmed by body.
This functionality blocks some of the settings such as BOS Mode, BOS Priority and Unconfirmed Swings. Those settings are categorised so that you not messed up
Release Notes
I have to rename all my scripts because first 2 laters started associating with geopolitical affairs. Im really sorry for inconvenience
Release Notes
- fixing bug when swing has a few absolutely the same wicks in the middle
Release Notes
minor fixes
Release Notes
fixed detecting sms bos with Swing By Body confirmation
BOSbreakofstructureCandlestick AnalysishighLOWpivotPivot PointsPivot points and levelsstructureswing

Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in publication is governed by House rules. You can favorite it to use it on a chart.

Want to use this script on a chart?


Trade Smart Money? Check out our website link where we do all the heavy lifting for you, automate your analysis and keep you updated on every trading setup you’ve created.
Also on:

Disclaimer