Basic Market Structure and Automatic Fibonacci Levels

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.

Just dropping a line to say that I have been very satisfied with the studies I have purchased.

The Basic Market Structure (BMS) is especially useful, because it’s in line with what I have been doing manually.


Basic Market Structure, Automatic Trend Lines and Better Range Finder have been extremely helpful in my trading. I would absolutely recommend Fun with ThinkScript to anyone looking for ThinkorSwim indicators.


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:

example image

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.

Fun with ThinkScript: Basic Market Structure Screenshot
1st order pivots

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

Fun with ThinkScript: Basic Market Structure Screenshot
2nd order pivots

Third-order pivots usually mark major inflections and define the most important market structure on any time frame.

Fun with ThinkScript: Basic Market Structure Screenshot
3rd order pivots

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.

Fun with ThinkScript: Basic Market Structure Screenshot

minor price swings

Connecting the 3rd order pivot points reveals major price swings.

Fun with ThinkScript: Basic Market Structure Screenshot

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.


Fun with ThinkScript: Basic Market Structure Screenshot

Fun with ThinkScript: Basic Market Structure Screenshot

  1. The indicator is now much more responsive and is able to identify swing lines quicker.Fun with ThinkScript: Basic Market Structure Screenshot
  2. 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.
  3. 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.
  4. The user may now elect to show changes in price for either major or minor swings.Fun with ThinkScript: Basic Market Structure Screenshot
  5. The fibonacci levels now feature just-in-time, smart lines. Levels above 100% are automatically hidden until they are needed.Fun with ThinkScript: Basic Market Structure Screenshot
  6. The pivot points may now be determined using either the candle wicks or the bodies.Fun with ThinkScript: Basic Market Structure Screenshot