Multi Time Frame Moving Average

MiamiFlorida

New member
Hello, I am trying to have visibility of higher time frame moving averages on a lower time frame chart. For example, on the 1 minute chart I would like to see where the monthly 50 SMA is. It was my understanding that you can only access data from time frame charts greater than or equal to your current one, so I was under the assumption that this would work. The smallest time frame that I have been able to make it work is a 360 day chart. Any idea how I can fix this? Any help would be appreciated.

This is the code I have been using:

input price = FundamentalType.CLOSE;

input aggregationPeriod = AggregationPeriod.Month;

input length = 50;

input averageType = AverageType.SIMPLE;



def MovAvg = MovingAverage(averageType, Fundamental(price, period = aggregationPeriod), length);



plot MALine = highestAll(if isNaN(close[-1])

then MovAvg

else Double.NaN);

MALine.SetStyle(Curve.Short_Dash);

MALine.SetLineWeight(1);

MALine.SetDefaultColor(CreateColor(50,250,150));
 
Solution
Hello, I am trying to have visibility of higher time frame moving averages on a lower time frame chart. For example, on the 1 minute chart I would like to see where the monthly 50 SMA is. It was my understanding that you can only access data from time frame charts greater than or equal to your current one, so I was under the assumption that this would work. The smallest time frame that I have been able to make it work is a 360 day chart. Any idea how I can fix this? Any help would be appreciated.

This is the code I have been using:

input price = FundamentalType.CLOSE;

input aggregationPeriod = AggregationPeriod.Month;

input length = 50;

input averageType = AverageType.SIMPLE;



def MovAvg = MovingAverage(averageType...
Hello, I am trying to have visibility of higher time frame moving averages on a lower time frame chart. For example, on the 1 minute chart I would like to see where the monthly 50 SMA is. It was my understanding that you can only access data from time frame charts greater than or equal to your current one, so I was under the assumption that this would work. The smallest time frame that I have been able to make it work is a 360 day chart. Any idea how I can fix this? Any help would be appreciated.

This is the code I have been using:

input price = FundamentalType.CLOSE;

input aggregationPeriod = AggregationPeriod.Month;

input length = 50;

input averageType = AverageType.SIMPLE;



def MovAvg = MovingAverage(averageType, Fundamental(price, period = aggregationPeriod), length);



plot MALine = highestAll(if isNaN(close[-1])

then MovAvg

else Double.NaN);

MALine.SetStyle(Curve.Short_Dash);

MALine.SetLineWeight(1);

MALine.SetDefaultColor(CreateColor(50,250,150));
The ToS platform does not provide a month of data to aggregations less than 5min
 
Solution

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

Hello, I am trying to have visibility of higher time frame moving averages on a lower time frame chart. For example, on the 1 minute chart I would like to see where the monthly 50 SMA is. It was my understanding that you can only access data from time frame charts greater than or equal to your current one, so I was under the assumption that this would work. The smallest time frame that I have been able to make it work is a 360 day chart. Any idea how I can fix this? Any help would be appreciated.

This is the code I have been using:

input price = FundamentalType.CLOSE;

input aggregationPeriod = AggregationPeriod.Month;

input length = 50;

input averageType = AverageType.SIMPLE;



def MovAvg = MovingAverage(averageType, Fundamental(price, period = aggregationPeriod), length);



plot MALine = highestAll(if isNaN(close[-1])

then MovAvg

else Double.NaN);

MALine.SetStyle(Curve.Short_Dash);

MALine.SetLineWeight(1);

MALine.SetDefaultColor(CreateColor(50,250,150));

another way of looking at it, you are requesting too many data candles.

a 1 minute chart has 390 candles during a 6.5 hour day. with after hours turned off.
say a month has 22 days, that would be 22 x 390 = 8,580 candles.
50 months would be
50 x 22 x 390 = 429,000 candles

i think the limit is around 10,000 candles.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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