Plot High Low 1st Day to form range

Sai

Member
VIP
Plot High Low 1st Day of the month to form range

HI, I am trying to plot 1st Day of the month's High and LOW . i want to use this as a range for my Swings for that month.
 

Attachments

  • 1stDayOfTheMonthRange.png
    1stDayOfTheMonthRange.png
    98.7 KB · Views: 175
Last edited by a moderator:
Solution
Hi Sally, if i am trying to plot only for current month using GetMonth() != GetMonth()[1] . its acting weired. can you pls help to plot for current month pls.

This should plot just the current month's h/l. This version should also work on intraday charts with enough days displayed on the chart for the month.

Screenshot 2023-12-22 053604.png
Code:
#HL_Month
input showcurrentonly = yes;

def hi = if GetMonth() != GetMonth()[1] then high(period = AggregationPeriod.DAY) else hi[1];
plot h = if showcurrentonly and GetMonth() != GetLastMonth() then Double.NaN else hi;
h.SetPaintingStrategy(PaintingStrategy.DASHES);
h.SetDefaultColor(Color.GREEN);

def lo = if GetMonth() != GetMonth()[1] then low(period = AggregationPeriod.DAY) else lo[1];
plot l =...
HI, I am trying to plot 1st Day of the month's High and LOW . i want to use this as a range for my Swings for that month.

This plots those lines and has an optional cloud.

Screenshot 2023-12-14 161105.png
Code:
#HL_Month
def hi = if GetMonth() != GetMonth()[1] then high else hi[1];
plot h = hi;
h.SetPaintingStrategy(PaintingStrategy.DASHES);
h.setdefaultColor(color.green);

def lo = if GetMonth() != GetMonth()[1] then low else lo[1];
plot l = lo;
l.SetPaintingStrategy(PaintingStrategy.DASHES);
l.setdefaultColor(color.red);

input cloud = no;
defineGlobalColor("Cloud", color.light_gray);
addcloud(if !cloud then double.nan else h, l, globalColor("Cloud"), globalColor("Cloud"));
#
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Hi Sally, if i am trying to plot only for current month using GetMonth() != GetMonth()[1] . its acting weired. can you pls help to plot for current month pls.

This should plot just the current month's h/l. This version should also work on intraday charts with enough days displayed on the chart for the month.

Screenshot 2023-12-22 053604.png
Code:
#HL_Month
input showcurrentonly = yes;

def hi = if GetMonth() != GetMonth()[1] then high(period = AggregationPeriod.DAY) else hi[1];
plot h = if showcurrentonly and GetMonth() != GetLastMonth() then Double.NaN else hi;
h.SetPaintingStrategy(PaintingStrategy.DASHES);
h.SetDefaultColor(Color.GREEN);

def lo = if GetMonth() != GetMonth()[1] then low(period = AggregationPeriod.DAY) else lo[1];
plot l = if showcurrentonly and GetMonth() != GetLastMonth() then Double.NaN else lo;
l.SetPaintingStrategy(PaintingStrategy.DASHES);
l.SetDefaultColor(Color.RED);

input cloud = no;
DefineGlobalColor("Cloud", Color.LIGHT_GRAY);
AddCloud(if !cloud then Double.NaN else h, l, GlobalColor("Cloud"), GlobalColor("Cloud"));
#
 
  • Like
Reactions: Sai
Solution
This should plot just the current month's h/l. This version should also work on intraday charts with enough days displayed on the chart for the month.
Hi Sleepyz, Thank you . Trying to see how can we draw the range for Highs and lows of 1st 10 business days of the month(January for example ) . I see above has different approaches which cant be used to find out for 10 days. can you help me
Thank you
 
Hi Sleepyz, Thank you . Trying to see how can we draw the range for Highs and lows of 1st 10 business days of the month(January for example ) . I see above has different approaches which cant be used to find out for 10 days. can you help me
Thank you

This should plot the developing high/low for the 1st x days input of the last month on the chart.

Screenshot 2024-01-03 015741.png
Code:
#Plot H/L 1st 10 trading days of Last Month Extended
input days = 10;
def ymd = GetYYYYMMDD();
def ct  = if GetMonth() != GetMonth()[1] and ymd then 1
          else if ymd != ymd[1]
          then ct[1] + 1
          else ct[1];

def h   = if isnan(close)
          then h[1]
          else if ct[1] != 1 and ct == 1
          then high
          else if ct <= days
          then Max(high, h[1])
          else h[1];
plot hh_x_days = if GetMonth() != GetLastMonth() then Double.NaN else h;

def l   = CompoundValue(1,
          if isnan(close)
          then l[1]
          else if ct[1] != 1 and ct == 1
          then low
          else if ct <= days
          then Min(low, l[1])
          else l[1], low);
plot ll_xdays = if GetMonth() != GetLastMonth() then Double.NaN else l;

input verticals = yes;
addverticalLine(verticals and getmonth()!=getmonth()[1], " ", color.white);
addverticalLine(verticals and ct==11 and ct[1] == 10, " ", color.white);

#
 
Last edited:
THANK YOU SkeepyZ. Each version has diff logic . Any idea how can we have this as a scan column for the stocks which close is above high / Low of this range
 
THANK YOU SkeepyZ. Each version has diff logic . Any idea how can we have this as a scan column for the stocks which close is above high / Low of this range

There was different logic because in the 1st request you displayed a monthly chart upon which only regular trading hours are included. Looking at the 10 day request, I assumed you might use intraday charts with expanded hours and therefore you would want those included in the high/low.

Here if the 10 day code with scan logic that you can adjust to your preferences.

To test it today, the code is set to input days = 2, only 1 plot can be used so the other is commented out, and scan was set to 5m, extended hours included and used plot scanhigh. The custom 2 column in the results is the h / l values at days = 2
Screenshot 2024-01-04 082203.png


Code:
#Plot H/L 1st 10 trading days of Last Month Extended
input days = 2;
def ymd = GetYYYYMMDD();
def ct  = if GetMonth() != GetMonth()[1] and ymd then 1
          else if ymd != ymd[1]
          then ct[1] + 1
          else ct[1];

def h   = if isnan(close)
          then h[1]
          else if ct[1] != 1 and ct == 1
          then high
          else if ct <= days
          then Max(high, h[1])
          else h[1];
plot scan_high = close > h;

def l   = CompoundValue(1,
          if isnan(close)
          then l[1]
          else if ct[1] != 1 and ct == 1
          then low
          else if ct <= days
          then Min(low, l[1])
          else l[1], low);

#plot scanlow = close < l;
#
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
260 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