Auto Pivot Points Support & Resistance Indicator for ThinkorSwim

M

mashume

Active member
can i make it show weekly pivots even though im on the 6mo 1day chart? Also can you scan it?
I believe it could be done using aggregation periods, though it would require some re-working.

The code comments in the version posted in line by @horserider at #6 in this thread have hints for using the script in a scan. :) but you can always brew your own, so lang as the scan returns exactly one value (boolean) to scan against. -- that can be in the form of x == y, x > y, x > y and x < z, etc... but returns only one thing. comment out other plots.

This is my first post here, so perhaps my tone isn't the most considered for the group. I don't mean to offend.

Happy Scripting
 
N

Nikola

New member
what is the difference between Bens script and Horseriders script?
 
BenTen

BenTen

Administrative
Staff
VIP
@Nikola I didn't make this indicator. Another developer, named Mobius produced it. I believe both utilize pivot points. The one that horserider shared also include ATR (average true range). You should try them out and see which one works better for you.
 
T

tomsk

Well-known member
VIP
@Nikola Here's what I know about these two pivot studies. The study that @BenTen posted is called Projection Pivots while the study that @horserider posted is called Pivot Array with Signals. Both studies were written by Mobius.

In the Projection Pivots study, notice there is an input variable called "n" with a value of 21. That looks at the last 21 pivots and plots projection lines. Load that on a daily aggregation chart of /ES. Now when you change the value of that from 21 to 5, you'll see very different results on the chart.

The other study called Pivot Array with Signals was written by Mobius for TheoTrade. It plots the most recent 4 support and resistance pivots labelled with signals. None of these indicators use any form of ATR, it is based purely on price and prior pivots.

Mobius had also recently written another study called Trend Pivots that is great for intraday trades especially on /ES. It is an amazing study, it tends to react really well to turning points. One of the big pluses for me is that I can watch the pivots form and see how price reacts to pivot points especially on a 2 min timeframe. Good for a quick $200-300 win most days especially during volatile sessions, good enough for lunch/dinner!

Hope this helps
 
Last edited:
S

skynetgen

Well-known member
Warehouse
Mobius had also recently written another study called Trend Pivots that is great for intraday trades especially on /ES. It is an amazing study, it tends to react really well to turning points. One of the big pluses for me is that I can watch the pivots form and see how price reacts to pivot points especially on a 2 min timeframe. Good for a quick $200-300 win most days especially during volatile sessions, good enough for lunch/dinner!

Hope this helps
What timeframes and parameters you use for this study?
 
T

tomsk

Well-known member
VIP
@skynetgen I used standard parameters, on a 2 day 2 min timeframe, instrument: /ES. One enhancement is that I also added a very simple color coded TICK and AD label on my chart to get a sense of the underlying market sentiment

Here's what I use:

# START CODE
input TickSymb = "$TIKSP";
input ADSymb = "$ADSPD";
def TICKS = if !IsNaN(close(TickSymb)) then close(TickSymb) else TICKS[1];
def AD = if !IsNaN(close(ADSymb)) then close(ADSymb) else AD[1];
AddLabel(1, " Tick = " + TICKS, if TICKS < 0 then Color.Pink else Color.Cyan);
AddLabel(1, " AD = " + AD, if AD < -350 then Color.Pink else if AD > 350 then Color.Cyan else if between(AD, -250, 250) then Color.White else Color.Yellow);
# END CODE
 
Last edited:
zeek

zeek

Active member
2019 Donor
@Nikola
Mobius had also recently written another study called Trend Pivots that is great for intraday trades especially on /ES. It is an amazing study, it tends to react really well to turning points. One of the big pluses for me is that I can watch the pivots form and see how price reacts to pivot points especially on a 2 min timeframe. Good for a quick $200-300 win most days especially during volatile sessions, good enough for lunch/dinner!

Hope this helps
Do you know if the Trend Pivots study is currently avaliable for TOS?
 
vvcv

vvcv

Member
I'd like to add a humble opinion, in response to the OP's comment about having trouble drawing support and resistance line.

If you are, in fact, having trouble finding/drawing s/r levels, then I would suggest staying out of the market when your hard earned cash is at risk. They are especially fundamental to learning price movement. Be cautious of a s/r line without much volume, and be cautious of big money, in black pools, at these levels. Yeah, man, just so much to know at these areas of market price movement. Traders who trade DOMs may be something worthwhile to look for, for a bit of education on this subject, they know about these areas inside out.
 
BenTen

BenTen

Administrative
Staff
VIP
@vvcv You're absotely correct. That's a fair comment. And thanks for looking out for others. My intention wasn't to let people know that this will draw all the S/R lines for them. It helps to assist when they're drawing their own support and resistance. The suggested support and resistance lines from this indicator provides a great way for people to learn where to start. It's not a mean for any traders to rely solely on the indicator to do the work for them.
 
vvcv

vvcv

Member
@BenTen

oh yeah, i understand. I'd agree that it being a great tool for those that do know. I just wanted to give a quick heads up to new folks to the market. Just so they can buy a hot-dog when they want one. Then again, that's a whole other area to be cautious of. :oops::sick::)
 
C

chewie76

New member
Is there a way to get these auto pivot points indicator to work with a lower study, like the RSI?
 
A

Antares66

New member
I used some pivot points but noticed that monthly pivots don´t show up on minute charts.
Does someone now why?
 
A

Antares66

New member
Problem solved. I increased the time interval to 30 days.:)
 
Z

zappi

New member
Is there a way to Convert this code High low indicator to TOS
Code:
study(title="Pivot Hilo Support n Resistance Levels R5.3 by JustUncleL", shorttitle="PVTLVLS R5.3", overlay=true, max_bars_back=50)

// By: JustUncleL
// Date: 20-Mar-2017
// Version: R4
//
// Description:
//   This Pivot Points marked with small coloured triandles and with Optional Support and Resistance extension Levels.
// 
//   Options:
//   - Show Pivot Points (default true)
//   - Pivot Length Left Side (default 3), the number of bars left hand side of the Pivot candle.
//   - Pivot Length Right Side (default 3), the number of bars right hand side of the Pivot candle.
//   - Show S/R Extension Levels (default true)
//   - Maximum S/R Extension Length (default 0, no limit)
//   - Show Pivot Labels HH, LL, HL, LH
//
//   Note: Setting Left side=2 and Right side=2 will generate Fractal points.
//
// Modifications:
//  R5.3 12-Apr-2018
//     - Added option to show the Pivot candle as a Coloured Bar.
//
//  R5.2 22-Feb-2018:
//     - Added option to display Levels as a Fractal Chaos Channel, thanks goto HPotter's "Fractal Chaos Bands" series
//       idea for inspiration.
//     - Replaced script functions with TV pivothigh() and pivotlow() calls to speed up
//       the processing of the script.
//
//  R5 12-Jan-2018:
//     - Remove redundant Pivot labelling. Now have HH,LL,HL,LH labels instead.
//     - Added option start printing Pivot marker early, however, this may result in the
//       current Pivot marker re-building until last candle in pattern closed.
//     - Replaced "star" pivot markers with small coloured Dots that sit right on the
//       high or low of the Pivot Candle.
//
//  17-Oct-2017:
//     - Replaced TV pivothigh and pivotlow function calls with built-in finctions to allow
//       for equal high or low on the left hand side of Pivot.
//     - Added implied GPL copyright notice.
//     - Added Buy/Sell alarm alerts on Fractal breaks and removed redundant code.
//
//  R4 11-Oct-2017:
//     - Added option to display HH/LL symbols.
//
//  02-Sep-2017:
//     - Corrected MA Filtering on Alert arrows, so now MA's are now kept in correct order.
//     - Added Ideal Pivot option.
//    
//  22-Aug-2017:
//     - Added optional swing alert arrows and alarmcondition.
//     - Shortened optional Pivot labels to "PH" and "PL"
//     - Added optional MA Ribbon filtering of Pivot points.
//
//  13-Aug-2017:
//     - Correct Bug introduced by last update, would not work find correct pivot
//       point with some assets.
//
//  4-Aug-2017 :
//     - optimised some code.
//     - shortened Pivot labels to "PH" and "PL"
//     - added code to select correct Pivots when Heikin Ashi candles are used.
//     - added "Renko Style Pivots", so can now be used with Renko charts.
//       that have wicks selected.
//
//  R3 - added code to force Pivot to be always complete before drawing.
//  R2 - added option for different length test for each side of Pivot.
//  R1 - original.
//
// -----------------------------------------------------------------------------
// Copyright 2017,2018 JustUncleL
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// The GNU General Public License can be found here
// <http://www.gnu.org/licenses/>.
//
// -----------------------------------------------------------------------------
//

// - INPUTS
ShowPivots       = input(true,title="Show Pivot Points")
uAuto            = input(false,title="Use Auto Strength Pivots Points")
left             = input(5,minval=1,title="Pivot Length Left Hand Side")
right            = input(5,minval=1,title="Pivot Length Right Hand Side")
ShowSRLevels     = input(true,title="Show S/R Level Extensions")
ShowChannel      = input(false,title="Show Levels as a Fractal Chaos Channel")
Shunt            = input(1,minval=0,maxval=1,type=integer,title="When to start Printing Pivot (0 = no wait, 1 = wait for candle close)")
maxLvlLen        = input(0,minval=0, title="Maximum S/R Level Extension Length")
uRenko           = input(false, title="Use Renko Style Pivots (open/close for high/low)")
sIdeal           = input(false, title="Show Only Ideal Pivots (handy for Renko and HA)")
ShowHHLL         = input(false,title="Show HH,LL,LH,HL markers on Pivots Points")
clrPivot         = input(false, title="Highlight Pivot with Coloured Bar")
//
ShowFB           = input(false, title="Show Fractal Break Alert Arrows")
filterFB         = input(false, title="Apply MA Filter to Fractal Break Alerts")
// Filtering
uMAf             = input(false,title="Use MA Filter on Pivots")
// Fast MA - type, source, length
fast_ma_type     = input(defval="EMA", title="Fast MA Type ", options=["SMA", "EMA", "WMA", "VWMA", "Smooth SMA", "DEMA", "TEMA", "Hull MA", "ZeroLag EMA", "Triangular MA", "SuperSmooth MA"])
fast_ma_len      = input(defval=21, title="Fast MA - Length", minval=1)
fast_ma_src      = input(close, title="Fast MA - Source")
// Slow MA - type, source, length
slow_ma_type     = input(defval="EMA", title="Slow MA Type ", options=["SMA", "EMA", "WMA", "VWMA", "Smooth SMA", "DEMA", "TEMA", "Hull MA", "ZeroLag EMA", "Triangular MA", "SuperSmooth MA"])
slow_ma_len      = input(defval=55, title="Slow MA - Length", minval=1)
slow_ma_src      = input(close, title="Slow MA - Source")
sMAs             = input(false, title="Show MA Lines")

// - /INPUTS

//
high_  = uRenko? max(close,open) : high
low_   = uRenko? min(close,open) : low


// === FINCTIONS

// - variant(type, src, len)
// Returns MA input selection variant, default to SMA if blank or typo.

// SuperSmoother filter
// © 2013  John F. Ehlers
variant_supersmoother(src,len) =>
    a1 = exp(-1.414*3.14159 / len)
    b1 = 2*a1*cos(1.414*3.14159 / len)
    c2 = b1
    c3 = (-a1)*a1
    c1 = 1 - c2 - c3
    v9 = 0.0
    v9 := c1*(src + nz(src[1])) / 2 + c2*nz(v9[1]) + c3*nz(v9[2])
    v9
   
variant_smoothed(src,len) =>
    v5 = 0.0
    v5 := na(v5[1]) ? sma(src, len) : (v5[1] * (len - 1) + src) / len
    v5

variant_zerolagema(src,len) =>
    ema1 = ema(src, len)
    ema2 = ema(ema1, len)
    v10 = ema1+(ema1-ema2)
    v10
   
variant_doubleema(src,len) =>
    v2 = ema(src, len)
    v6 = 2 * v2 - ema(v2, len)
    v6

variant_tripleema(src,len) =>
    v2 = ema(src, len)
    v7 = 3 * (v2 - ema(v2, len)) + ema(ema(v2, len), len)               // Triple Exponential
    v7
   
// return variant, defaults to SMA
variant(type, src, len) =>
    type=="EMA"     ? ema(src,len) :
      type=="WMA"   ? wma(src,len):
      type=="VWMA"  ? vwma(src,len) :
      type=="Smooth SMA"  ? variant_smoothed(src,len) :
      type=="DEMA"  ? variant_doubleema(src,len):
      type=="TEMA"  ? variant_tripleema(src,len):
      type=="Hull MA"? wma(2 * wma(src, len / 2) - wma(src, len), round(sqrt(len))) :
      type=="SuperSmooth MA"  ? variant_supersmoother(src,len) :
      type=="ZeroLag EMA"  ? variant_zerolagema(src,len) :
      type=="Triangular MA"   ? sma(sma(src,len),len) : sma(src,len)

// - /variant


// Functions to find ideal Pivot Highs and Lows.
ipivothigh(src, L, R) =>
    t = true
    for i = R to L+R-1
        t := t and src>src[i+1]
    for i = 0 to R-1
        t := t and src<src[i+1]
    t ? src[R] : na

ipivotlow(src, L, R) =>
    t = true
    for i = R to L+R-1
        t := t and src<src[i+1]
    for i = 0 to R-1
        t := t and src>src[i+1]
    t ? src[R] : na
    
// Functions to find normal Pivot High and Lows, allowing for equal highs
// on left side of pivot.
// NOTE: To increase processing speed, these functions are replaced by
//       pivothigh()/pivotlow() calls.
//
//npivothigh(src, L, R) =>
//    t = true
//    for i = R to L+R-1
//        t := t and src[R]>=src[i+1]
//    for i = 0 to R-1
//        t := t and src[R]>src
//    t ? src[R] : na
//
//npivotlow(src, L, R) =>
//    t = true
//    for i = R to L+R-1
//        t := t and src[R]<=src[i+1]
//    for i = 0 to R-1
//        t := t and src[R]<src
//    t ? src[R] : na
    
    
// - /FUNCTIONS

// - SERIES VARIABLES

// MA's
fast_ma_series  = variant(fast_ma_type, fast_ma_src, fast_ma_len)
slow_ma_series  = variant(slow_ma_type, slow_ma_src, slow_ma_len)

plot(sMAs? fast_ma_series: na, color=lime,title="Fast MA", join=true,style=circles,linewidth=2,transp=15)
plot(sMAs and fast_ma_len<=slow_ma_len? slow_ma_series: na, color=gray,title="Slow MA", join=true,style=circles,linewidth=2,transp=15)

// Determine pivots
pvtLenL  = uAuto? (close > ema(close, 20)) ? left : left + 1 : left
pvtLenR  = uAuto? (close < ema(close, 20)) ? right : right + 1: right

// Get High and Low Pivot Points
pvthi_ = (uMAf and (fast_ma_len>slow_ma_len or fast_ma_series<slow_ma_series))? na :  sIdeal?ipivothigh(high_,pvtLenL,pvtLenR) : pivothigh(high_,pvtLenL,pvtLenR)
pvtlo_ = (uMAf and (fast_ma_len>slow_ma_len or fast_ma_series>slow_ma_series))? na :  sIdeal?ipivotlow(low_,pvtLenL,pvtLenR) :  pivotlow(low_,pvtLenL,pvtLenR)

// Force Pivot completion before plotting.
pvthi = pvthi_[Shunt]
pvtlo = pvtlo_[Shunt]

//  ||-----------------------------------------------------------------------------------------------------||
//  ||---   Higher Highs, Lower Highs, Higher Lows, Lower Lows  -------------------------------------------||
higherhigh = na(pvthi) ? na : ( valuewhen(pvthi, high_[pvtLenR+Shunt], 1) < valuewhen(pvthi, high_[pvtLenR+Shunt], 0) )? pvthi : na
lowerhigh = na(pvthi) ? na : ( valuewhen(pvthi, high_[pvtLenR+Shunt], 1) > valuewhen(pvthi, high_[pvtLenR+Shunt], 0)  )? pvthi : na
higherlow = na(pvtlo) ? na : ( valuewhen(pvtlo, low_[pvtLenR+Shunt], 1) < valuewhen(pvtlo, low_[pvtLenR+Shunt], 0) )? pvtlo : na
lowerlow =  na(pvtlo) ? na : ( valuewhen(pvtlo, low_[pvtLenR+Shunt], 1) > valuewhen(pvtlo, low_[pvtLenR+Shunt], 0) )? pvtlo : na


// If selected Display the HH/LL above/below candle.
plotshape(ShowHHLL ? higherhigh : na, title='HH', style=shape.triangleup, location=location.abovebar, color=green, text="HH", offset=-pvtLenR-Shunt,transp=0)
plotshape(ShowHHLL ? higherlow : na, title='HL', style=shape.triangleup, location=location.belowbar, color=green, text="HL", offset=-pvtLenR-Shunt,transp=0)
plotshape(ShowHHLL ? lowerhigh : na, title='LH', style=shape.triangledown, location=location.abovebar, color=maroon, text="LH", offset=-pvtLenR-Shunt,transp=0)
plotshape(ShowHHLL ? lowerlow : na, title='LL', style=shape.triangledown, location=location.belowbar, color=maroon, text="LL", offset=-pvtLenR-Shunt,transp=0)


// If Selected Display Pivot points
//plotshape(ShowPivots and not ShowHHLL ? pvthi :na, title='High Pivot Marker', style=shape.triangleup,location=location.abovebar, color=green, offset=-pvtLenR-Shunt,transp=0,size=size.auto)
//plotshape(ShowPivots and not ShowHHLL ? pvtlo :na,  title='Low Pivot Marker', style=shape.triangledown, location=location.belowbar, color=maroon, offset=-pvtLenR-Shunt,transp=0,size=size.auto)
plot(ShowPivots and not ShowHHLL? pvthi :na, title='High Pivot *', style=circles,join=false,color=white, offset=-pvtLenR-Shunt,transp=50,linewidth=3)
plot(ShowPivots and not ShowHHLL? pvtlo :na, title='Low Pivot *', style=circles,join=false,color=white, offset=-pvtLenR-Shunt,transp=50,linewidth=3)
plot(ShowPivots and not ShowHHLL? pvthi :na, title='High Pivot *', style=circles,join=false,color=green, offset=-pvtLenR-Shunt,transp=0,linewidth=2)
plot(ShowPivots and not ShowHHLL? pvtlo :na, title='Low Pivot *', style=circles,join=false,color=maroon, offset=-pvtLenR-Shunt,transp=0,linewidth=2)

// Highlight Pivot Bar.
ORANGE = #FFA500FF
barcolor(clrPivot and (pvthi or pvtlo)?ORANGE:na,title="Colour Pivot Bar",offset=-pvtLenR-Shunt)



//Count How many candles for current Pivot Level, If new reset.
counthi = 0
countlo = 0
counthi := na(pvthi) ? nz(counthi[1])+1 : 0
countlo := na(pvtlo) ? nz(countlo[1])+1 : 0

pvthis = 0.0
pvtlos = 0.0
pvthis := na(pvthi) ? pvthis[1] : high[pvtLenR+Shunt]
pvtlos := na(pvtlo) ? pvtlos[1] : low[pvtLenR+Shunt]

hipc = (pvthis != pvthis[1]) ? na : maroon
lopc = (pvtlos != pvtlos[1]) ? na : green

// Show Levels if Selected
plot(ShowSRLevels and not ShowChannel and (maxLvlLen==0 or counthi<maxLvlLen)? pvthis : na, color=hipc, transp=0, linewidth=1, offset=-pvtLenR-Shunt, title="Top Levels")
plot(ShowSRLevels and not ShowChannel and (maxLvlLen==0 or countlo<maxLvlLen)? pvtlos : na, color=lopc, transp=0, linewidth=1, offset=-pvtLenR-Shunt, title="Bottom Levels")
plot(ShowSRLevels and not ShowChannel and (maxLvlLen==0 or counthi<maxLvlLen) ? pvthis : na, color=hipc, transp=0, linewidth=1, offset=0, title="Top Levels 2")
plot(ShowSRLevels and not ShowChannel and (maxLvlLen==0 or countlo<maxLvlLen) ? pvtlos : na, color=lopc, transp=0, linewidth=1, offset=0, title="Bottom Levels 2")

// Show Levels as a Fractal Chaos Channel
plot(ShowSRLevels and ShowChannel ? pvthis : na, color=green, transp=0, linewidth=1, style=stepline, offset=0, title="Top Chaos Channel",trackprice=false)
plot(ShowSRLevels and ShowChannel ? pvtlos : na, color=maroon, transp=0, linewidth=1, style=stepline, offset=0, title="Bottom Chaos Channel",trackprice=false)

// Add Optional Fractal Break Alerts
buy = false
sell = false
buy  := close>pvthis and open<=pvthis and (not filterFB or ((fast_ma_len>slow_ma_len or fast_ma_series>slow_ma_series) and close>fast_ma_series))
sell := close<pvtlos and open>=pvtlos and (not filterFB or ((fast_ma_len>slow_ma_len or fast_ma_series<slow_ma_series) and close<fast_ma_series))

//
plotarrow(ShowFB and buy?1:na, title="BUY Arrow", colorup=lime, maxheight=60, minheight=50, transp=20)
plotarrow(ShowFB and sell?-1:na, title="SELL Arrow", colordown=red, maxheight=60, minheight=50, transp=20)
//
alertcondition(buy or sell,title="Fractal Break Arrow",message="Alert")
alertcondition(buy,title="Fractal Break Long",message="Long")
alertcondition(sell,title="Fractal Break Short",message="Short")


//
//EOF
 
S

stocksniper

Member
Hey guys is there a support and resistance multi time frame script so I can apply the daily support and resistance lines on the 1 or 5 Time frame. Your help is greatly appreciated. Thanks
 

Top