Description

Basic Market Structure and Automatic Fibonacci Levels Indicator ThinkorSwim TOS Script

**More information:

Get Basic Market Structure and Automatic Fibonacci Levels Indicator ThinkorSwim TOS Script at bestoftrader.com

Description:

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.

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

2nd order pivots

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

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.

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.

FIXES

UPGRADES AND NEW FEATURES

  1. The indicator is now much more responsive and is able to identify swing lines quicker.
  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.
  5. The fibonacci levels now feature just-in-time, smart lines. Levels above 100% are automatically hidden until they are needed.
  6. The pivot points may now be determined using either the candle wicks or the bodies.