Auto Pivot Points Support & Resistance Indicator for ThinkorSwim

T

tomsk

Well-known member
VIP
Sounds like all you're looking for is a horizontal line to be plotted across the chart at the High and Low points from Pre Market all the way to the end of RTH? If that is the case you can use of of Mobius Globex studies and adjust the time period and you'll pretty have what you need. However I would not classify that as an automatic support resistance study though.
 
J

joshua74133

Member
so there is no way to take this and make it put all the lines all the way across. ideally from market close the previous day to the end of market the next day... full 24hrs
input magnitude = 5; def top = high >= Highest(high[1], magnitude) and high >= Highest(high[-magnitude], magnitude); def topvalue = if BarNumber() < magnitude then Double.NaN else if top then high else topvalue[1]; plot topline = topvalue; def countp = if IsNaN(top) and !IsNaN(top[1]) then 1 else countp[1] + 1; plot peaktop = if IsNaN(top) then GetValue(topline, countp) else Double.NaN; def bottom = low <= Lowest(low[1], magnitude) and low <= Lowest(low[-magnitude], magnitude); def bottomValue = if BarNumber() < magnitude then Double.NaN else if bottom then low else bottomValue[1]; plot bottomline = bottomValue; def countt = if IsNaN(bottom) and !IsNaN(bottom[1]) then 1 else countt[1] + 1; plot bottomlow = if IsNaN(bottom) then GetValue(bottomline, countt) else Double.NaN; bottomlow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL); bottomlow.SetDefaultColor(Color.GREEN); topline.SetPaintingStrategy(PaintingStrategy.HORIZONTAL); topline.SetDefaultColor(Color.RED); peaktop.SetPaintingStrategy(PaintingStrategy.HORIZONTAL); peaktop.SetDefaultColor(Color.RED); bottomline.SetPaintingStrategy(PaintingStrategy.HORIZONTAL); bottomline.SetDefaultColor(Color.GREEN);
 
J

joshua74133

Member
So there is no way to code this so the lines go all the way across? I want all the support lines to last all day. Seems like there should be a way to extend all these support and resistance lines
 
BenTen

BenTen

Administrative
Staff
VIP
@joshua74133 To my knowledge, there is no way to extend all the s/r lines all the way to the right.
 
T

tomsk

Well-known member
VIP
@joshua74133 To my knowledge, there is no way to extend all the s/r lines all the way to the right.

@BenTen Actually I have a version that plots a high/low across the chart intraday from the moment the market closes for the day until the end of RTH the following day, i.e. for a 24 hour period. The request was unclear though I did post some earlier comments in post #61. The trick is to define the active period and I believe once that 24 hour window is defined the rest is easy
 
T

tomsk

Well-known member
VIP
Sounds like all you're looking for is a horizontal line to be plotted across the chart at the High and Low points from Pre Market all the way to the end of RTH? If that is the case you can use of of Mobius Globex studies and adjust the time period and you'll pretty have what you need. However I would not classify that as an automatic support resistance study though.
As a follow up to my earlier post #61 I have put together this study that plots a horizontal line across the chart at the High and Low points from the Premarket (essentially right after the close of the previous trading session) all the way to the end of RTH. This is essentially close to a 24 hour GlobeX plus RTH period. Using Mobius Globex High/Low study as a base, I adjusted the time period to match the time partition requested and tested this thoroughly during the trading session today. It does capture the time partition requested

Code:
# GlobeX RTH High Low 24 Hours
# tomsk
# 1.29.2020

# Plots a horizontal line across the chart at the High and Low points from the Premarket (essentially right after the close of the previous trading session) all the way to the end of RTH. This is essentially close to a 24 hour GlobeX plus RTH period. Using Mobius Globex High/Low study as a base, I adjusted the time period to match the time partition requested and tested this thoroughly during the trading session today. It does capture the time partition requested

# GlobeX or Overnight High / Low
# Mobius
# V01.2012
# V07.2017 Replaced Time Brackets with GetTime() function which works better with Mobile
# 7.25.2019

input PlotOverNightExtremes = yes;

def h = high;
def l = low;
def bar = BarNumber();

def GlobeXRTH = getTime() >= RegularTradingEnd(getYYYYMMDD()) + AggregationPeriod.FIVE_MIN or
                getTime() < RegularTradingEnd(getYYYYMMDD());

def ONhigh = if GlobeXRTH and !GlobexRTH[1]
             then h
             else if GlobexRTH and
                     h > ONhigh[1]
                  then h
                  else ONhigh[1];
def ONhighBar = if GlobeXRTH and h == ONhigh
                then Bar
                else double.nan;
def ONlow = if GlobeXRTH and !GlobeXRTH[1]
            then l
            else if GlobeXRTH and 
                    l < ONlow[1]
                 then l
                 else ONlow[1];
def ONlowBar = if GlobeXRTH and l == ONlow
               then Bar
               else double.nan;
def OverNightHigh = if BarNumber() == HighestAll(ONhighBar) 
                    then ONhigh
                    else OverNightHigh[1];
def OverNightLow = if BarNumber() == HighestAll(ONlowBar) 
                   then ONlow
                   else OverNightLow[1];
plot ONH = if OverNightHigh > 0
           then OverNightHigh
           else OverNightHigh[1];
ONH.SetHiding(!PlotOverNightExtremes);
ONH.SetPaintingStrategy(PaintingStrategy.SQUARES);
ONH.SetDefaultColor(Color.YELLOW);
ONH.HideBubble();
ONH.HideTitle();
plot ONL = if OverNightLow > 0
           then OverNightLow
           else Double.NaN;
ONL.SetHiding(!PlotOverNightExtremes);
ONL.SetPaintingStrategy(PaintingStrategy.SQUARES);
ONL.SetDefaultColor(Color.CYAN);
ONL.HideBubble();
ONL.HideTitle();
AddChartBubble(bar == ONhighBar and PlotOverNightExtremes, ONH, "ONH", Color.BLUE);
AddChartBubble(bar == ONlowBar and PlotOverNightExtremes, ONL, "ONL", Color.GRAY, 0);
# End Code GlobeXRTH High Low
 
Last edited:
J

joshua74133

Member
theres got to be a way to code it, like just choose how long you can extend those lines? sure would be helpful
 
J

joshua74133

Member
I'm going to try to use the fib line code to place a fib line when a support is formed. No idea what I'm doing... Lol just spit balling ideas
 
horserider

horserider

Well-known member
VIP
@joshua74133 Great you want to try. Just be aware there are studies on here that already do what you seek. Also the study you are wishing to change I believe was made for scalping. Trades would be made on the break of the most recent support or resistance line.
 
J

joshua74133

Member
Everything I have found is high low in pre market. What I want is a auto support that plots all support lines to last all day. Right the only auto support that ive seen stops when a new support has formed.
 
J

joshua74133

Member
Is there anyway to make the shading go away lol cant see crap chart looks like a dang rainbow
 
J

joshua74133

Member
Figured out how to remove the cloud... I think this will work. Thanks!
 
I

Illumination

New member
Hi, I have a question regarding the pivot points that appear on the DOM. I don't need to see it on the DOM but find no way of altering/removing them specifically. All I see for TOS is the "Show Studies from Chart" but no option to edit/altar specific indicators that appear there. The S/R lines are good but the appear of all the studies on the DOM can get confusing. Is there any workaround to this? Thank you.
 
J

joshua74133

Member
It have to go into the think script and everywhere you see bubble or cloud just delete
 
J007RMC

J007RMC

Active member
2019 Donor
VIP
Pivot Study with Audible Alarms for Buy/Sell.... this is a mobious study, and definitely worth a try it also paints buy/sell wedges.

Code:
# Mobius
####EVANB ADDED CODE AT THE BOTTOM
# V01.08.2012

input n = 1;
input showLines = yes;
input showValues = Yes;
input showBarNumbers = no;

# Internal Script Reference
script LinePlot {
    input BarID = 0;
    input Value = 0;
    input BarOrigin = 0;
    def ThisBar = HighestAll(BarOrigin);
    def ValueLine = if BarOrigin == ThisBar
                then Value
                else Double.NaN;
    plot P = if ThisBar - BarID <= BarOrigin
             then HighestAll(ValueLine)
             else Double.NaN;
}
   def h = high;
   def l = low;
   def bar = barNumber();
   def PH;
   def PL;
   def hh = fold i = 1 to n + 1
            with p = 1
            while p
            do h > getValue(h, -i);
       PH = if (bar > n and
                h == highest(h, n) and
                hh)
            then h
            else double.NaN;
   def ll = fold j = 1 to n + 1  
            with q = 1
            while q
            do l < getValue(low, -j);
       PL = if (bar > n and
                l == lowest(l, n) and
                ll)
            then l
            else double.NaN;
   def PHBar = if !isNaN(PH)
               then bar
               else PHBar[1];
   def PLBar = if !isNaN(PL)
               then bar
               else PLBar[1];
   def PHL = if !isNaN(PH)
             then PH
             else PHL[1];
   def priorPHBar = if PHL != PHL[1]
                    then PHBar[1]
                    else priorPHBar[1];
   def PriorPH = if PHL != PHL[1]
                 then PHL[1]
                 else PriorPH[1];
   def PLL = if !isNaN(PL)
             then PL
             else PLL[1];
   def PriorPLBar = if PLL != PLL[1]
                    then PLBar[1]
                    else priorPLBar[1];
   def PriorPL = if PLL != PLL[1]
                 then PLL[1]
                 else PriorPL[1];
   def HighPivots = bar >= highestAll(priorPHBar);
   def LowPivots = bar >= highestAll(priorPLBar);
   def FirstRpoint = if HighPivots
                     then bar - PHBar
                     else 0;
   def PriorRpoint = if HighPivots
                     then bar - PriorPHBar
                     else 0;
   def RSlope = (getvalue(PH, FirstRpoint) - getvalue(PH, PriorRpoint))
                       / (PHBar - PriorPHBar);
   def FirstSpoint = if LowPivots
                     then bar - PLBar
                     else 0;
   def PriorSpoint = if LowPivots
                     then bar - PriorPLBar
                     else 0;
   def SSlope = (getvalue(PL, FirstSpoint) - getvalue(PL, PriorSpoint))
                   / (PLBar - PriorPLBar);
   def RExtend = if bar == highestall(PHBar)
                 then 1
                 else RExtend[1];
   def SExtend = if bar == highestall(PLBar)
                 then 1
                 else SExtend[1];
  plot PriorPHLine = LinePlot(PriorRPoint, PriorPH, PriorPHBar);
       PriorPHLine.SetStyle(Curve.Firm);
       PriorPHLine.SetDefaultColor(Color.Red);
  plot PivotHighLine = LinePlot(FirstRPoint, PH, PHBar);
       PivotHighLine.SetStyle(Curve.Firm);
       PivotHighLine.SetDefaultColor(Color.Red);
  plot pivotHigh = if HighPivots
                   then PH
                   else double.NaN;
       pivotHigh.SetDefaultColor(GetColor(1));
       pivotHigh.setPaintingStrategy(PaintingStrategy.VALUES_ABOVE);
       pivotHigh.setHiding(!showValues);
  plot RLine = pivotHigh;
       RLine.enableApproximation();
       RLine.SetDefaultColor(GetColor(7));
       RLine.SetStyle(Curve.Short_DASH);
  plot RExtension = if RExtend
                    then (bar - PHBar) * RSlope + PHL
                    else double.NaN;
       RExtension.SetStyle(Curve.Short_DASH);
       RExtension.SetDefaultColor(GetColor(7));
  plot PriorPLLine = LinePlot(PriorSPoint, PriorPL, PriorPLBar);
       PriorPLLine.SetStyle(Curve.Firm);
       PriorPLLine.SetDefaultColor(Color.Green);
  plot PivotLowLine = LinePlot(FirstSPoint, PL, PLBar);
       PivotLowLine.SetStyle(Curve.Firm);
       PivotLowLine.SetDefaultColor(Color.Green);
  plot pivotLow = if LowPivots
                   then PL
                   else double.NaN;
       pivotLow.SetDefaultColor(GetColor(1));
       pivotLow.setPaintingStrategy(PaintingStrategy.VALUES_ABOVE);
       pivotLow.setHiding(!showValues);
  plot SupportLine = pivotLow;
       SupportLine.enableApproximation();
       SupportLine.SetDefaultColor(GetColor(7));
       SUpportLine.SetStyle(Curve.Short_DASH);
  plot SupportExtension = if SExtend
                          then (bar - PLBar) * SSlope + PLL
                          else double.NaN;
       SupportExtension.SetDefaultColor(GetColor(7));
       SupportExtension.SetStyle(Curve.Short_DASH);


### EvanB #######
    plot buy = close[1] > pivotHighLine and high>high[1];
           buy.setPaintingstrategy(PaintingStrategy.BOOLEAN_WEDGE_UP);
           buy.SetDefaultColor(Color.green);

    plot sell = close[1] < pivotlowline  and low < low[1];      
       sell.setPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_DOWN);
        sell.SetDefaultColor(Color.pink);
plot bo = close>open and high>high[1] and close > rextension;
bo.setPaintingstrategy(PaintingStrategy.BOOLEAN_WEDGE_UP);
           bo.SetDefaultColor(Color.green);
plot bd = close<open and low<low[1] and close < supportextension;
bd.setPaintingstrategy(PaintingStrategy.BOOLEAN_WEDGE_down);
           bd.SetDefaultColor(Color.pink);

Alert(condition = buy, text = "Buy", "alert type" = Alert.BAR, sound = Sound.Ding);
Alert(condition = sell, text = "Sell", "alert type" = Alert.BAR, sound = Sound.Ding);
Alert(condition = bo, text = "Breakout", "alert type" = Alert.BAR, sound = Sound.Ring);
Alert(condition = bd, text = "Breakdown", "alert type" = Alert.BAR, sound = Sound.Ring);
 
Last edited by a moderator:
L

Lgh7vst

New member
2019 Donor
VIP
Hello is it possible to add a text or email aler to this?
 
Top