Day Trading with Pivots For ThinkOrSwim

Oh wow was wondering how to get levels that weren't rounded but believe it or not it still has worked extremely well for me regardless of the round up being 0. Im for sure ready to help tackle this anyway i can. As i said though im not the most experienced coder but say we can get my criteria completed i for sure can create a thread on how to play these perfectly. With my 7years of trading experience I can create all the rules on how this should be used then. 70% on SPY calls this morning! with my rounded levels i had 390 as the daily breakout and we were just a hair above that going into the bell so put in a order for nice handful of calls and in addition the 393 calls were over there breakout for the calls so it was a golden trade for me. As a stock analyst anything you need from my experience just let me know. You are beautiful and very talented man for helping me work on this appreciate it alot.
This is going to be epic. Excited to learn your system. I use this indicator as well. It killed on a many tickers today.
 
Oh wow was wondering how to get levels that weren't rounded but believe it or not it still has worked extremely well for me regardless of the round up being 0. Im for sure ready to help tackle this anyway i can. As i said though im not the most experienced coder but say we can get my criteria completed i for sure can create a thread on how to play these perfectly. With my 7years of trading experience I can create all the rules on how this should be used then. 70% on SPY calls this morning! with my rounded levels i had 390 as the daily breakout and we were just a hair above that going into the bell so put in a order for nice handful of calls and in addition the 393 calls were over there breakout for the calls so it was a golden trade for me. As a stock analyst anything you need from my experience just let me know. You are beautiful and very talented man for helping me work on this appreciate it alot.

Are you swinging overnight if a ticker closes above or below the last stand levels?
 
I was just checking this with SPY as @iFrostyy mentioned. Looked pretty great today both ways:

gYOmA79.png
Hey there. Looking to scan for tickers in the bull reversal zone and below on the weekly. Vice versa for shorts.
 
Hey there. Looking to scan for tickers in the bull reversal zone and below on the weekly. Vice versa for shorts.

Since you are only interested in the weekly, you should be able to scan for that just using the plots in the study. I showed a screenshot of the scanner in this post above. You should be able to create one where high is above 'bear last stand' and high is below 'bull target #1' or something like that. There is a decent thread on creating scans on this site if you are new to creating them. Let me know if you have any trouble with it.
 
Since you are only interested in the weekly, you should be able to scan for that just using the plots in the study. I showed a screenshot of the scanner in this post above. You should be able to create one where high is above 'bear last stand' and high is below 'bull target #1' or something like that. There is a decent thread on creating scans on this site if you are new to creating them. Let me know if you have any trouble with it.
Scanning your original study with the wizard doesn't work for me. Using "close is less than smallcamsupport" on weekly agg" not displaying any results. for ex: XOP currently meets the requirements and is not getting pulled in the scan.
 
Scanning your original study with the wizard doesn't work for me. Using "close is less than smallcamsupport" on weekly agg" not displaying any results. for ex: XOP currently meets the requirements and is not getting pulled in the scan.

In the scan setup, you need to make sure you select 'show small cam points' to yes or else the scan will not work. It is a bi-product of how I coded it...the scan needs to have all the same options as the visual. Try making sure that is on and you will see it there:

WDY9qe3.png
 
There has been a lot of discussion here about different Pivot indicators and I wanted to share a slightly different one.

This is a modified Camarilla pivot setup that has been made popular by PostyTrades on Twitter. This setup involves:
  • A bear/bull reversal zone
  • A bear/bull last stand level
  • Two bear/bull extended targets
tIkLNdl.png


These levels, as with most pivots, are simply areas of reference. When combined with other analysis like Vol profile, Price Action, Support/Resistance, Trendlines, etc they can become powerful. Read more about these pivots here: Camarilla Pivots. They provide context on market opening and inform you what to expect - eg. RTH opens above the bearish reversal zone but then trades back through it...this is weakness and likely targets the bullish reversal zone. For this reason, there is a vertical line on the chart that displays the RTH open time but can be switched off OR modified to show another time.

This indicator can be used on Daily/Weekly/Monthly timeframes but it is intended for Day Trading futures. That doesn't mean it won't work for other instruments, just what I have spent time looking at. In addition to the Posty Pivots, I've also included the Central Pivot Range and prior period high/low values as other areas of interest. Each of these elements can be turned off/on in the options.
One thing of interest is the 'RoundLevel' variable. I'm rounding the Pivots to the nearest point on NQ (ie. RoundLevel = 0) but you would want it to be 2 if trading CL or even higher if looking at Forex.

Caveats:
This will not work on mobile as it does not support aggregation periods. I believe the same limitations exist on Range and Renko charts.
The thinkorswim DAY aggregation retrieves the daily close price and NOT the settlement price, which is slightly different. This makes a slight difference in the levels. If you want them to be exact, you need to set the 'Manual Close' to the actual previous day settlement. There may be another way around this but this was the way I had to resolve it.
By default, the indicator will show Today's levels only but you can show prior days as well - just make sure you set 'Manual Close' back to 0 if you want to look at multiple days.
And finally, I am not sure how this is similar/different than PivotBoss work. Maybe others can comment on this but I've derived most of the values here from the original Camarilla information. Possibly others could comment on similarities.

Feedback welcome!

Code:
# Complete Pivot Setup
# Created by @tony_futures
# Inspired from @PostyTrades and @SergeTrades

#declare hide_on_daily;
input aggregationPeriod = {default DAY, WEEK, MONTH, YEAR};
input showCPR = no;
input showPrevious = no;
input showReversalZone = yes;
input showLastStand = yes;
input showLabels = yes;
input showBullTargets = yes;
input showBearTargets = yes;
input showTodayOnly = yes;
input manualClose = 0.00;
input RoundLevel = 0;

def Today = if aggregationPeriod == AggregationPeriod.DAY and GetLastDay() == GetDay() then 1 else if aggregationPeriod == AggregationPeriod.MONTH and GetLastMonth() == GetMonth() then 1  else if aggregationPeriod == AggregationPeriod.WEEK and GetLastWeek() == GetWeek() then 1 else if aggregationPeriod == AggregationPeriod.YEAR and GetLastYEAR() == GetYear() then 1 else 0;

def prevHigh = high(period = aggregationPeriod)[1];
def prevLow = low(period = aggregationPeriod)[1];
def prevClose1 = close(period = aggregationPeriod)[1];
def prevClose = if manualClose != 0 then manualClose else prevClose1;

#Addlabel(aggregationPeriod == AggregationPeriod.DAY," Daily Close: " + prevClose, Color.WHITE);

def pivot = (prevHigh + prevLow + prevClose) / 3.0;
def bc = (prevHigh + prevLow) / 2.0;
def tc = (pivot - bc) + pivot;
def prevDiff = prevHigh - prevLow;
def prevDiff2 = prevDiff*1.1/2;
def prevDiff4 = prevDiff*1.1/4;
def prevDiff8 = prevDiff*1.1/8;

def smallR1 = prevClose + (prevDiff*1.1/ 12);
def smallS1 = prevClose - (prevDiff*1.1/ 12);

def R1 = prevDiff4 + prevClose;
def R3 = RoundDown(prevDiff2 + prevClose, RoundLevel);
def R2 = R3 - prevDiff8;
def R4 = RoundDown(prevDiff + prevClose,RoundLevel);
def R5 = RoundDown((R3 + (1.168 * (R3 - R1))),RoundLevel);

def S1 = PrevClose - prevDiff4;
def S3 = RoundUp(PrevClose - prevDiff2, RoundLevel);
def S2 = S3 + prevDiff8;
def S4 = RoundUp(prevClose - prevDiff, RoundLevel);
def S5 = RoundUp((S3 - (1.168 * ( S1 - S3))), RoundLevel);

# Central Pivot Range - turn off by changing showCPR to no
plot PLine = if showCPR and showTodayOnly and Today then pivot else if showCPR and !showTodayOnly then pivot else Double.NaN;
plot BCLine = if showCPR and showTodayOnly and Today then bc else if showCPR and !showTodayOnly then bc else Double.NaN;
plot TCLine = if showCPR and showTodayOnly and Today then tc else if showCPR and !showTodayOnly then tc else Double.NaN;

PLine.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
PLine.SetDefaultColor(Color.White);
BCLine.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
BCLine.SetDefaultColor(Color.CYAN);
TCLine.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
TCLine.SetDefaultColor(Color.MAGENTA);

# Previous Day High/Low - turn off by changing showPrevious to no
plot PreviousHigh = if showPrevious and showTodayOnly and Today then RoundDown(prevHigh,RoundLevel) else if showPrevious and !showTodayOnly then RoundDown(prevHigh,RoundLevel) else Double.NaN;
PreviousHigh.SetDefaultColor(Color.GRAY);
plot PreviousLow = if showPrevious and showTodayOnly and Today then RoundUp(prevLow,RoundLevel) else if showPrevious and !showTodayOnly then RoundUp(prevLow,RoundLevel) else Double.NaN;
PreviousLow.setDefaultColor(Color.GRAY);
# Reversal zones - turn off by changing showReversalZone to no
AddCloud(if showReversalZone and showTodayOnly and Today then r1 else if showReversalZone and !showTodayOnly then r1 else Double.NaN, r2, Color.DARK_ORANGE, Color.DARK_ORANGE);
AddCloud(if showReversalZone and showTodayOnly and Today then s1 else if showReversalZone and !showTodayOnly then s1 else Double.NaN, s2, Color.LIGHT_GREEN, Color.LIGHT_GREEN);
AddLabel(showReversalZone and showLabels, "Bear zone: " + RoundDown(R1, RoundLevel) + " to " + RoundDown(R2, RoundLevel), Color.LIGHT_RED);
AddLabel(showReversalZone and showLabels, "Bull zone: " + RoundDown(S1, RoundLevel) + " to " + RoundDown(S2, RoundLevel), Color.LIGHT_GREEN);

# Last stand lines - turn off by changing ShowLastStand to no
plot bullLastStand = if showLastStand and showTodayOnly and Today then S3 else if showLastStand and !showTodayOnly then S3 else Double.NaN;
bullLastStand.setDefaultColor(Color.GREEN);
plot bearLastStand = if showLastStand and showTodayOnly and Today then R3 else if showLastStand and !showTodayOnly then R3 else Double.NaN;
bearLastStand.setDefaultColor(Color.RED);

input showBubblesLeft = yes;
AddChartBubble(showBubblesLeft and showLastStand and Today and !Today[1], R3, "Bear Last Stand: " + R3, Color.GRAY, yes);
AddChartBubble(showBubblesLeft and showLastStand and Today and !Today[1], S3, "Bull Last Stand: " + S3, Color.GRAY, no);

AddChartBubble(showBubblesLeft and showPrevious and Today and !Today[1], PrevHigh, "Previous High: " + PrevHigh, Color.GRAY, yes);
AddChartBubble(showBubblesLeft and showPrevious and Today and !Today[1], PrevLow, "Previous Low: " + PrevLow, Color.GRAY, no);

plot bull1 = if showBullTargets and showTodayOnly and Today then R5 else if showBullTargets and !showTodayOnly then R5 else Double.NaN;
bull1.setDefaultColor(Color.MAGENTA);
plot bear1 = if showBearTargets  and showTodayOnly and Today then S5 else if showBearTargets and !showTodayOnly then S5 else Double.NaN;
bear1.setDefaultColor(Color.CYAN);
AddChartBubble(showBubblesLeft and showBullTargets and Today and !Today[1], R5, "Bull Target 1: " + R5, Color.GRAY, yes);
AddChartBubble(showBubblesLeft and showBearTargets and Today and !Today[1], S5, "Bear Target 1: " + S5, Color.GRAY, no);
plot bull2 = if showBullTargets  and showTodayOnly and Today then R4 else if showBullTargets and !showTodayOnly then R4 else Double.NaN;
bull2.setDefaultColor(Color.MAGENTA);
plot bear2 = if showBearTargets  and showTodayOnly and Today then S4 else if showBearTargets and !showTodayOnly then S4 else Double.NaN;
bear2.setDefaultColor(Color.CYAN);
AddChartBubble(showBubblesLeft and showBullTargets and Today and !Today[1], R4, "Bull Target 2: " + R4, Color.GRAY, yes);
AddChartBubble(showBubblesLeft and showBearTargets and Today and !Today[1], S4, "Bear Target 2: " + S4, Color.GRAY, no);

input showOpen = yes;
input Open_Time = 0930;
AddVerticalLine(secondsFromTime(Open_Time)[1] < 0 and secondsFromTime(Open_Time) >= 0 and Today and showOpen, concat("Open", ""), Color.Green, curve.POINTS);

input showBubblesRight = No;
input displaceRightBubble = 3;
def showBubbleNow = !IsNaN(close) and IsNaN(close[-1]);
AddChartBubble(showBubblesRight and showLastStand and showBubbleNow[displaceRightBubble], R3, "Bear Last Stand: " + R3, Color.GRAY, yes);
AddChartBubble(showBubblesRight and showLastStand and showBubbleNow[displaceRightBubble], S3, "Bull Last Stand: " + S3, Color.GRAY, no);

AddChartBubble(showBubblesRight and showPrevious and showBubbleNow[displaceRightBubble], PreviousHigh, "Previous High: " + RoundDown(previousHigh,RoundLevel), Color.GRAY, yes);
AddChartBubble(showBubblesRight and showPrevious and showBubbleNow[displaceRightBubble], PreviousLow, "Previous Low: " + PreviousLow, Color.GRAY, no);

AddChartBubble(showBubblesRight and showBullTargets and showBubbleNow[displaceRightBubble], R5, "Bull Target 1: " + R5, Color.GRAY, yes);
AddChartBubble(showBubblesRight and showBearTargets and showBubbleNow[displaceRightBubble], S5, "Bear Target 1: " + S5, Color.GRAY, no);

AddChartBubble(showBubblesRight and showBullTargets and showBubbleNow[displaceRightBubble], R4, "Bull Target 2: " + R4, Color.GRAY, yes);
AddChartBubble(showBubblesRight and showBearTargets and showBubbleNow[displaceRightBubble], S4, "Bear Target 2: " + S4, Color.GRAY, no);

input showWeeklyLabels = yes;
AddChartBubble(showWeeklyLabels and AggregationPeriod == AggregationPeriod.WEEK and Today and !Today[1], (R2 - R1)/2 + R1, "Weekly", Color.WHITE, yes);
AddChartBubble(showWeeklyLabels and AggregationPeriod == AggregationPeriod.WEEK and Today and !Today[1], (S1 - S2)/2 + S2, "Weekly", Color.WHITE, no);

input showSmallCamPoints = no;
plot smallCamResistance = if showSmallCamPoints and Today then smallR1 else Double.NaN;
smallCamResistance.setDefaultColor(Color.LIGHT_RED);
plot smallCamSupport = if showSmallCamPoints and Today then smallS1 else Double.NAN;
smallCamSupport.setDefaultColor(Color.LIGHT_GREEN);
I absolutely love this - is there a TradingView Version of this by chance?

I have been looking for a indicator on TV and there are some, but some do not match up as much as I would like them to with this current TOS one. I am not sure where I am seeing the issues, it is only at the bull/bear target 1. Any thoughts?
 
Last edited:
Just came across this and have to say this is one of the best indicators I've seen on the website. Kudos to all who put a ton of work into developing this. Just a quick question if someone can help me understand: when it says, bull or bears last stand, is it referring to S3/R3 Camarilla reversal zones?
 
I was just checking this with SPY as @iFrostyy mentioned. Looked pretty great today both ways:

gYOmA79.png
@FutureTony Thank you for this excellent indicator. May I know what does Last Bull/Bear Stand mean and what timeframe is most suitable to use? Can you share how do you apply this system on your daily trading routine? Thanks
 
Just came across this and have to say this is one of the best indicators I've seen on the website. Kudos to all who put a ton of work into developing this. Just a quick question if someone can help me understand: when it says, bull or bears last stand, is it referring to S3/R3 Camarilla reversal zones?

That is correct, yes.
 
@FutureTony Thank you for this excellent indicator. May I know what does Last Bull/Bear Stand mean and what timeframe is most suitable to use? Can you share how do you apply this system on your daily trading routine? Thanks

This study is based on Camarilla Pivot points. There is quite a bit of information here and elsewhere on the logic of the system. IMO, you can use them on any timeframe. They are trying to approximate 'expected' ranges and movement. @iFrostyy has mentioned he uses the daily levels on very small timeframes. Others use the monthly/quarterly levels to swing stocks. It really is dependent on what your trading style is...hopefully that helps a bit.
 
Do you have a watchlist
This study is based on Camarilla Pivot points. There is quite a bit of information here and elsewhere on the logic of the system. IMO, you can use them on any timeframe. They are trying to approximate 'expected' ranges and movement. @iFrostyy has mentioned he uses the daily levels on very small timeframes. Others use the monthly/quarterly levels to swing stocks. It really is dependent on what your trading style is...hopefully that helps a bit.
Do you have a watchlist colum for when close is in bull or bear zone?
 
As I mentioned above, I would opt to add another level to screen out some of these tickers - possibly a weekly moving average or something so you are typically 'buying strength' but to each their own. One other thing I have thought about is NOT alerting in the first five minutes to weed out some gapping activity...

bRBQw9F.png

This is the scan setup above. Note I've added price over $8 and volume over 1 million for this example. Select from the 'All Optionable' universe in the top left and then add your criteria. The custom study we are using is the 'bullAlertNow' value equal to 1 from the code above. You can then choose to save as a watchlist and alert whenever the watchlist changes. This may have a slight delay but my experience with it has been quite good.
Not getting any scan results or arrows when added to chart with the pivot study; does it have to be a bullish day to see results?
 
load the scanner but the arrows show up did not correlate with when price crosses above "last stand for bear/bull"...hmm weird. Or maybe this only work during trading hour?
 
Last edited:

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
373 Online
Create Post

Similar threads

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.
Back
Top