Prior Day High, Low, Halfback with RTH anchor: globex market profile For ThinkOrSwim

chiropteraphile

New member
Plots prior day high (green), low (red), and halfback (dark orange), anchored to globex RTH hours, for futures.

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

WJTrmYW.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;

plot PriorDayHigh = priorRTHhigh;
PriorDayHigh.SetDefaultColor(Color.Green);
PriorDayHigh.SetPaintingStrategy(PaintingStrategy.Line);
PriorDayHigh.SetStyle(Curve.FIRM);
PriorDayHigh.SetLineWeight(2);
PriorDayHigh.HideBubble();
PriorDayHigh.HideTitle();

plot Halfback = sumHighLow / 2;
Halfback.SetDefaultColor(Color.Dark_Orange);
Halfback.SetPaintingStrategy(PaintingStrategy.Line);
Halfback.SetStyle(Curve.Firm);
Halfback.SetLineWeight(2);
Halfback.HideBubble();
Halfback.HideTitle();

plot PriorDayLow = priorRTHlow;
PriorDayLow.SetDefaultColor(Color.Red);
PriorDayLow.SetPaintingStrategy(PaintingStrategy.Line);
PriorDayLow.SetStyle(Curve.FIRM);
PriorDayLow.SetLineWeight(2);
PriorDayLow.HideBubble();
PriorDayLow.HideTitle();
#
 
This script appears to be lacking an "input" at the beginning and thus isn't populating when the script is copied and placed into TOS. I'm no good at this so I have no idea how to rectify it.
 
This script appears to be lacking an "input" at the beginning and thus isn't populating when the script is copied and placed into TOS. I'm no good at this so I have no idea how to rectify it.
Not sure how to help :(
If your question is: "Does this script plot on the chart?"
The answer is: "Yes".

Here is what it looked like on this morning's chart:
G4sBxMH.png
 

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