Pivot Significance Index for ThinkorSwim

markos

Well-known member
VIP
Hint: Measures time and price between pivots and uses that data to indicate how meaningful a pivot may be

Trading Notes - the higher the indicator values, the farther the distance between pivots

Both indicator lines at 1 indicate an area is farther than "normal" in both time and price from the most recent pivot. Look for white line as a place for trend to rest

Cyan line at 1 and Orange line at 0 indicate an area where price moved quickly. This "divergence" is the kind dip buyers would want to see

Code:
# Pivot Significance Index in 6-3-19 TSL
# v0.01
# 5.19.19
# Nube

     # Subscript used later 

script normalize{ 

    input h = high; 

    input l = low; 

    input c = close; 

    input x = 21; 

    def normalize = if Highest(h, x) - Lowest(l, x) != 0 

                    then (c - Lowest(l, x)) / (Highest(h, x) - Lowest(l, x)) 

                    else 0; 

    plot normalized = normalize; 

} 

    # Inputs 

input pivotLength = 4; #hint pivotLength: Length for stochastic pivot 

input normalizationLength = 21; #hint normalizationLength: Length for normalization of time and price between pivots 

input alert = no; 

    # Variables 

def h = high;  

def l = low; 

def c = close;  

def nan = Double.NaN;  

def x = BarNumber(); 

def norm = normalize(h, l, c, pivotLength);  

        ## Pivot High 

def hh = if norm  crosses above .5 

         then h 

         else if h > hh[1] 

              then h 

              else hh[1]; 

def hpBar = if h == hh 

            then x  

            else nan; 

def hpBar_1 = if !IsNaN(hpBar)      

              then x  

              else hpBar_1[1]; 

def hpPrice = if !IsNaN(hpBar)  

              then h  

              else hpPrice[1];  

        ## Pivot Low 

def ll = if norm crosses below .5 

         then l 

         else if l < ll[1] 

              then l 

              else ll[1]; 

def lpBar = if l == ll  

            then x  

            else nan; 

def lpBar_1 =  if !IsNaN(lpBar)  

               then x  

               else lpBar_1[1];  

def lpPrice = if !IsNaN(lpBar)  

              then l  

              else lpPrice[1]; 

            ### Normalizing distance between pivots 

def bars  = hpBar_1 - lpBar_1; 

def price = hpPrice - lpPrice; 

def nBarsBetween  = normalize(bars, bars, bars, normalizationLength); 

def nPriceBetween = normalize(price, price, price, normalizationLength); 

    # Plots 

plot 

SignificantPivot = if !IsNaN(c) and nBarsBetween + nPriceBetween == 2 then 1 else nan; 

SignificantPivot.SetLineWeight(3); 

SignificantPivot.SetDefaultColor(Color.White); 


plot  

BarsBetweenPivots = if IsNaN(c) then nan else nbarsBetween; 

BarsBetweenPivots.SetDefaultColor(Color.Dark_Orange); 


plot  

PriceBetweenPivots = if IsNaN(c) then nan else nPriceBetween; 

PriceBetweenPivots.SetDefaultColor(Color.Cyan); 
 

AddLabel(alert and SignificantPivot, "Significant Pivot", Color.White); 

Alert(alert and SignificantPivot, " Significant Pivot", Alert.Bar, Sound.Ring); 

declare lower;   

# f/ Pivot Significance Index
 
Last edited:

Jabbo

New member
2019 Donor
I am having a "invalid statement at my 34:1 -" } " not sure what is going on. Is this statement correct?

Thank you!
 

markos

Well-known member
VIP
I placed the code into my editor and didn't see the problem. I then cleaned up some blank lines. @Jabbo please let me know if you still have problems. Markos
 

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Top