High & low of week& previous week Candle Study

omfinancial

New member
Greetings all! I hope q1 has gone to your liking- I am attempting to work on Better entries and A concept I am trying to vizualize via study is the High and Low of week Candle ( and previous week). I am writing to inquire if it is possible to have Think script Identify the High/Low of Week (& previous week) , and plot a horizontal line at the Low point of the Candle that makes the high, and at the High point of the candle that makes the Low. I have a screenshot attached.

Thanks again for this forum and its contributors.



1711729992032.png
 
Solution
Greetings all! I hope q1 has gone to your liking- I am attempting to work on Better entries and A concept I am trying to vizualize via study is the High and Low of week Candle ( and previous week). I am writing to inquire if it is possible to have Think script Identify the High/Low of Week (& previous week) , and plot a horizontal line at the Low point of the Candle that makes the high, and at the High point of the candle that makes the Low. I have a screenshot attached.

Thanks again for this forum and its contributors.



View attachment 21466

This plots the last 2 weeks HL data you requested.
Line colors can be changed at the input screen.
Optional bubbles can be moved sideways in expansion at input bubblemover

Greetings all! I hope q1 has gone to your liking- I am attempting to work on Better entries and A concept I am trying to vizualize via study is the High and Low of week Candle ( and previous week). I am writing to inquire if it is possible to have Think script Identify the High/Low of Week (& previous week) , and plot a horizontal line at the Low point of the Candle that makes the high, and at the High point of the candle that makes the Low. I have a screenshot attached.

Thanks again for this forum and its contributors.



View attachment 21466

This plots the last 2 weeks HL data you requested.
Line colors can be changed at the input screen.
Optional bubbles can be moved sideways in expansion at input bubblemover

Screenshot 2024-04-12 130302.png
Code:
#High & low of week& previous week Candle Study
input showbubbles = yes;
input bubblemover = 2;

def count = if !IsNaN(close) and GetWeek() != GetWeek()[1] then count[1] + 1 else count[1];
def cond  = HighestAll(count) - count + 1;
def na    = Double.NaN;
DefineGlobalColor("HW", Color.WHITE);
DefineGlobalColor("LW", Color.WHITE);
DefineGlobalColor("LHW", Color.CYAN);
DefineGlobalColor("HLW", Color.YELLOW);

#Week 1 (Current)
plot hw1 = if cond == 1 then high(period = AggregationPeriod.WEEK) else na;
plot lw1 = if cond == 1 then low(period = AggregationPeriod.WEEK) else na;
hw1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
lw1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
hw1.SetDefaultColor(GlobalColor("HW"));
lw1.SetDefaultColor(GlobalColor("LW"));

def lhw1 = if IsNaN(close) then lhw1[1] else if high == hw1 then low else lhw1[1];
def hlw1 = if IsNaN(close) then hlw1[1] else if low == lw1 then high else hlw1[1];

plot lowofhighweek1 = if cond == 1 then lhw1 else na;
plot highoflowweek1 = if cond == 1 then hlw1 else na;
lowofhighweek1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
highoflowweek1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
lowofhighweek1.SetDefaultColor(GlobalColor("LHW"));
highoflowweek1.SetDefaultColor(GlobalColor("HLW"));

#Week 2 (Previous)
plot hw2 = if cond == 2 then high(period = AggregationPeriod.WEEK) else na;
plot lw2 = if cond == 2 then low(period = AggregationPeriod.WEEK) else na;
hw2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
lw2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
hw2.SetDefaultColor(GlobalColor("HW"));
lw2.SetDefaultColor(GlobalColor("LW"));

def lhw2 = if IsNaN(hw2) then lhw2[1] else if high == hw2 then low  else lhw2[1];
def hlw2 = if IsNaN(lw2) then hlw2[1] else if low == lw2 then high else hlw2[1];

plot lowofhighweek2 = if cond <= 2 then lhw2[1] else na;
plot highoflowweek2 = if cond <= 2 then hlw2 else na;

lowofhighweek2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
highoflowweek2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
lowofhighweek2.SetDefaultColor(GlobalColor("LHW"));
highoflowweek2.SetDefaultColor(GlobalColor("HLW"));

### Bubbles
def b = bubblemover;
def mover = showbubbles and IsNaN(close[b]) and !IsNaN(close[b + 1]);
AddChartBubble(mover, lowofhighweek1, "LHW1 " + AsText(lowofhighweek1), lowofhighweek1.TakeValueColor());
AddChartBubble(mover, highoflowweek1, "HLW1 " + AsText(highoflowweek1), highoflowweek1.TakeValueColor());
AddChartBubble(mover, lowofhighweek2, "LHW2 " + AsText(lowofhighweek2), lowofhighweek2.TakeValueColor());
AddChartBubble(mover, highoflowweek2, "HLW1 " + AsText(highoflowweek2), highoflowweek2.TakeValueColor());

#
 
Solution

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