# Support & Resistance For ThinkOrSwim

#### whats up

##### Member
VIP
Can we get this supply and demand indicator? Like the one in the video I just posted below. Thanks

#### BenTen

Staff member
Staff
VIP
The above is not really Supply & Demand. It is nothing but Support and Resistance (as noted by the YouTuber). It's better if you learn how to draw the S/R levels manually. An indicator won't do it justice for the stock. You can check out this indicator below.

If you are having trouble with the plots not showing up on your chart:
I found the issue. In the lower timeframe, I need to use more data such as 30 min in 30 days not in 5 days to show complete supports and resistances.

Code:
``````# Mobius
# Support / Resistance
# V01.06.2012 V02.08.2013
# Added lower bar for clouds, Volume condition for plot and Vertical line for time.

input n = 13;
input ShowLines = yes;
input PlotTime = 1215; #hint PlotTime: Enter Bars End to plot Bars Start 0 for none.

def h = high;
def l = low;
def v = volume;
def Firstbar = barNumber();
def Highest = fold i = 1 to n + 1
with p = 1
while p
do h > getValue(h,-i);

def HVn = if V == Highest(v, n)
then l
else Double.NaN;

def A = if (Firstbar > n
and h == highest(h, n)
and Highest)
and HVn
then h
else double.NaN;
def Alow = if (Firstbar > n
and h == highest(h, n)
and Highest)
and HVn
then l
else double.nan;
def Lowest = fold j = 1 to n + 1
with q = 1
while q
do l < getValue(l, -j);
def B = if (Firstbar > n
and l == lowest(l, n)
and Lowest)
and HVn
then l
else double.NaN;
def Bhigh = if (Firstbar > n
and l == lowest(l, n)
and Lowest)
and HVn
then h
else double.nan;
def Al = if !isNaN(A)
then A
else Al[1];
def A2 = if !isNaN(Alow)
then Alow
else A2[1];
def Bl = if !isNaN(B)
then B
else Bl[1];
def B2 = if !isNaN(Bhigh)
then Bhigh
else B2[1];

plot ph = Round(A, 2);
ph.setPaintingStrategy(PaintingStrategy.VALUES_ABOVE);

plot hL = if Al > 0
then Al
else double.NaN;
hL.setHiding(!showLines);
hL.SetPaintingStrategy(PaintingStrategy.Dashes);
hL.SetDefaultColor(Color.Yellow);
plot hL2 = if A2 > 0
then A2
else double.nan;
hL2.setHiding(!showLines);
hL2.SetPaintingStrategy(PaintingStrategy.Dashes);
hL2.SetDefaultColor(Color.Yellow);

plot pl = Round(B, 2);
pl.setPaintingStrategy(PaintingStrategy.VALUES_BELOW);

plot ll = if Bl > 0
then Bl
else double.NaN;
ll.setHiding(!showLines);
ll.SetPaintingStrategy(PaintingStrategy.Dashes);
ll.SetDefaultColor(Color.Blue);
plot lH = if B2 > 0
then B2
else Double.NaN;
lH.setHiding(!showLines);
lH.SetPaintingStrategy(PaintingStrategy.Dashes);
lH.SetDefaultColor(Color.Blue);

# Time Markers
AddVerticalLine(SecondsTillTime(PlotTime) == 0, "", Color.Red, Curve.Short_Dash);

plot priceLine = highestAll(if isNaN(close[-1])
and !isNAN(close)
then close
else Double.NaN);
priceLine.SetStyle(Curve.Long_Dash);
priceLine.SetDefaultColor(CreateColor(75,75,75));
priceLine.SetLineWeight(1);
# End Code``````

Last edited by a moderator:

#### markos

##### Well-known member
VIP
There are several studies like this on the site. Type the word Pivot in the search box above and see what you come up with.

Or you could use fractal boxes...

#### john3

##### Active member
2019 Donor
@markos What are fractal boxes?

#### markos

##### Well-known member
VIP
@john3 I put it in a separate thread on this site. They are basically areas of support/resistance in a given time frame. You can then see when it escapes the box. Markets are fractal, but I have no idea how this would work or be of benefit on small aggs/ timeframes. Hope that helps.

#### thinky

##### Member
What studies Steve Miller uses to create the projection lines and S&R areas in charts?

#### markos

##### Well-known member
VIP
What studies Steve Miller uses to create the projection lines and S&R areas in charts?
Hi @thinky his website is askslim.com. He also posts YouTube and twitter videos. Start there first. Look through his list of resources.

#### roger80k

##### New member
Hi Guys,

Can you please help me locate this type of MTF Supply Zone Script. As shown in this Youtube Video that will show the supply zone with the time frame placed on the box.

Thanks

#### BenTen

Staff member
Staff
VIP
@roger80k If I'm not mistaken, that was drawn manually.

#### BenTen

Staff member
Staff
VIP
There are tons of different support and resistance indicators. You can see a list of them here.

With just that screenshot, it's hard to know how the indicator was created. However, that reminds me of Jose's SwingArm indicator.

#### kevin_Boston

##### New member
Just thought to share a study I use. Not sure if this already exists here.
• Support/Resistance Zones around pivot S/R points.
• zones using ATR to the Theotrade Pivots study.
http://tos.mx/Qf8BmGT

Ruby:
``````# Support/Resistance Zones around pivot S/R points.

input length = 252;
input averageType = AverageType.WILDERS;

def ATR = MovingAverage(averageType, TrueRange(high, close, low), length);

# User Inputs
input n = 21; #hint n: periods used for pivot calculations.
def Num_Dev_Dn = ATR;
def Num_Dev_up = -ATR;

# 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;
}
# Variables
def o = open;
def h = high;
def l = low;
def c = close;
def bar = BarNumber();
def BBar = bar == HighestAll(bar);
# Parent High
def ParentHigh = HighestAll(h);
def ParentHBarOrigin = if h == ParentHigh
then bar
else ParentHBarOrigin[1];
def ParentHBarID = bar - HighestAll(ParentHBarOrigin);
# R1
def hh = fold i = 1 to n + 1
with p = 1
while p
do h > GetValue(h, -i);
def PivotH = if (bar > n and
h == Highest(h, n) and
hh)
then h
else Double.NaN;
def PHValue = if !IsNaN(PivotH)
then PivotH
else PHValue[1];
def PHBarOrigin = if !IsNaN(PivotH)
then bar
else PHBarOrigin[1];
def PHBarID = bar - PHBarOrigin;
# R2
def R2PHValue = if PHBarOrigin != PHBarOrigin[1]
then PHValue[1]
else R2PHValue[1];
def R2PHBarOrigin = if PHBarOrigin != PHBarOrigin[1]
then PHBarOrigin[1]
else R2PHBarOrigin[1];
def R2PHBarID = bar - R2PHBarOrigin;
# R3
def R3PHValue = if R2PHBarOrigin != R2PHBarOrigin[1]
then R2PHValue[1]
else R3PHValue[1];
def R3PHBarOrigin = if R2PHBarOrigin != R2PHBarOrigin[1]
then R2PHBarOrigin[1]
else R3PHBarOrigin[1];
def R3PHBarID = bar - R3PHBarOrigin;
# R4
def R4PHValue = if R3PHBarOrigin != R3PHBarOrigin[1]
then R3PHValue[1]
else R4PHValue[1];
def R4PHBarOrigin = if R3PHBarOrigin != R3PHBarOrigin[1]
then R3PHBarOrigin[1]
else R4PHBarOrigin[1];
def R4PHBarID = bar - R4PHBarOrigin;

# Parent Low
def ParentLow = LowestAll(l);
def ParentLBarOrigin = if l == ParentLow
then bar
else ParentLBarOrigin[1];
def ParentLBarID = bar - HighestAll(ParentLBarOrigin);
# S1
def ll = fold j = 1 to n + 1
with q = 1
while q
do l < GetValue(l, -j);
def PivotL = if (bar > n and
l == Lowest(l, n) and
ll)
then l
else Double.NaN;
def PLValue = if !IsNaN(PivotL)
then PivotL
else PLValue[1];
def PLBarOrigin = if !IsNaN(PivotL)
then bar
else PLBarOrigin[1];
def PLBarID = bar - PLBarOrigin;
# S2
def S2PLValue = if PLBarOrigin != PLBarOrigin[1]
then PLValue[1]
else S2PLValue[1];
def S2PLBarOrigin = if PLBarOrigin != PLBarOrigin[1]
then PLBarOrigin[1]
else S2PLBarOrigin[1];
def S2PLBarID = bar - S2PLBarOrigin;
# S3
def S3PLValue = if S2PLBarOrigin != S2PLBarOrigin[1]
then S2PLValue[1]
else S3PLValue[1];
def S3PLBarOrigin = if S2PLBarOrigin != S2PLBarOrigin[1]
then S2PLBarOrigin[1]
else S3PLBarOrigin[1];
def S3PLBarID = bar - S3PLBarOrigin;
# S4
def S4PLValue = if S3PLBarOrigin != S3PLBarOrigin[1]
then S3PLValue[1]
else S4PLValue[1];
def S4PLBarOrigin = if S3PLBarOrigin != S3PLBarOrigin[1]
then S3PLBarOrigin[1]
else S4PLBarOrigin[1];
def S4PLBarID = bar - S4PLBarOrigin;

# Plots
plot PR1 = LinePlot(BarID = ParentHBarID,
Value = ParentHigh,
BarOrigin = HighestAll(ParentHBarOrigin));
PR1.SetDefaultColor(Color.GREEN);
#addChartBubble(Bar == HighestAll(ParentHBarOrigin), ParentHigh, "High", color.yellow, 1);
plot R1 = LinePlot(BarID = PHBarID,
Value = PHValue,
BarOrigin = PHBarOrigin);
R1.SetDefaultColor(Color.GREEN);
#AddChartBubble(bar == HighestAll(PHBarOrigin), PHValue, "R1", Color.GREEN, 1);

plot LowerBandr1 = R1 + Num_Dev_Dn ;
plot UpperBandr1 = R1 + Num_Dev_up ;
lowerbandr1.hide();
upperbandr1.hide();

plot R2 = LinePlot(BarID = R2PHBarID,
Value = R2PHValue,
BarOrigin = R2PHBarOrigin);
R2.SetDefaultColor(Color.GREEN);
#AddChartBubble(bar == HighestAll(R2PHBarOrigin), PHValue, "R2", Color.GREEN, 1);

plot LowerBandr2 = R2 + Num_Dev_Dn ;
plot UpperBandr2 = R2 + Num_Dev_up ;
lowerbandr2.hide();
upperbandr2.hide();

plot R3 = LinePlot(BarID = R3PHBarID,
Value = R3PHValue,
BarOrigin = R3PHBarOrigin);
R3.SetDefaultColor(Color.GREEN);
#AddChartBubble(bar == HighestAll(R3PHBarOrigin), PHValue, "R3", Color.GREEN, 1);

plot LowerBandr3 = R3 + Num_Dev_Dn ;
plot UpperBandr3 = R3 + Num_Dev_up ;
lowerbandr3.hide();
upperbandr3.hide();

plot R4 = LinePlot(BarID = R4PHBarID,
Value = R4PHValue,
BarOrigin = R4PHBarOrigin);
R4.SetDefaultColor(Color.GREEN);
#AddChartBubble(bar == HighestAll(R4PHBarOrigin), PHValue, "R4", Color.GREEN, 1);

plot LowerBandr4 = R4 + Num_Dev_Dn ;
plot UpperBandr4 = R4 + Num_Dev_up ;
lowerbandr4.hide();
upperbandr4.hide();

plot PS1 = LinePlot(BarID = ParentLBarID,
Value = ParentLow,
BarOrigin = HighestAll(ParentLBarOrigin));
PS1.SetDefaultColor(Color.RED);
#AddChartBubble(bar == HighestAll(ParentLBarOrigin), ParentLow, "Low", Color.YELLOW, 0);
plot S1 = LinePlot(BarID = PLBarID,
Value = PLValue,
BarOrigin = PLBarOrigin);
S1.SetDefaultColor(Color.RED);
#AddChartBubble(bar == HighestAll(PLBarOrigin), PLValue, "S1", Color.RED, 0);

plot LowerBands1 = S1 + Num_Dev_Dn ;
plot UpperBands1 = S1 + Num_Dev_up ;
lowerbands1.hide();
upperbands1.hide();

plot S2 = LinePlot(BarID = S2PLBarID,
Value = S2PLValue,
BarOrigin = S2PLBarOrigin);
S2.SetDefaultColor(Color.RED);
#AddChartBubble(bar == HighestAll(S2PLBarOrigin), PLValue, "S2", Color.RED, 0);

plot LowerBands2 = S2 + Num_Dev_Dn ;
plot UpperBands2 = S2 + Num_Dev_up ;
lowerbands2.hide();
upperbands2.hide();

plot S3 = LinePlot(BarID = S3PLBarID,
Value = S3PLValue,
BarOrigin = S3PLBarOrigin);
S3.SetDefaultColor(Color.RED);
#AddChartBubble(bar == HighestAll(S3PLBarOrigin), PLValue, "S3", Color.RED, 0);

plot LowerBands3 = S3 + Num_Dev_Dn ;
plot UpperBands3 = S3 + Num_Dev_up ;
lowerbands3.hide();
upperbands3.hide();

plot S4 = LinePlot(BarID = S4PLBarID,
Value = S4PLValue,
BarOrigin = S4PLBarOrigin);
S4.SetDefaultColor(Color.RED);
#AddChartBubble(bar == HighestAll(S4PLBarOrigin), PLValue, "S4", Color.RED, 0);

plot LowerBands4 = S4 + Num_Dev_Dn ;
plot UpperBands4 = S4 + Num_Dev_up ;
lowerbands4.hide();
upperbands4.hide();

plot BearScan = if (close crosses below S1) or
(close crosses below S2)
then close
else Double.NaN;
plot BullScan = if (close crosses above R1) or
(close crosses above R2)
then close
else Double.NaN;
# End Code Fractal Array``````

Last edited by a moderator:

VIP

#### Fupaflap

##### New member
So I’m a casual trader I like to do the same play every Monday, Wednesday, Friday on SPX. Watched this trend for awhile before starting my trade but it’s basically a double diagonal, I STO ATM a call and put then buy a call/put each 15 points out from the atm a week out. I basically went for the opening movement to settle and buy in around 945 and then exit when my play is up 1.00, simple easy hundred bucks

However, I’ve made rules when to bail and they fit my trading but the big thing is timing the buy in, if you buy too early and you kind of have to ride out a risky dip and that’s really the only time I’ll lose is selling too early before it bounces back and play goes green.

If I have an indicator that could kind of give me an idea for the support and resistance of SPX for just like the first 2 hours of opening bell it could really help. Right now I just use the Wolf Wave indicator and on the 5 min and 1 hour time frame it does OK? But could I be doing a better job? Basically the play excels when SPX barely moves. I can be in the play at 950, for 23.50 then out at 1005 for 24.50

#### mkdear

##### New member
VIP
I need help in creating multi-time frame support and resistance label/indicator. I am primarily looking for one support and resistance point in each timeframe. I have pasted the simplified version of support and resistance for current time frame. Can someone create multi-time frame support and resistance? Thank you!

Code:
``````def n = 21;
def vHigh = high;
def vLow = low;
def bn = BarNumber();

def PH;
def PL;
def hh = fold i = 1 to n + 1 with p = 1 while p do vHigh > GetValue(vHigh, -i);
PH = if (bn > n and vHigh == Highest(vHigh, n) and hh) then vHigh else Double.NaN;
def ll = fold j = 1 to n + 1 with q = 1 while q do vLow < GetValue(low, -j);
PL = if (bn > n and vLow == Lowest(vLow, n) and ll) then vLow else Double.NaN;
def PHBar = if !IsNaN(PH) then bn else PHBar[1];
def PLBar = if !IsNaN(PL) then bn 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 PLL = if !IsNaN(PL) then PL else PLL[1];
def priorPLBar = if PLL != PLL[1] then PLBar[1] else priorPLBar[1];
def HighPivots = bn >= HighestAll(priorPHBar);
def LowPivots = bn >= HighestAll(priorPLBar);
def pivotHighLine = if PHL > 0 and HighPivots then PHL else Double.NaN;
def pivotLowLine = if PLL > 0 and LowPivots then PLL else Double.NaN;``````

#### mkdear

##### New member
VIP
Nevermind! I think I figured it out. Using different "n" will mimic a multi-timeframe Pivots.

## The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
• Exclusive indicators
• Proven strategies & setups
• Private Discord community
• Exclusive members-only content
• 1 full year of unlimited support

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?