Add multi timeframe to MACD TwoLines?

D

dvorakm

New member
2019 Donor
VIP
Hi! I can not seem to figure out how to edit MACD TwoLines code to use a different aggregation on a given chart. For example, I am needing the MACD TwoLines 30minute aggregation, but viewed on a 5minute chart. I thought simply adding "input agg = AggregationPeriod.thirty_MIN;" would do the trick, but I, of course, was wrong. It displays exactly the same as the MACD TwoLines on the 5minute chart. Any help would be greatly appreciated.
Code:
#
# TD Ameritrade IP Company, Inc. (c) 2007-2020
#

declare lower;

input fastLength = 8;
input slowLength = 21;
input MACDLength = 5;
input averageType = AverageType.EXPONENTIAL;
input agg = AggregationPeriod.thirty_MIN;

plot Value = MACD(fastLength, slowLength, MACDLength, averageType).Value;
plot Avg = MACD(fastLength, slowLength, MACDLength, averageType).Avg;
plot ZeroLine = 0;

Value.SetDefaultColor(GetColor(1));
Avg.SetDefaultColor(GetColor(8));
ZeroLine.SetDefaultColor(GetColor(0));
 
Last edited by a moderator:
horserider

horserider

Well-known member
VIP
Not sure you can do it with that study. May have to go back and use the original MACD calculations and apply agg to the close.
 

Similar threads

Top