Drawing 9ema from multiple time frames on a chart


Category:
0
0

Pete,
Do you have a method for drawing a 9ema from each of the following time frames onto a single chart?

1 minute chart 9ema
5 minute chart 9ema
15 minute chart 9ema
60 minute chart 9ema

Ideally, I would like to have all of these 9ema’s charted onto a 1 minute chart.

Many thanks.

 

David McLean

RESOLVED
Marked as spam
Posted by (Questions: 1, Answers: 2)
Asked on September 10, 2020 12:29 pm
295 views
0
Private answer

Thanks for posting your question about MTF moving averages plotted on a chart.

The solution I will provide is the most flexible for all viewers. Which means the chart study will include user adjustable inputs so that anyone can select the Edit Studies window and adjust the length of the moving average, what type of moving average and the time frame.

Using this approach, you can use this code to create a single custom chart study that you can then add to the chart many times. Then adjust each one using the user inputs (do not modify the code).

input maLengthOne = 9;
input maTypeOne = AverageType.EXPONENTIAL;
input timeFrameOne = AggregationPeriod.FIVE_MIN;
plot maOne = MovingAverage(maTypeOne, close(period = timeFrameOne), maLengthOne);

Now I know for certain someone will want to know how to build a signal chart study that contains all the moving averages you listed. I will show you a section of code that displays two moving averages, using two of those time frames as the default value.

input maLengthOne = 9;
input maTypeOne = AverageType.EXPONENTIAL;
input timeFrameOne = AggregationPeriod.FIVE_MIN;
input maLengthTwo = 9;
input maTypeTwo = AverageType.EXPONENTIAL;
input timeFrameTwo = AggregationPeriod.FIFTEEN_MIN;
plot maOne = MovingAverage(maTypeOne, close(period = timeFrameOne), maLengthOne);
plot maTwo = MovingAverage(maTypeTwo, close(period = timeFrameTwo), maLengthTwo);

As you examine this code you will find a pattern. All I did was to copy the code that plots the single moving average. Then changed the name of all the inputs and variables. For example I copied "input maLengthOne" then pasted that and changed the copy to "inputmaLengthTwo". I repeated the process for every input and variable name throughout. Following this pattern you can repeat this process to create a Three, Four, Five or how every many you like.

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on September 10, 2020 2:08 pm
0
I have fiddled around with this for a while and couldn't resolve it. You know the language well. I am testing your code for 5 concurrent ema's and am making a contribution right now for your prompt assistance. Thanks Pete !
( at September 10, 2020 6:07 pm)
0
You are very welcome. Glad I could help!
( at September 10, 2020 7:10 pm)