Daily Pivot, Support, and Resistance, with RTH anchor: globex market profile For ThinkOrSwim

chiropteraphile

New member
Plots eight daily support (red), resistance (green), and pivot lines (17 lines total), anchored to prior day globex RTH, for futures.

Chart timeframe should be XD:XM or similar (not Today:XM).


PGoTigm.png



#
def na = Double.NaN;
def bn = BarNumber();
def h = high;
def l = low;

script prior {
input prior = close;
def priorOf = if prior != prior[1] then prior[1] else priorOf[1];
plot priorBar = priorOf;
}

def cb = HighestAll(if !IsNaN(h) then bn else na);
def time = GetTime();
def rts = RegularTradingStart(GetYYYYMMDD());
def rte = RegularTradingEnd(GetYYYYMMDD());
def RTH = if time crosses above rts
then bn else RTH[1];
def globex = if time crosses below rte
then bn else globex[1];

def priorRTH = prior(RTH);
def priorGlobex = prior(globex);
def hRTH = HighestAll(RTH);
def hGX = HighestAll(globex);
def hPRTH = HighestAll(priorRTH);
def hPGX = HighestAll(priorGlobex);

def gXhigh = HighestAll(if bn >= hGX && bn < hRTH
then h else if hRTH < hGX && bn >= hGX
then h else na);
def gXlow = LowestAll(if bn >= hGX && bn < hRTH
then l else if hRTH < hGX && bn >= hGX
then l else na);
def RTHhigh = HighestAll(if bn >= hRTH && bn < hGX
then h else if hGX < hRTH && bn >= hRTH
then h else na);
def RTHlow = LowestAll(if bn >= hRTH && bn < hGX
then l else if hGX < hRTH && bn >= hRTH
then l else na);

def priorRTHhigh = HighestAll(if bn >= hPRTH
&& bn < if hGX < hRTH then hGX
else hPGX then h else na);
def priorRTHlow = LowestAll(if bn >= hPRTH
&& bn < if hGX < hRTH then hGX
else hPGX then l else na);

def RTHrange = priorRTHhigh - priorRTHlow;
def sumHighLow = priorRTHhigh + priorRTHlow;

# OPEN VALUE
input opentime = {default Manual, Globex, Midnight, RTHstart};
input endtime = {default Manual, Globex, Midnight, RTHend};
input openTimeClock = 0930;
def globextime = GetYYYYMMDD() != GetYYYYMMDD()[1];
def midnighttime = SecondsFromTime(0000) == 0;
def RTHstarttime = GetTime() crosses above RegularTradingStart(GetYYYYMMDD());
def RTHendtime = (1615);
def openValue;

switch (opentime) {
case Manual:
openValue = if SecondsFromTime(openTimeClock) == 0 then open else openValue[1];
case Globex:
openValue = if globextime then open else openValue[1];
case Midnight:
openValue = if midnighttime then open else openValue[1];
case RTHstart:
openValue = if RTHstarttime then open else openValue[1];
}


# SETTLMENT VALUE
input settlementTime = {default Manual, PreMarketend, RTHend, EXTend};
input settlementTimeClock = 1615;
def PreMarketend = gettime() crosses above regularTradingStart(getyyyYMMDD());
def RTHend = secondsfromtime(1615) == 0;
def EXTend = GetTime() crosses above RegularTradingEnd(GetYYYYMMDD());
def settlementValue;
switch (settlementTime) {
case Manual:
settlementValue = if SecondsFromTime(settlementTimeClock) == 0 then close else settlementValue[1];
case PreMarketend:
settlementValue = if PreMarketend then close[1] else settlementValue[1];
case RTHend:
settlementValue = if RTHend then close else settlementValue[1];
case EXTend:
settlementValue = if EXTend then close else settlementValue[1];
}

plot Pivot = (priorRTHhigh + priorRTHlow + settlementValue) / 3;
Pivot.SetDefaultColor(Color.Violet);
Pivot.SetStyle(Curve.Firm);
Pivot.SetLineWeight(1);
Pivot.HideBubble();
Pivot.HideTitle();

plot R1 = (2 * Pivot) - priorRTHlow;
R1.SetDefaultColor(Color.Dark_Green);
R1.SetStyle(Curve.Firm);
R1.SetLineWeight(1);
R1.HideBubble();
R1.HideTitle();

plot S1 = (2 * Pivot) - priorRTHhigh;
S1.SetDefaultColor(Color.Dark_Red);
S1.SetStyle(Curve.Firm);
S1.SetLineWeight(1);
S1.HideBubble();
S1.HideTitle();

plot R2 = Pivot + (R1 - S1);
R2.SetDefaultColor(Color.Dark_Green);
R2.SetStyle(Curve.Firm);
R2.SetLineWeight(1);
R2.HideBubble();
R2.HideTitle();

plot S2 = Pivot - (R1 - S1);
S2.SetDefaultColor(Color.Dark_Red);
S2.SetStyle(Curve.Firm);
S2.SetLineWeight(1);
S2.HideBubble();
S2.HideTitle();

plot S3 = priorRTHlow - 2 * (priorRTHhigh - Pivot);
S3.SetDefaultColor(Color.Dark_Red);
S3.SetStyle(Curve.Firm);
S3.SetLineWeight(1);
S3.HideBubble();
S3.HideTitle();

plot R3 = priorRTHhigh + 2 * (Pivot - priorRTHlow);
R3.SetDefaultColor(Color.Dark_Green);
R3.SetStyle(Curve.Firm);
R3.SetLineWeight(1);
R3.HideBubble();
R3.HideTitle();

plot S4 = priorRTHlow - 3 * (priorRTHhigh - Pivot);
S4.SetDefaultColor(Color.Dark_Red);
S4.SetStyle(Curve.Firm);
S4.SetLineWeight(1);
S4.HideBubble();
S4.HideTitle();

plot R4 = priorRTHhigh + 3 * (Pivot - priorRTHlow);
R4.SetDefaultColor(Color.Dark_Green);
R4.SetStyle(Curve.Firm);
R4.SetLineWeight(1);
R4.HideBubble();
R4.HideTitle();

plot S5 = priorRTHlow - 4 * (priorRTHhigh - Pivot);
S5.SetDefaultColor(Color.Dark_Red);
S5.SetStyle(Curve.Firm);
S5.SetLineWeight(1);
S5.HideBubble();
S5.HideTitle();

plot R5 = priorRTHhigh + 4 * (Pivot - priorRTHlow);
R5.SetDefaultColor(Color.Dark_Green);
R5.SetStyle(Curve.Firm);
R5.SetLineWeight(1);
R5.HideBubble();
R5.HideTitle();

plot S6 = priorRTHlow - 5 * (priorRTHhigh - Pivot);
S6.SetDefaultColor(Color.Dark_Red);
S6.SetStyle(Curve.Firm);
S6.SetLineWeight(1);
S6.HideBubble();
S6.HideTitle();

plot R6 = priorRTHhigh + 5 * (Pivot - priorRTHlow);
R6.SetDefaultColor(Color.Dark_Green);
R6.SetStyle(Curve.Firm);
R6.SetLineWeight(1);
R6.HideBubble();
R6.HideTitle();

plot S7 = priorRTHlow - 6 * (priorRTHhigh - Pivot);
S7.SetDefaultColor(Color.Dark_Red);
S7.SetStyle(Curve.Firm);
S7.SetLineWeight(1);
S7.HideBubble();
S7.HideTitle();

plot R7 = priorRTHhigh + 6 * (Pivot - priorRTHlow);
R7.SetDefaultColor(Color.Dark_Green);
R7.SetStyle(Curve.Firm);
R7.SetLineWeight(1);
R7.HideBubble();
R7.HideTitle();

plot S8 = priorRTHlow - 7 * (priorRTHhigh - Pivot);
S8.SetDefaultColor(Color.Dark_Red);
S8.SetStyle(Curve.Firm);
S8.SetLineWeight(1);
S8.HideBubble();
S8.HideTitle();

plot R8 = priorRTHhigh + 7 * (Pivot - priorRTHlow);
R8.SetDefaultColor(Color.Dark_Green);
R8.SetStyle(Curve.Firm);
R8.SetLineWeight(1);
R8.HideBubble();
R8.HideTitle();
#
 
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
297 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