The Basic Market Structure indicator plots major and minor swing lines based on second and third order pivots. It will also, automatically, plot fibonacci retracement levels.
Your scripts have helped many of us simplify our daily process and provide quicker more accurate signals.
Latest version of Basic Market Structure is excellent–many thanks Robert! Well worth it!
Basic Market Structure
Hello, I wasn’t sure were else to go for help but I’m trying to re-create what is going on in the image below:
Describing what you are looking for is rather easy. However, actually writing the ThinkScript for this indicator proved quite difficult.
The basic market structure on any time frame are pivot highs and lows (also called swing highs or lows). A pivot high is a bar that has a higher high than the bar that came before it and the bar that comes after it. At least in the very short term, the bar’s high represents the high-water mark past which buyers were not able to push price, and can be considered a very minor source of potential resistance. A pivot low is the same concept inverted: a bar with a lower low relative to both the preceding and the following bars. These types of pivots are also called first-order pivots and are marked in the following screenshot.
Second-order pivot highs (also called intermediate-term pivots) are first-order pivot highs that are preceded and followed by lower first-order pivot highs; again, this structure is inverted for second-order pivot lows. In the screenshot below, notice that these second-order pivots begin to define some more significant structural points. It is much more likely that second-order pivots will come at important turning points
Third-order pivots usually mark major inflections and define the most important market structure on any time frame.
It is possible to begin seeing the context behind price action by connecting the pivot points. Minor swings are defined by connecting the 2nd order pivots.
minor price swings
Connecting the 3rd order pivot points reveals major price swings.
major price swings
Now that the underlying structure of the price movement has been revealed, I thought it would be beneficial to also add automatic fibonacci retracement lines based on the most recent major swing in price.
fibonacci retracements (click above for full-size image)
Each of the different elements may be either enabled or disabled from within the script’s settings panel to allow for customizing the look of the charts.
building up each of the different elements
This indicator will work on any charting time-frame.
Major Update to Basic Market Structure Indicator
I have completely rewritten this indicator. I threw out the old code and started over as if I had never done this before. Doing so has allowed me to fix a few discrepancies that I didn’t like. I also added new features to enhance the indicator.
Upgrades and New features
- The indicator is now much more responsive and is able to identify swing lines quicker.
- The starting point for drawing fibonacci levels has been moved to the left to align with the start of the swing line they are based on rather than at the end of the swing line as in the older version. This now matches the functionality of the fibonacci retracement drawing tool and allows the labels to be moved out of the way of the newest candles.
- Based on user input, the fibonacci levels may be calculated from either the most recent major or minor swing or from the previous major or minor swing.
- The user may now elect to show changes in price for either major or minor swings.
- The fibonacci levels now feature just-in-time, smart lines. Levels above 100% are automatically hidden until they are needed.
- The pivot points may now be determined using either the candle wicks or the bodies.