Day Trading with Pivots For ThinkOrSwim

The challenge with this scan is that it is going to show all tickers that have crossed above this week, not just tickers that are currently crossing above in say the last 10 min.

There's a way to do it without relying on a higher timeframe agg, but it's not great. You need to track the h/l/c of the period bar by bar, then store the values when the period rolls over. You then calculate the cams based on those values and scan against them. I've done it before and it works ok, except that the close of the last bar of the day often doesn't match the close of the daily candle, so you get some fake out alerts.
Yes exactly i need a 5min scan
well im going to attempt it. Cant believe they make it so hard for me to just say i want a signal when the close of this 5min bar to gos below or over this line lol
 
Last edited by a moderator:

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

The challenge with this scan is that it is going to show all tickers that have crossed above this week, not just tickers that are currently crossing above in say the last 10 min.

There's a way to do it without relying on a higher timeframe agg, but it's not great. You need to track the h/l/c of the period bar by bar, then store the values when the period rolls over. You then calculate the cams based on those values and scan against them. I've done it before and it works ok, except that the close of the last bar of the day often doesn't match the close of the daily candle, so you get some fake out alerts.
could you please share the scanner link?
 
@FutureTony How hard would it be to add a Quarterly Time Frame To This? Nice Work I will have to overlay those Camarilla Pivots. To see how they fallout.

Here is a Quarterly aggregationperiod added to the script in post #1

Capture.jpg
Ruby:
# Complete Pivot Setup
# Created by @tony_futures
# Inspired from @PostyTrades and @SergeTrades

#declare hide_on_daily;
#Modified to add Quarter aggregationPeriod

input aggregationPeriod = {default DAY, WEEK, MONTH, QUARTER, 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;

#Quarters Defined
def quarter  = (GetMonth() - 1) % 3;
def qtr      = if quarter  == 0 and quarter[1] != 0 then qtr[1] + 1 else qtr[1];
def candles  = !IsNaN(close);
def capture  = candles and qtr != qtr[1];
def qtrCount = CompoundValue(1, if capture then qtrCount[1] + 1 else qtrCount[1], 0);
def thisqtr  = (HighestAll(qtrCount) - qtrCount) ;

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.QUARTER and thisqtr == 0  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);
 
Guys im not fooking around, this is by far one of the best indicators on this whole website. I need someone whos an expert at coding and be able to make a scanner to show when stocks are breaking out over the bear line/ breaking down under the bull line. i cant even count the amount of 100% all the way to 1000% plays ive hit using this someone please help me. Need a scanner to show these breakdowns and breakouts on the 5min chart. Someone who can do it will get paid. One issue im seeing now is since the indicator is set to daily at minimum for pivot points it wont let do anything with under a daily time frame. Im seriosuly not even joking if you want to make thousands a day you guys have the setup just need a scanner since its impossible to manually scan through all the stocks at the moment and you miss winners like UNH today
 
Guys im not fooking around, this is by far one of the best indicators on this whole website. I need someone whos an expert at coding and be able to make a scanner to show when stocks are breaking out over the bear line/ breaking down under the bull line. i cant even count the amount of 100% all the way to 1000% plays ive hit using this someone please help me. Need a scanner to show these breakdowns and breakouts on the 5min chart. Someone who can do it will get paid. One issue im seeing now is since the indicator is set to daily at minimum for pivot points it wont let do anything with under a daily time frame. Im seriosuly not even joking if you want to make thousands a day you guys have the setup just need a scanner since its impossible to manually scan through all the stocks at the moment and you miss winners like UNH today
I have 7+ years in this market, I dont think anyone on this website knows how powerful this can be if its done.
 
I have 7+ years in this market, I dont think anyone on this website knows how powerful this can be if its done.
If i knew advance coding i would for sure make this my life mission but sadly i do not, When you guys have something that pumps outs 100%+ plays a day i think this whole website should come together collectively to get this done. if someone attempts this please dont give up, i will search the whole world to find the top coders to get this done
 
Guys im not fooking around, this is by far one of the best indicators on this whole website. I need someone whos an expert at coding and be able to make a scanner to show when stocks are breaking out over the bear line/ breaking down under the bull line. i cant even count the amount of 100% all the way to 1000% plays ive hit using this someone please help me. Need a scanner to show these breakdowns and breakouts on the 5min chart. Someone who can do it will get paid. One issue im seeing now is since the indicator is set to daily at minimum for pivot points it wont let do anything with under a daily time frame. Im seriosuly not even joking if you want to make thousands a day you guys have the setup just need a scanner since its impossible to manually scan through all the stocks at the moment and you miss winners like UNH today
If i knew advance coding i would for sure make this my life mission but sadly i do not, When you guys have something that pumps outs 100%+ plays a day i think this whole website should come together collectively to get this done. if someone attempts this please dont give up, i will search the whole world to find the top coders to get this done
Do you mean when the 5 minute chart hits the daily levels or do you want the pivots on the 5 minute levels?
 
If i knew advance coding i would for sure make this my life mission but sadly i do not, When you guys have something that pumps outs 100%+ plays a day i think this whole website should come together collectively to get this done. if someone attempts this please dont give up, i will search the whole world to find the top coders to get this done

Okay, I think I get it. Part of the challenge is that literally hundreds of stocks meet that criteria every day. So you will get bombarded with alerts. Maybe we can narrow down the universe of stocks you are interested in somehow...
Anyway, looking at CAT today - the arrow is where you would get the alert, correct?
WOkUQR5.png
 
Last edited by a moderator:
Okay, I think I get it. Part of the challenge is that literally hundreds of stocks meet that criteria every day. So you will get bombarded with alerts. Maybe we can narrow down the universe of stocks you are interested in somehow...
Anyway, looking at CAT today - the arrow is where you would get the alert, correct?
WOkUQR5.png
Correct it would look something like this, and yeah im sure there will be hundreds but as an option trader theres only really a good handful of names people trade daily with options so narrowing it down would be super easy, also i am asking about starting at this becuase im going to take it even further and try to scan options. The option contracts and the normal stock charts have different breakouts. so for example CAT 190 calls where already trying to breakout from open. But that sir is exactly what i would like
 
of course thers fakeouts but i know how to see those for the most part, whats most important is that its making the attempt to breakout and should be watched as a potential runner
 
of course thers fakeouts but i know how to see those for the most part, whats most important is that its making the attempt to breakout and should be watched as a potential runner
Okay, I think we should be able to get something working on this. First things first - I noticed in your images that you don't have the 'Round Level' setup properly to look at charts. The Cam Pivot calculations will round to the nearest dollar in your current setting. You should change that from 0 to 2.
Our approach to solve the limitation with the scanner will be as @bigboss describes above. Storing the daily high/low and close so we do not run afoul of the scanner rules. This 'manual' close will be slightly off from the daily number but from my review of multiple tickers, it is usually only .01 and should not impact the pivots by more than that. As an aside, it is odd that you can build a scan to look for weekly oversold, daily MACD cross and 5 minute breakout but you cannot use a daily aggregation. I digress :)
For our purposes here, we are only looking at solving a 5 minute close above the 'R3'/'Bear Last Stand' level. We can add the bearish equivalent as well. From my experience, Scanner code works best if we strip out the unnecessary plots and variables. I'm going to work through that and test once we hit NY Open. Once that looks good, I will post that code and we will start building our scan.
And if anyone ever has any thoughts/suggestions that they want to ask in private, you can always reach me on Twitter @tony_futures. I will always strive to post the source code back here for interesting studies I build.
 
Last edited:
Okay, I think we should be able to get something working on this. First things first - I noticed in your images that you don't have the 'Round Level' setup properly to look at charts. The Cam Pivot calculations will round to the nearest dollar in your current setting. You should change that from 0 to 2.
Our approach to solve the limitation with the scanner will be as @bigboss describes above. Storing the daily high/low and close so we do not run afoul of the scanner rules. This 'manual' close will be slightly off from the daily number but from my review of multiple tickers, it is usually only .01 and should not impact the pivots by more than that. As an aside, it is odd that you can build a scan to look for weekly oversold, daily MACD cross and 5 minute breakout but you cannot use a daily aggregation. I digress :)
For our purposes here, we are only looking at solving a 5 minute close above the 'R3'/'Bear Last Stand' level. We can add the bearish equivalent as well. From my experience, Scanner code works best if we strip out the unnecessary plots and variables. I'm going to work through that and test once we hit NY Open. Once that looks good, I will post that code and we will start building our scan.
And if anyone ever has any thoughts/suggestions that they want to ask in private, you can always reach me on Twitter @tony_futures. I will always strive to post the source code back here for interesting studies I build.
Okay, things look good. I have 53 tickers showing a 'breakout' so far. Many finance companies, BAC, JPM, WFC and also things like SNOW, VALE and so on. Here is the scan code:
Ruby:
# Pivot Scanner Setup
# Created by @tony_futures

declare hide_on_daily;

input RoundLevel = 2;

#def prevHigh = high(period = aggregationPeriod)[1];
#def prevLow = low(period = aggregationPeriod)[1];
#def prevClose = close(period = aggregationPeriod)[1];

def NYOpen = secondsFromTime(0930) == 0;
def prevLow2 = if NYOpen then low else if low < prevLow2[1] then low else prevLow2[1];
def prevHigh2 = if NYOpen then high else if high > prevHigh2[1] then high else prevHigh2[1];
def prevClose = if NYOpen then close[1] else prevClose[1];
def prevLow = if NYOpen then prevLow2[1] else prevLow[1];
def prevHigh = if NYOpen then prevHigh2[1] else prevHigh[1];

def prevDiff = prevHigh - prevLow;
def prevDiff2 = prevDiff*1.1/2;
#def prevDiff4 = prevDiff*1.1/4;
#def prevDiff8 = prevDiff*1.1/8;

#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);

# Last stand lines - turn off by changing ShowLastStand to no

def bullBreakOut = close > R3 and close [1] < R3;
#def alreadyBreakout = if NYOpen and !bullBreakOut then no else if bullBreakOut then yes else alreadyBreakout[1];
#def firstBreakOut = bullBreakout and !alreadyBreakout[1];
plot bullArrow = if bullBreakOut then low else Double.NaN;
bullArrow.setPaintingStrategy(PaintingStrategy.ARROW_UP);
bullArrow.setDefaultColor(Color.LIGHT_GREEN);

plot bullAlertNow = if bullBreakOut then 1 else 0;
bullAlertNow.setHiding(yes);
If you add this to a chart with the Pivots on it, you will see arrows where we have a 5 minute close above the 'Last Stand' level. There are many commented lines in the code...the last bit of the bottom is my attempt to have each ticker only 'fire' once per day. I'm still looking at that.
What are we doing above - when the session opens, we start tracking the high and low and use yesterday's values to build today's pivots. Basically aggregating at the daily level without using the built-in aggregation. I should note that I am doing this without showing EXT hours for equities. You might have issues if you have them turned on.
 
Okay, things look good. I have 53 tickers showing a 'breakout' so far. Many finance companies, BAC, JPM, WFC and also things like SNOW, VALE and so on. Here is the scan code:
Ruby:
# Pivot Scanner Setup
# Created by @tony_futures

declare hide_on_daily;

input RoundLevel = 2;

#def prevHigh = high(period = aggregationPeriod)[1];
#def prevLow = low(period = aggregationPeriod)[1];
#def prevClose = close(period = aggregationPeriod)[1];

def NYOpen = secondsFromTime(0930) == 0;
def prevLow2 = if NYOpen then low else if low < prevLow2[1] then low else prevLow2[1];
def prevHigh2 = if NYOpen then high else if high > prevHigh2[1] then high else prevHigh2[1];
def prevClose = if NYOpen then close[1] else prevClose[1];
def prevLow = if NYOpen then prevLow2[1] else prevLow[1];
def prevHigh = if NYOpen then prevHigh2[1] else prevHigh[1];

def prevDiff = prevHigh - prevLow;
def prevDiff2 = prevDiff*1.1/2;
#def prevDiff4 = prevDiff*1.1/4;
#def prevDiff8 = prevDiff*1.1/8;

#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);

# Last stand lines - turn off by changing ShowLastStand to no

def bullBreakOut = close > R3 and close [1] < R3;
#def alreadyBreakout = if NYOpen and !bullBreakOut then no else if bullBreakOut then yes else alreadyBreakout[1];
#def firstBreakOut = bullBreakout and !alreadyBreakout[1];
plot bullArrow = if bullBreakOut then low else Double.NaN;
bullArrow.setPaintingStrategy(PaintingStrategy.ARROW_UP);
bullArrow.setDefaultColor(Color.LIGHT_GREEN);

plot bullAlertNow = if bullBreakOut then 1 else 0;
bullAlertNow.setHiding(yes);
If you add this to a chart with the Pivots on it, you will see arrows where we have a 5 minute close above the 'Last Stand' level. There are many commented lines in the code...the last bit of the bottom is my attempt to have each ticker only 'fire' once per day. I'm still looking at that.
What are we doing above - when the session opens, we start tracking the high and low and use yesterday's values to build today's pivots. Basically aggregating at the daily level without using the built-in aggregation. I should note that I am doing this without showing EXT hours for equities. You might have issues if you have them turned on.
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.
 
Okay, I think we should be able to get something working on this. First things first - I noticed in your images that you don't have the 'Round Level' setup properly to look at charts. The Cam Pivot calculations will round to the nearest dollar in your current setting. You should change that from 0 to 2.
Our approach to solve the limitation with the scanner will be as @bigboss describes above. Storing the daily high/low and close so we do not run afoul of the scanner rules. This 'manual' close will be slightly off from the daily number but from my review of multiple tickers, it is usually only .01 and should not impact the pivots by more than that. As an aside, it is odd that you can build a scan to look for weekly oversold, daily MACD cross and 5 minute breakout but you cannot use a daily aggregation. I digress :)
For our purposes here, we are only looking at solving a 5 minute close above the 'R3'/'Bear Last Stand' level. We can add the bearish equivalent as well. From my experience, Scanner code works best if we strip out the unnecessary plots and variables. I'm going to work through that and test once we hit NY Open. Once that looks good, I will post that code and we will start building our scan.
And if anyone ever has any thoughts/suggestions that they want to ask in private, you can always reach me on Twitter @tony_futures. I will always strive to post the source code back here for interesting studies I build.
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.
 
Okay, things look good. I have 53 tickers showing a 'breakout' so far. Many finance companies, BAC, JPM, WFC and also things like SNOW, VALE and so on. Here is the scan code:
Ruby:
# Pivot Scanner Setup
# Created by @tony_futures

declare hide_on_daily;

input RoundLevel = 2;

#def prevHigh = high(period = aggregationPeriod)[1];
#def prevLow = low(period = aggregationPeriod)[1];
#def prevClose = close(period = aggregationPeriod)[1];

def NYOpen = secondsFromTime(0930) == 0;
def prevLow2 = if NYOpen then low else if low < prevLow2[1] then low else prevLow2[1];
def prevHigh2 = if NYOpen then high else if high > prevHigh2[1] then high else prevHigh2[1];
def prevClose = if NYOpen then close[1] else prevClose[1];
def prevLow = if NYOpen then prevLow2[1] else prevLow[1];
def prevHigh = if NYOpen then prevHigh2[1] else prevHigh[1];

def prevDiff = prevHigh - prevLow;
def prevDiff2 = prevDiff*1.1/2;
#def prevDiff4 = prevDiff*1.1/4;
#def prevDiff8 = prevDiff*1.1/8;

#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);

# Last stand lines - turn off by changing ShowLastStand to no

def bullBreakOut = close > R3 and close [1] < R3;
#def alreadyBreakout = if NYOpen and !bullBreakOut then no else if bullBreakOut then yes else alreadyBreakout[1];
#def firstBreakOut = bullBreakout and !alreadyBreakout[1];
plot bullArrow = if bullBreakOut then low else Double.NaN;
bullArrow.setPaintingStrategy(PaintingStrategy.ARROW_UP);
bullArrow.setDefaultColor(Color.LIGHT_GREEN);

plot bullAlertNow = if bullBreakOut then 1 else 0;
bullAlertNow.setHiding(yes);
If you add this to a chart with the Pivots on it, you will see arrows where we have a 5 minute close above the 'Last Stand' level. There are many commented lines in the code...the last bit of the bottom is my attempt to have each ticker only 'fire' once per day. I'm still looking at that.
What are we doing above - when the session opens, we start tracking the high and low and use yesterday's values to build today's pivots. Basically aggregating at the daily level without using the built-in aggregation. I should note that I am doing this without showing EXT hours for equities. You might have issues if you have them turned on.
Holy smokes you are fast. Im going to mess around with this some today and start to incoroprate it into charting the option contracts its self now which will be the ultimate bread and butter to what ive wanted to do with this ill keep you updated
 
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.
Okay
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.
What would be the difference between bull alert and bull alert now
 
Okay

What would be the difference between bull alert and bull alert now
Bull Alert Now is the one for the scan. Bull Arrow is the other one and it will visually show on the chart when the close above the pivot happened. I was mostly just using it for troubleshooting/verification things were working properly.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
421 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