Showing previous month high on daily chart


New member
Trying to learn how to reference data from other aggregation periods. Getting the previous month with [1] seems to only get the month from the previous candle. This very simple code and screenshot are maybe showing a clearer explanation. I would expect that MH[1] would have returned a value of 140.18 because that was last month's high. Instead, MH and MH[1] are both returning this month's high. Is there a reliable way to get last month's high? I did try searching the forums and the ThinkScript manual but both places seem to suggest MH[1] is the correct way and should have worked.

def MONTH = AggregationPeriod.MONTH;

def monthHigh = high(period = MONTH);

AddLabel(yes, "MH0: " + monthHigh + ", MH1: " + monthHigh[1], Color.WHITE);



(thanks @generic)
def MH = high (period = MONTH);
def MH1 = high (period = MONTH)[1];

# MH[1] is NOT equal to MH1
Last edited:
@bvesco Add another line specific for MH1. Not sure why this is but I think it has something to do with how thinkscript handles agg above daily.
def mh1 = high(period = month)[1];
Thanks everyone for the help. Indeed these are different things:

def MH = high (period = MONTH);
def MH1 = high (period = MONTH)[1];

# MH[1] is NOT equal to MH1

At least this is true if you are not on the monthly chart itself. MH[1] seems to give the monthly price of the previous candle on the current chart. I suppose if you are on the very first candle of the month they would be the same but as soon as you print a second candle in the same month it becomes incorrect.

@rad14733, good eye on the script error but that's for a different script I had loaded and not related to this one.

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
206 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.