Auto Pivot Points Support & Resistance Indicator for ThinkorSwim

S

stocksniper

Member
looking for daily resistance to put on a 1 minute or 5 min time frame.
 
J

jrchezz

New member
Hello, team - attempting to learn how to buy and sell options with only Support and Resistance. If you have a simple indicator... please post and thanks

p.s. - Learning how to code and I start classes next term. Any advise would be welcome too (All the best)
 
horserider

horserider

Well-known member
VIP
So many. Where to start???? Any idea what you are interested in exploring?
 
J

jrchezz

New member
So many. Where to start???? Any idea what you are interested in exploring?
So many. Where to start???? Any idea what you are interested in exploring?
Hello, sir - I'm looking for something simple, that's not very complex i.e. Two lines Support/Resistance that would help me
see the breakout in order to jump in. I think someone on this site posted http://tos.mx/Evki6yU (looks great!) It has too many S/R lines and I can't tell easily when to buy/sell.

Horserider - thank you for your kindness too
 
horserider

horserider

Well-known member
VIP
That one would be more suitable for short term trades. Being in classes I assume you want to swing trade ?
 
horserider

horserider

Well-known member
VIP
Nothing simple about fast in and out. Not sure if just two lines will work for that. The one that was sent to you would be suitable but as you noted, many lines. And with classes that could be difficult. IF you can explain exactly how you want to trade, better recommendations can be made.
 
H

Hitesh

New member
This script is from trading view and looking for help if someone can convert to ThinkorSwim script.

Code:
study("Higher High Lower Low Strategy", overlay =true)
lb = input(2, title="Left Bars", minval = 1)
rb = input(2, title="Right Bars", minval = 1)
showsupres = input(true, title="Show Support/Resistance")
changebarcol = input(true, title="Change Bar Color")
mb = lb + rb + 1
ph = iff(not na(high[mb]), iff(highestbars(high, mb) == -lb, high[lb], na), na) // Pivot High
pl = iff(not na(low[mb]), iff(lowestbars(low, mb) == -lb, low[lb], na), na) // Pivot Low
hl = na
hl := iff(ph, 1, iff(pl, -1, na)) // Trend direction
zz = na
zz := iff(ph, ph, iff(pl, pl, na)) // similar to zigzag but may have multiple highs/lows
zz :=iff(pl and hl == -1 and valuewhen(hl, hl, 1) == -1 and pl > valuewhen(zz, zz, 1), na, zz)
zz :=iff(ph and hl == 1  and valuewhen(hl, hl, 1) == 1  and ph < valuewhen(zz, zz, 1), na, zz)
hl := iff(hl==-1 and valuewhen(hl, hl, 1)==1 and zz > valuewhen(zz, zz, 1), na, hl)
hl := iff(hl==1 and valuewhen(hl, hl, 1)==-1 and zz < valuewhen(zz, zz, 1), na, hl)
zz := iff(na(hl), na, zz)
findprevious()=>  // finds previous three points (b, c, d, e)
ehl = iff(hl==1, -1, 1)
loc1 = 0.0, loc2 = 0.0, loc3 = 0.0, loc4 = 0.0
xx = 0
for x=1 to 1000
if hl[x]==ehl and not na(zz[x])
loc1 := zz[x]
xx := x + 1
break
ehl := hl
for x=xx to 1000
if hl[x]==ehl and not na(zz[x])
loc2 := zz[x]
xx := x + 1
break
ehl := iff(hl==1, -1, 1)
for x=xx to 1000
if hl[x]==ehl and not na(zz[x])
loc3 := zz[x]
xx := x + 1
break
ehl := hl
for x=xx to 1000
if hl[x]==ehl and not na(zz[x])
loc4 := zz[x]
break
    [loc1, loc2, loc3, loc4]
a = na, b = na, c = na, d = na, e = na
if not na(hl)
[loc1, loc2, loc3, loc4] = findprevious()
a := zz
b := loc1
c := loc2
d := loc3
    e := loc4
_hh = zz and (a > b and a > c and c > b and c > d)
_ll = zz and (a < b and a < c and c < b and c < d)
_hl = zz and ((a >= c and (b > c and b > d and d > c and d > e)) or (a < b and a > c and b < d))
_lh = zz and ((a <= c and (b < c and b < d and d < c and d < e)) or (a > b and a < c and b > d))
plotshape(_hl, text="HL", title="Higher Low", style=shape.labelup, color=lime, textcolor=black, location=location.belowbar, transp=0, offset = -lb)
plotshape(_hh, text="HH", title="Higher High", style=shape.labeldown, color=lime, textcolor=black, location=location.abovebar, transp=0, offset = -lb)
plotshape(_ll, text="LL", title="Lower Low", style=shape.labelup, color=red, textcolor=white, location=location.belowbar, transp=0, offset = -lb)
plotshape(_lh, text="LH", title="Lower High", style=shape.labeldown, color=red, textcolor=white, location=location.abovebar, transp=0, offset = -lb)
res = na, sup = na
res := iff(_lh, zz, res[1])
sup := iff(_hl, zz, sup[1])
trend = na
trend := iff(close > res, 1, iff(close < sup, -1, nz(trend[1])))
res := iff((trend == 1 and _hh) or (trend == -1 and _lh), zz, res)
sup := iff((trend == 1 and _hl) or (trend == -1 and _ll), zz, sup)
plot(showsupres ? res : na, title="Resistance", color= na(res) ? na : red, linewidth=2, style=circles, offset = -lb)
plot(showsupres ? sup : na, title="Support", color= na(sup) ? na : blue, linewidth=2, style=circles, offset = -lb)
barcolor(color = iff(changebarcol, iff(trend == 1, blue, black), na))
 
Last edited by a moderator:
J

jrchezz

New member
Nothing simple about fast in and out. Not sure if just two lines will work for that. The one that was sent to you would be suitable but as you noted, many lines. And with classes that could be difficult. IF you can explain exactly how you want to trade, better recommendations can be made.

That one would be more suitable for short term trades. Being in classes I assume you want to swing trade ?
Hello, Horserider - forgive me for the delay to reply and thank you. Ben provided an indicator and I'll test it this weekend. Sister from New York made a surprise trip to Bossier City, LA for my birthday. This is the first, I was able to access eMail and the website. All the best to you partner
 
J

jrchezz

New member
@jrchezz Happy Birthday
Hello, Horserider - I'm providing the code for the Support Resistance that I would like to start trading with but only after some testing. I'm hoping you could insert an alert for when the LowSwing and HighSwing Up/Down Arrows appear. Take care partner, Jr.
Code:
declare upper;
input LookbackPeriod = 5;
input HideCurrentTF = no;
input HideTimeFrame2 = no;
input HideTimeFrame3 = no;
input TimeFrame2 = {default "15 MIN", "1 MIN", "2 MIN", "3 MIN", "4 MIN", "5 MIN", "10 MIN", "20 MIN", "30 MIN", "1 HOUR", "2 HOURS", "4 HOURS", DAY, "2 DAYS", "3 DAYS", "4 DAYS", WEEK, MONTH, "OPT EXP"};
input TimeFrame3 = {default "30 MIN", "1 MIN", "2 MIN", "3 MIN", "4 MIN", "5 MIN", "10 MIN", "15 MIN", "20 MIN", "1 HOUR", "2 HOURS", "4 HOURS", DAY, "2 DAYS", "3 DAYS", "4 DAYS", WEEK, MONTH, "OPT EXP"};
input HideSwings = no;
input SwingsLagBar = 1;
#--------------------------------------------------------------
def _highInPeriod1 = Highest(high, LookbackPeriod);
def _lowInPeriod1 = Lowest(low, LookbackPeriod);
#--------------------------------------------------------------
def marketLow1 = if _lowInPeriod1 < _lowInPeriod1[-LookbackPeriod] then _lowInPeriod1 else _lowInPeriod1[-LookbackPeriod];
def _markedLow1 = low == marketLow1;
rec _lastMarkedLow1 = CompoundValue(1, if IsNaN(_markedLow1) then _lastMarkedLow1[1] else if _markedLow1 then low else _lastMarkedLow1[1], low);
#--------------------------------------------------------------
def marketHigh1 = if _highInPeriod1 > _highInPeriod1[-LookbackPeriod] then _highInPeriod1 else _highInPeriod1[-LookbackPeriod];
def _markedHigh1 = high == marketHigh1;
rec _lastMarkedHigh1 = CompoundValue(1, if IsNaN(_markedHigh1) then _lastMarkedHigh1[1] else if _markedHigh1 then high else _lastMarkedHigh1[1], high);
#--------------------------------------------------------------
plot Resistance1 = _lastMarkedHigh1;
plot Support1 = _lastMarkedLow1;
#--------------------------------------------------------------
Resistance1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Resistance1.SetDefaultColor(Color.GREEN);
Resistance1.SetHiding(HideCurrentTF);
#--------------------------------------------------------------
Support1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Support1.SetDefaultColor(Color.RED);
Support1.SetHiding(HideCurrentTF);
#--------------------------------------------------------------
def LowSwingForw = Lowest(low, SwingsLagBar)[-SwingsLagBar];
def LowSwingBack = Lowest(low, LookbackPeriod)[1];
def SwingLow = if low < LowSwingForw and low <= LowSwingBack then 1 else 0;
plot LowSwing = if SwingLow then low else Double.NaN;
#--------------------------------------------------------------
def HighSwingForw = Highest(high, SwingsLagBar)[-SwingsLagBar];
def HighSwingBack = Highest(high, LookbackPeriod)[1];
def SwingHigh = if high > HighSwingForw and high >= HighSwingBack then 1 else 0;
plot HighSwing = if SwingHigh then high else Double.NaN;
#--------------------------------------------------------------
HighSwing.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
HighSwing.SetLineWeight(5);
HighSwing.SetDefaultColor(Color.RED);
HighSwing.SetHiding(HideSwings);
LowSwing.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
LowSwing.SetLineWeight(5);
LowSwing.SetDefaultColor(Color.GREEN);
LowSwing.SetHiding(HideSwings);
#--------------------------------------------------------------
Alert(HighSwing, "SupRes : Swing High", Alert.BAR, Sound.Bell);
Alert(LowSwing, "SupRes : Swing Low", Alert.BAR, Sound.Bell);
#--------------------------------------------------------------
AddLabel(HighSwing, "SupRes : Swing High", Color.RED);
AddLabel(LowSwing, "SupRes : Swing Low", Color.GREEN);
#--------------------------------------------------------------
def _highInPeriod2 = Highest(high(period = TimeFrame2), LookbackPeriod);
def _lowInPeriod2 = Lowest(low(period = TimeFrame2), LookbackPeriod);
#--------------------------------------------------------------
def marketLow2 = if _lowInPeriod2 < _lowInPeriod2[-LookbackPeriod] then _lowInPeriod2 else _lowInPeriod2[-LookbackPeriod];
def _markedLow2 = low(period = TimeFrame2) == marketLow2;
rec _lastMarkedLow2 = CompoundValue(1, if IsNaN(_markedLow2) then _lastMarkedLow2[1] else if _markedLow2 then low(period = TimeFrame2) else _lastMarkedLow2[1], low(period = TimeFrame2));
#--------------------------------------------------------------
def marketHigh2 = if _highInPeriod2 > _highInPeriod2[-LookbackPeriod] then _highInPeriod2 else _highInPeriod2[-LookbackPeriod];
def _markedHigh2 = high(period = TimeFrame2) == marketHigh2;
rec _lastMarkedHigh2 = CompoundValue(1, if IsNaN(_markedHigh2) then _lastMarkedHigh2[1] else if _markedHigh2 then high(period = TimeFrame2) else _lastMarkedHigh2[1], high(period = TimeFrame2));
#--------------------------------------------------------------
plot Resistance2 = _lastMarkedHigh2;
plot Support2 = _lastMarkedLow2;
#--------------------------------------------------------------
Resistance2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Resistance2.SetDefaultColor(Color.GREEN);
Resistance2.SetHiding(HideTimeFrame2);
#--------------------------------------------------------------
Support2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Support2.SetDefaultColor(Color.RED);
Support2.SetHiding(HideTimeFrame2);
#--------------------------------------------------------------
def _highInPeriod3 = Highest(high(period = TimeFrame3), LookbackPeriod);
def _lowInPeriod3 = Lowest(low(period = TimeFrame3), LookbackPeriod);
#--------------------------------------------------------------
def marketLow3 = if _lowInPeriod3 < _lowInPeriod3[-LookbackPeriod] then _lowInPeriod3 else _lowInPeriod3[-LookbackPeriod];
def _markedLow3 = low(period = TimeFrame3) == marketLow3;
rec _lastMarkedLow3 = CompoundValue(1, if IsNaN(_markedLow3) then _lastMarkedLow3[1] else if _markedLow3 then low(period = TimeFrame3) else _lastMarkedLow3[1], low(period = TimeFrame3));
#--------------------------------------------------------------
def marketHigh3 = if _highInPeriod3 > _highInPeriod3[-LookbackPeriod] then _highInPeriod3 else _highInPeriod3[-LookbackPeriod];
def _markedHigh3 = high(period = TimeFrame3) == marketHigh3;
rec _lastMarkedHigh3 = CompoundValue(1, if IsNaN(_markedHigh3) then _lastMarkedHigh3[1] else if _markedHigh3 then high(period = TimeFrame3) else _lastMarkedHigh3[1], high(period = TimeFrame3));
#--------------------------------------------------------------
plot Resistance3 = _lastMarkedHigh3;
plot Support3 = _lastMarkedLow3;
#--------------------------------------------------------------
Resistance3.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Resistance3.SetDefaultColor(Color.GREEN);
Resistance3.SetHiding(HideTimeFrame3);
#--------------------------------------------------------------
Support3.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Support3.SetDefaultColor(Color.RED);
Support3.SetHiding(HideTimeFrame3);
 
T

tomsk

Well-known member
VIP
@jrchezz All you need to do is to just append the following two statements to the end of your study and you'll have the alerts for the arrows all set to go

Code:
Alert(HighSwing, "High Swing", Alert.BAR, Sound.Ring);
Alert(LowSwing, "Low Swing", Alert.BAR, Sound.Bell);
 
horserider

horserider

Well-known member
VIP
@jrchezz Glad Tomsk was able to help you. Best of luck.
 
J

jrchezz

New member
Hello Horserider - many thanks for checking back and after a couple of weeks, I'll provide you an update. ttl Jr.
 
J

jrchezz

New member
@jrchezz All you need to do is to just append the following two statements to the end of your study and you'll have the alerts for the arrows all set to go

Code:
Alert(HighSwing, "High Swing", Alert.BAR, Sound.Ring);
Alert(LowSwing, "Low Swing", Alert.BAR, Sound.Bell);

Hello, Tomsk - wonderful news... I was able to trade this morning and made $140 - - - you "Rock!" all the best to you partner Jr.
 
J

joshua74133

New member
Is there anyway to make a support study that will print the lines for the full day? from pre market to end of day? I don't know why I cant find this anywhere
 
BenTen

BenTen

Administrative
Staff
VIP
@joshua74133 Are you referring to pre-market high and low?
 
J

joshua74133

New member
@joshua74133 Are you referring to pre-market high and low?
No I'm talking about all these auto support studies have the support lines show up in pre market but they end when a new support line is created. I want all the lines that the auto support draws to have those lines drawn all the way across for the full day
 
J

joshua74133

New member

This picture is what I'm talking about. I want all the lines to go all the way across from pre market to end of day
 

Top