Day Trading with Pivots For ThinkOrSwim

Posting a new version of this today. I've updated the code on page 1 of this thread. The new version cleans up a few things, provides support for yearly timeframes and also adds the traditional Camarilla S1/R1 that occur between the bear and bull zones (best for days when we have subdued movement).
 
Very nice script @FutureTony, great work.

This pivot is very close to one I've seen sold elsewhere. You might want to consider placing some kind of open source license in the header to keep people from claiming it as there work and then selling it. Everyone who writes scripts should consider an open source license program to protect their work. There are folks who lurk here who will "borrow" your ideas to make a buck.
 
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’d like to use this code for Camarilla but edit the code to include “Premarket” price movement in its calculation. Generally, Camarilla Pivots do not include Premarket data. However, I find this additional info very useful and on my last platform it was built in that way. Do you perhaps know what text I can add to the code and where, to enable this?

Thanks
 
These pivots are based on the previous day's close. They don't exclude any pre-market data but it sounds like you are looking for something on a shorter timeframe. You could base them on hourly or 4hr prices as you wish. I might start with the default Camarilla Pivots in TOS and change the aggregation period. OR...you could search in this community, I'm guessing there are other hourly pivot-type studies that people have already created.
 
These pivots are based on the previous day's close. They don't exclude any pre-market data but it sounds like you are looking for something on a shorter timeframe. You could base them on hourly or 4hr prices as you wish. I might start with the default Camarilla Pivots in TOS and change the aggregation period. OR...you could search in this community, I'm guessing there are other hourly pivot-type studies that people have already created.
@FutureTony thanks for providing the code for this study. I want to follow up on the pre-market data question. When using the study with stock intraday charts, the levels would be different and more accurate when including the premarket and post-market data (I am comparing with DAS camarilla levels). So I am just wondering is that something you can add to the code to include pre-market and post-market data in calculating the camarilla levels for intraday charts? This would be so much helpful.
 
Nicest pivot point study I've been able to come across SO FAR. I'm having a hard time figuring out why there's 50 scripts out there for a seemingly simple thing. Most of them don't even work.

Possibly to simplify things, base the pivots on the high low of post-pre market/1 day/1 week/1 month? Also name the labels exactly what they are.

Thanks
 
Last edited:
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);
 
A fun addition to Tony Futures code: a cloud just above and below bull / bear last stands:

Code:
Def S3Cloud = RoundDown((S3 + (.3 * (S2 - S3))),RoundLevel);
Def R3Cloud = RoundDown((R3 + (.3 * (R2 - R3))),RoundLevel);

input ShowBullLastStandCloud = yes;
input ShowBearLastStandCloud = yes;

AddCloud(if ShowBullLastStandCloud and showTodayOnly and Today then S3 else if ShowBullLastStandCloud and !showTodayOnly then S3 else Double.NaN, S3Cloud, Color.LIGHT_GREEN, Color.LIGHT_GREEN));
AddCloud(if ShowBearLastStandCloud and showTodayOnly and Today then R3 else if ShowBearLastStandCloud and !showTodayOnly then R3 else Double.NaN, R3Cloud, Color.DARK_ORANGE, Color.DARK_ORANGE);
 
Is there anyone here who can make a scan for price going above or below the Bear/Bull last stand thats where all the money is to be made using this indcator, have had multiple 100%+ waiting for that level to break would be great to scan for it though, Maybe @bigboss you can help since you attempted a scan on this before
 
It should be straightforward to scan for that.
Igflr9f.png

Choose the timeframe you are interested in and then add the criteria for high crossing above the bear line or below the bull line. Be sure that the timeframe selected in the scan matches the timeframe in the study.
 
It should be straightforward to scan for that.
Igflr9f.png

Choose the timeframe you are interested in and then add the criteria for high crossing above the bear line or below the bull line. Be sure that the timeframe selected in the scan matches the timeframe in the study.
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.
 

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