Day Trading with Pivots For ThinkOrSwim

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:
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...

View attachment 15010
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.
Can you tweak this to be able to show when price close crosses the bull or bear last stand line without errors on the lower timeframes?

This will scan. @FutureTony can you add quarterly and yearly aggregation to the posty pivots please.

Ruby:
# Posty Reversal Zone scan by bigboss
# SAVE STUDY AS POSTY_REVERSAL_ZONE_SCAN
# THEN CREATE A SCAN with the following:
# Posty_Reversal_Zone_Scan("period" = "DAY")."inside_bull_reversal_zone" is true
# or
# Posty_Reversal_Zone_Scan("period" = "DAY")."inside_bear_reversal_zone" is true
#
# On the Scanner, you can use any aggregation above DAY. Just make sure what's in the scan criteria matches the aggregation period at the top of the scanner.

input period = aggregationperiod.DAY;

def price = close(period = period)[1];
def range = high(period = period)[1] - low(period = period)[1];

def lb = price + range*1.1/2;
def sb = price - range*1.1/2;
def gl = price - range*1.1/4;
def gs = price + range*1.1/4;

plot inside_bear_reversal_zone = if close > gs and close < (lb+gs)/2 then 1 else 0;
plot inside_bull_reversal_zone = if close < gl and close > (sb+gl)/2 then 1 else 0;
@bigboss can reversal zone be taken away and instead show bull and bear last stand? Trying to show price close by crossing either bull or bear last stand levels on the scan
 
Last edited by a moderator:
Hi BottomDollar, the adds I made were; adding S1/R1 and S2/R2 from Cam Points Daily; Adding bull3 and bear3 targets, and the option for prior day pivots..possibly a bubble here or there like Previous Hi/Lo.
I use most of these (lately have removed s1-2, and r1-2 as the Mobius Fib Pivots are better) set to daily on the 7K tick MNQ and set to weekly on a 40 Min chart also MNQ.

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

#declare hide_on_daily;



DefineGlobalColor("MyBlue", CreateColor(0, 54, 191)); #GlobalColor("MyBlue")
DefineGlobalColor("MyYellow", CreateColor(255, 246, 67)); #GlobalColor("MyYellow")
DefineGlobalColor("MyGreen", CreateColor(0, 102, 51)); #GlobalColor("MyGreen")
DefineGlobalColor("MyLightGreen", CreateColor(0, 248, 171)); #GlobalColor("MyLightGreen")
DefineGlobalColor("MyBTDGreen", CreateColor(153, 255, 153)); #GlobalColor("MyBTDGreen")
DefineGlobalColor("MyLBlue", CreateColor(51, 204, 255)); #GlobalColor("MyLBlue")
DefineGlobalColor("MyLBlue2", CreateColor(51, 255, 255)); #GlobalColor("MyLBlue2")
DefineGlobalColor("MyDeepBlue", CreateColor(0, 0, 102)); #GlobalColor("MyDeepBlue")
DefineGlobalColor("MyRed", CreateColor(153, 0, 0)); #GlobalColor("MyRed")
DefineGlobalColor("MyOrange", CreateColor(255, 102, 0)); #GlobalColor("MyOrange")
DefineGlobalColor("MyRed2", createcolor(102,0,102)); #GlobalColor("MyRed2")
DefineGlobalColor("MyRed3", createcolor(204,0,102)); #GlobalColor("MyRed3")
DefineGlobalColor("MyPurple", createcolor(153,0,204)); #GlobalColor("MyPurple")
DefineGlobalColor("MyR2Pink", createcolor(255,88,145)); #GlobalColor("MyR2Pink")
DefineGlobalColor("MyS2Green", createcolor(0,102,102)); #GlobalColor("MyS2Green")
DefineGlobalColor("MyPreviousHL", createcolor(51,153,255)); #GlobalColor("MyPreviousHL")


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;
input SwingLength = 12;  #default is 12
input showBubblesLeft = yes;
input showBubblesRight = No;
input showPreviousBubblesRight = YES;
input displaceRightBubble = 3;

def showBubbleNow = !IsNaN(close) and IsNaN(close[-1]);
def showPreviousBubblesNow = !IsNaN(close) and IsNaN(close[-1]);

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

#####################
#taken from Cam Points DailyAgg
#LL
#S1/R1
#S2/R2
####################

#input CPP_aggregationPeriod = AggregationPeriod.DAY;

#def CPP_PH = high(period = CPP_aggregationPeriod)[1];
#def CPP_PL = low(period = CPP_aggregationPeriod)[1];
#def CPP_PC = close(period = CPP_aggregationPeriod)[1];

input showCPP = yes;
def CPP_R2 = prevClose1 + (prevHigh – prevLow) * 1.1 / 6;
def CPP_S2 = prevClose1 - (prevHigh – prevLow)* 1.1 / 6;
plot CPP_R2Line = if showCPP and showTodayOnly and Today then CPP_R2 else if showCPP and !showTodayOnly then CPP_R2 else Double.NaN;
plot CPP_S2Line  = if showCPP and showTodayOnly and Today then CPP_S2 else if showCPP and !showTodayOnly then CPP_S2 else Double.NaN;
CPP_R2Line.SetDefaultColor(GlobalColor("MyR2Pink"));
CPP_S2Line.SetDefaultColor(GlobalColor("MyS2Green"));
#CPP_R2Line.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
CPP_R2Line.SetStyle(Curve.LONG_DASH);
CPP_S2Line.SetStyle(Curve.LONG_DASH);
CPP_R2Line.setlineWeight(2);
CPP_S2Line.setlineWeight(2);
CPP_R2Line.hidebubble();
CPP_S2Line.hidebubble();

#######################
# End TAKEN from Cam points Daily
######################

def pivot = (prevHigh + prevLow + prevClose) / 3; #default 3.0
def bc = (prevHigh + prevLow) / 2; #default 2
def tc = (pivot - bc) + pivot;
def prevDiff = prevHigh - prevLow;
def prevDiff2 = prevDiff*1.1/2; #original is 1.1/2
def prevDiff4 = prevDiff*1.1/4; #original is 1.1/4
def prevDiff8 = prevDiff*1.1/8; #original is 1.1/8
#def prevDiff16 = prevDiff*1.1/16;

def smallR1 = prevClose + (prevDiff*1.12/ SwingLength); #default is 12
def smallS1 = prevClose - (prevDiff*1.12/ SwingLength);  #default is 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 R6 = RoundDown((R4 + (.28 * (R4 - R2))),RoundLevel);

def S1 = PrevClose - prevDiff4;
#def S1 = PrevClose - (prevHigh – prevLow)* 1.1 / 12;
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);
def S6 = RoundUp((S4 - (.28 * ( S2 - S4))), RoundLevel);

#######################
#Central Pivot Range - turn off by changing showCPR to no
#######################



input showPivotMiddle = yes;
plot PLine = if showCPR and showTodayOnly and Today and showPivotMiddle 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(GlobalColor("MyPurple"));
BCLine.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
BCLine.SetDefaultColor(Color.MAGENTA);
TCLine.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
TCLine.SetDefaultColor(Color.MAGENTA);

PLine.setlineWeight(3);
BCLine.setlineWeight(3);
TCLine.setlineWeight(3);

PLine.hidebubble();
BCLine.hidebubble();
TCLine.hidebubble();

PLine.hidetitle();
BCLine.hidetitle();
TCLine.hidetitle();

Input showPriorDayPivotLines = no;
plot BCLinePriorDay =  if  showPriorDayPivotLines then bc else if showCPR and !showTodayOnly then bc else Double.NaN;
BCLinePriorDay.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
BCLinePriorDay.SetDefaultColor(Color.MAGENTA);
BCLinePriorDay .setlineWeight(3);

plot PivotLinePriorDay =  if showPriorDayPivotLines and showPivotMiddle then pivot else if showCPR and !showTodayOnly then pivot else Double.NaN;
PivotLinePriorDay.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
PivotLinePriorDay.SetDefaultColor(GlobalColor("MyPurple"));
PivotLinePriorDay .setlineWeight(3);

plot TCLinePriorDay = if  showPriorDayPivotLines then tc else if showCPR and !showTodayOnly then tc else Double.NaN;;
TCLinePriorDay.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
TCLinePriorDay.SetDefaultColor(Color.MAGENTA);
TCLinePriorDay .setlineWeight(3);

# 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(GlobalColor("MyPreviousHL"));
PreviousHigh.SetLineWeight(4);

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(GlobalColor("MyPreviousHL"));
PreviousLow.SetLineWeight(4);


#######################
# Reversal zones - turn off by changing showReversalZone to no
# R1 and R2  BLUE CLOUD
# R1 and R2 lines
# R1 and R2 Bubbles
#######################

input ShowReversalCloud = no;
AddCloud(if showReversalZone and showTodayOnly and Today and ShowReversalCloud then r1 else if showReversalZone and !showTodayOnly then r1 else Double.NaN, r2, GlobalColor("MyRed"), GlobalColor("MyRed"));

plot R1Line = if showReversalZone and showTodayOnly and Today then R1 else if showReversalZone and !showTodayOnly then r1 else Double.NaN;
R1Line.setDefaultColor(GlobalColor("MyRed"));
R1Line.SetStyle(Curve.LONG_DASH);
R1Line.setlineWeight(2);

plot R2Line = if showReversalZone and showTodayOnly and Today then R2 else if showReversalZone and !showTodayOnly then r2 else Double.NaN;
R2Line.setDefaultColor(GlobalColor("MyRed"));
R2Line.SetStyle(Curve.LONG_DASH);
R2Line.setlineWeight(2);


AddCloud(if showReversalZone and showTodayOnly and Today and ShowReversalCloud then s1 else if showReversalZone and !showTodayOnly then s1 else Double.NaN, s2, GlobalColor("MyBlue"), GlobalColor("MyBlue"));


AddChartBubble(showBubblesRight and showLastStand and showBubbleNow[displaceRightBubble], R1, "R1: " + R1, Color.white, yes);
AddChartBubble(showBubblesRight and showLastStand and showBubbleNow[displaceRightBubble], R2, "R2: " + R2, Color.white, yes);

plot S1Line = if showReversalZone and showTodayOnly and Today then S1 else if showReversalZone and !showTodayOnly then S1 else Double.NaN;
S1Line.setDefaultColor(GlobalColor("MyBlue"));
s1Line.SetStyle(Curve.LONG_DASH);
S1Line.setlineWeight(2);

plot S2Line = if showReversalZone and showTodayOnly and Today then S2 else if showReversalZone and !showTodayOnly then S2 else Double.NaN;
S2Line.setDefaultColor(GlobalColor("MyBlue"));
S2Line.SetStyle(Curve.LONG_DASH);
S2Line.setlineWeight(2);

AddChartBubble(showBubblesRight and showLastStand and showBubbleNow[displaceRightBubble], S1, "S1: " + S1, Color.white, yes);
AddChartBubble(showBubblesRight and showLastStand and showBubbleNow[displaceRightBubble], S2, "S2: " + S2, Color.white, yes);


#AddLabel(showReversalZone and showLabels, "Bear zone: " + RoundDown(R1, RoundLevel) + " to " + RoundDown(R2, RoundLevel), GlobalColor("MyRed2"));
#AddLabel(showReversalZone and showLabels, "Bull zone: " + RoundDown(S1, RoundLevel) + " to " + RoundDown(S2, RoundLevel), GlobalColor("MyRed2"));


#######################
# 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(GlobalColor("MyGreen"));
bullLastStand.setlineWeight(3);

plot bearLastStand = if showLastStand and showTodayOnly and Today then R3 else if showLastStand and !showTodayOnly then R3 else Double.NaN;
bearLastStand.setDefaultColor(GlobalColor("MyRed"));
bearLastStand.setlineWeight(3);


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

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

### Bull / Bear TARGET ONE  ####



plot bull1 = if showBullTargets and showTodayOnly and Today then R5 else if showBullTargets and !showTodayOnly then R5 else Double.NaN;
bull1.setDefaultColor(GlobalColor("MyRed3"));
plot bear1 = if showBearTargets  and showTodayOnly and Today then S5 else if showBearTargets and !showTodayOnly then S5 else Double.NaN;
bear1.setDefaultColor(GlobalColor("MyBTDGreen"));
AddChartBubble(showBubblesLeft and showBullTargets and Today and !Today[1], R5, "Bull Target 1: " + R5, GlobalColor("MyRed3"), yes);
AddChartBubble(showBubblesLeft and showBearTargets and Today and !Today[1], S5, "Bear Target 1: " + S5, GlobalColor("MyBTDGreen"), no);
bull1.setlineWeight(4);
bear1.setlineWeight(4);

### Bull / Bear TARGET TWO  ####

plot bull2 = if showBullTargets  and showTodayOnly and Today then R4 else if showBullTargets and !showTodayOnly then R4 else Double.NaN;
bull2.setDefaultColor(GlobalColor("MyRed3"));
plot bear2 = if showBearTargets  and showTodayOnly and Today then S4 else if showBearTargets and !showTodayOnly then S4 else Double.NaN;
bear2.setDefaultColor(GlobalColor("MyBTDGreen"));
AddChartBubble(showBubblesLeft and showBullTargets and Today and !Today[1], R4, "Bull Target 2: " + R4, GlobalColor("MyRed3"), yes);
AddChartBubble(showBubblesLeft and showBearTargets and Today and !Today[1], S4, "Bear Target 2: " + S4, GlobalColor("MyBTDGreen"), no);
bull2.setlineWeight(4);
bear2.setlineWeight(4);

### Bull / Bear TARGET THREE  ####


plot bull3 = if showBullTargets  and showTodayOnly and Today then R6 else if showBullTargets and !showTodayOnly then R6 else Double.NaN;
bull3.setDefaultColor(GlobalColor("MyRed3"));
plot bear3 = if showBullTargets  and showTodayOnly and Today then S6 else if showBullTargets and !showTodayOnly then S6 else Double.NaN;
bear3.setDefaultColor(GlobalColor("MyBTDGreen"));
AddChartBubble(showBubblesLeft and showBullTargets and Today and !Today[1], R6, "Bull Target 3: " + R6, GlobalColor("MyRed3"), yes);
AddChartBubble(showBubblesLeft and showBearTargets and Today and !Today[1], S6, "BEAR Target 3: " + S6, GlobalColor("MyBTDGreen"), no);
bull3.setlineWeight(4);
bear3.setlineWeight(4);




input showOpen = yes;

AddVerticalLine( Today and !Today[1] and showOpen, concat("Today BEGIN", ""), Color.blue, curve.short_dash);

AddChartBubble(showBubblesRight and showLastStand and showBubbleNow[displaceRightBubble], R3, "Bear Last Stand: " + R3, Color.white, yes);
AddChartBubble(showBubblesRight and showLastStand and showBubbleNow[displaceRightBubble], S3, "Bull Last Stand: " + S3, Color.white, no);

input showPreviousBubbles = yes;

AddChartBubble(showPreviousBubblesRight and showPrevious and showPreviousBubbles and showPreviousBubblesNow[displaceRightBubble], PreviousHigh, "Previous High: " + RoundDown(previousHigh,RoundLevel), GlobalColor("MyPreviousHL"), yes);
AddChartBubble(showPreviousBubblesRight and showPrevious and showPreviousBubbles and showPreviousBubblesNow[displaceRightBubble], PreviousLow, "Previous Low: " + PreviousLow, GlobalColor("MyPreviousHL"), no);

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

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

AddChartBubble(showBubblesRight and showBullTargets and showBubbleNow[displaceRightBubble], R6, "Bull Target 3: " + R6, Color.white, yes);
AddChartBubble(showBubblesRight and showBearTargets and showBubbleNow[displaceRightBubble], S6, "Bear Target 3: " + S6, Color.white, 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 = yes;
input showSmallCamPointsBubbles = no;
plot smallCamResistance = if showSmallCamPoints and Today then smallR1 else Double.NaN;
smallCamResistance.setDefaultColor(GlobalColor("MyYellow"));
AddChartBubble(showSmallCamPointsBubbles and Today and !Today[1], smallR1, "small Cam R ZONE: " + smallR1, Color.white, no);
smallCamResistance.setlineWeight(3);


plot smallCamSupport = if showSmallCamPoints and Today then smallS1 else Double.NAN;
smallCamSupport.setDefaultColor(GlobalColor("MyBTDGreen"));
AddChartBubble(showSmallCamPointsBubbles and Today and !Today[1], smallS1, "small Cam S ZONE: " + smallS1, Color.white, no);
smallCamSupport.setlineWeight(3);

input showSCPCloud = no;
addcloud(if showSmallCamPoints and showSCPCloud and TOday then smallCamResistance else double.nan, smallCamSupport,GlobalColor("MyOrange"),GlobalColor("MyOrange"), no);
@GoldStriple When I enable bubbles on right, the right side bubbles are showing different targets. Can you Check why?

 

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
430 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