Previous Day High/Low/Close + Premarket High/Low + High/Low/Open of Day + ATR Lines for ThinkorSwim

Thanks! But was really hoping to get previous weeks high and low added. Would be the final piece of levels that I would need daily. Thanks!
Code:
input ShowThisWeekOnly = yes;

def CurrentWeek = GetWeek() == GetLastWeek();
def PrevWeekHigh = high(period = "week")[1];
def PrevWeekLow = low(period = "week")[1];
def PrevWeekClose = close(period = "week")[1];

# Conditional plotting for current week only
plot Whigh = if ShowThisWeekOnly and !CurrentWeek then Double.NaN else PrevWeekHigh;
plot Wlow = if ShowThisWeekOnly and !CurrentWeek then Double.NaN else PrevWeekLow;
plot Wmean = if ShowThisWeekOnly and !CurrentWeek then Double.NaN else (PrevWeekHigh + PrevWeekLow + PrevWeekClose) / 3;

Whigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Whigh.SetDefaultColor(Color.UPTICK);
Whigh.SetLineWeight(2);

Wlow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Wlow.SetDefaultColor(Color.DOWNTICK);
Wlow.SetLineWeight(2);

Wmean.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Wmean.SetDefaultColor(Color.YELLOW);
Wmean.SetLineWeight(2);

# Optional: price color changes relative to previous week levels
AssignPriceColor(
    if close >= Whigh then Color.GREEN
    else if close <= Wlow then Color.RED
    else Color.CURRENT
);
 
Last edited by a moderator:
Code:
input ShowThisWeekOnly = yes;

def CurrentWeek = GetWeek() == GetLastWeek();
def PrevWeekHigh = high(period = "week")[1];
def PrevWeekLow = low(period = "week")[1];
def PrevWeekClose = close(period = "week")[1];

# Conditional plotting for current week only
plot Whigh = if ShowThisWeekOnly and !CurrentWeek then Double.NaN else PrevWeekHigh;
plot Wlow = if ShowThisWeekOnly and !CurrentWeek then Double.NaN else PrevWeekLow;
plot Wmean = if ShowThisWeekOnly and !CurrentWeek then Double.NaN else (PrevWeekHigh + PrevWeekLow + PrevWeekClose) / 3;

Whigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Whigh.SetDefaultColor(Color.UPTICK);
Whigh.SetLineWeight(2);

Wlow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Wlow.SetDefaultColor(Color.DOWNTICK);
Wlow.SetLineWeight(2);

Wmean.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Wmean.SetDefaultColor(Color.YELLOW);
Wmean.SetLineWeight(2);

# Optional: price color changes relative to previous week levels
AssignPriceColor(
    if close >= Whigh then Color.GREEN
    else if close <= Wlow then Color.RED
    else Color.CURRENT
);

You rock!!!
 
Last edited by a moderator:
I would also appreciate if someone has a suggestion on getting PM_high and PM_Low working on more then just the current day. Disabling "Show only last period" option doesn't seem to work.



plot PM_High;
plot PM_Low;
if showOnlyLastPeriod and !IsNaN(close(period = aggregationPeriod)[-1]) {
PM_High = na;
PM_Low = na;
} else {
PM_High = if OverNightHigh > 0 then OverNightHigh else na;
PM_Low = if OverNightLow > 0 then OverNightLow else na;
}
I was also hoping to get suggestions on how to add in some averages including extended hours:
1) Average of (Prior Day High) and (Current Overnight High) **so divided by 2
2) Average of (Prior Day Low) and (Current Overnight Low) **so divided by 2
3) Average of (Prior Day High) and (Current Overnight High) and (Prior Day Close) **so divided by 3
4) Average of (Prior Day Low) and (Current Overnight Low) and (Prior Day Close) **so divided by 3
** I primarily use this for Futures tracking

Not super familiar with ThinkScript at this point but could probably figure it out.

If you can provide the entire current script of for "Previous Day High/Low/Close + Premarket High/Low + High/Low/Open of Day + ATR Lines for ThinkorSwim" I would greatly appreciate it! Thanks in advance!
 
Code:
input ShowThisWeekOnly = yes;

def CurrentWeek = GetWeek() == GetLastWeek();
def PrevWeekHigh = high(period = "week")[1];
def PrevWeekLow = low(period = "week")[1];
def PrevWeekClose = close(period = "week")[1];

# Conditional plotting for current week only
plot Whigh = if ShowThisWeekOnly and !CurrentWeek then Double.NaN else PrevWeekHigh;
plot Wlow = if ShowThisWeekOnly and !CurrentWeek then Double.NaN else PrevWeekLow;
plot Wmean = if ShowThisWeekOnly and !CurrentWeek then Double.NaN else (PrevWeekHigh + PrevWeekLow + PrevWeekClose) / 3;

Whigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Whigh.SetDefaultColor(Color.UPTICK);
Whigh.SetLineWeight(2);

Wlow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Wlow.SetDefaultColor(Color.DOWNTICK);
Wlow.SetLineWeight(2);

Wmean.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Wmean.SetDefaultColor(Color.YELLOW);
Wmean.SetLineWeight(2);

# Optional: price color changes relative to previous week levels
AssignPriceColor(
    if close >= Whigh then Color.GREEN
    else if close <= Wlow then Color.RED
    else Color.CURRENT
);
Ant -- Thanks! Back behind screens and hoping you can add labeling to this similar to the op'S as shown in this screengrab
1746474263878.png
 
Last edited by a moderator:

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