NeoDaNomad Updated   
This library was designed to create three different datasets using Bill Williams fractals. The goal is to spot trends in reversal data and ultimately use these datasets to help predict future price reversals.

First, the pivot() function is used to initialize and populate three separate arrays (high pivot, low pivot, all pivots). Since each high/low price depends on the bar_index, the bar_index, pivot direction(high/low), and high/low values are compressed into a string to maintain the data's integrity ("<bar_index>_<direction>_<price>"). Once each string array is populated and organized by bar_index, all three are returned inside a tuple. The return value must be deconstructed H,L,A=pivot() for each array's values to be accessed using getPivot(). This boilerplate allows for data to be accessed more efficiently in a recursive environment. getPivot() was designed to be used inside of a for or while block to populate matrices for further analyses. Again, getPivot() return values must be exposed through deconstruction. x,d,y=getPivot(). See code for more details.

pivot(int XLR) initializes and populates arrays

  • XLR - number of bars to the left and right that must be lower for a high to be considered a pivotHigh, or vice versa. This number will drastically change the size and scope of the returned datasets. smaller values will produce much larger datasets, which might model short term price activity well. In contrast, larger values will produce smaller datasets which might model longer term price activity well.
Returns - tuple[string]

getPivot(string arrayID, int index) accesses array data

  • arrayID - the variable name for one of the three arrays returned by pivot().
  • index - the index of the provided array, with 0 being the most recent pivot point. can be set to "i" in a loop to access values recursively
Returns - tuple
Release Notes:
Release Notes:




Release Notes:
Pine library

In true TradingView spirit, the author has published this Pine code as an open-source library so that other Pine programmers from our community can reuse it. Cheers to the author! You may use this library privately or in other open-source publications, but reuse of this code in a publication is governed by House Rules.


The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.

Want to use this library?

Copy the following line and paste it in your script.