How to convert the MTF MACD from looking at 3 time frames to only 2


Category:
0
0

Hi Pete. I would like to be able to take your MTF MACD to only look at 2 time frames (the Daily and Weekly), instead of having to look at 3 time frames. How would it be possible to make that change?

Marked as spam
Posted by (Questions: 15, Answers: 23)
Asked on August 12, 2017 6:08 am
129 views
0

Always be sure to provide a link to the video if your question pertains to one. There are two MTF MACD studies published. Which one did you want to modify? Have you tried setting both higher time frames to weekly and plotting it on a daily chart?

( at August 12, 2017 8:57 am)
0
I was able to figure it out. ? declare lower; input midTermPeriod = {”1 min”, ”3 min”, ”5 min”, ”15 min”, ”30 min”, ”60 min”, ”120 min”, “240 min”, ”Daily”, default ”Weekly”, ”Monthly”}; input fastLength = 12; input slowLength = 26; input MACDLength = 9; input midTermFastLength = 12; input midTermSlowLength = 26; input midTermMACDLength = 9; def middleAggregation; switch (midTermPeriod) { case ”1 min”: middleAggregation = AggregationPeriod.MIN; case ”3 min”: middleAggregation = AggregationPeriod.THREE_MIN; case ”5 min”: middleAggregation = AggregationPeriod.FIVE_MIN; case ”15 min”: middleAggregation = AggregationPeriod.FIFTEEN_MIN; case ”30 min”: middleAggregation = AggregationPeriod.THIRTY_MIN; case ”60 min”: middleAggregation = AggregationPeriod.HOUR; case ”120 min”: middleAggregation = AggregationPeriod.TWO_HOURS; case ”240 min”: middleAggregation = AggregationPeriod.FOUR_HOURS; case ”Daily”: middleAggregation = AggregationPeriod.DAY; case ”Weekly”: middleAggregation = AggregationPeriod.WEEK; case ”Monthly”: middleAggregation = AggregationPeriod.MONTH; } DefineGlobalColor(”UpTrend”, color.GREEN); DefineGlobalColor(”DownTrend”, color.RED); DefineGlobalColor(”NoTrend”, color.LIGHT_GRAY); def timeFrame = getAggregationPeriod(); def testTimeFrames = if timeFrame < middleAggregation then yes else no; # This section is for the chart level MACD def fastAvg = ExpAverage(close, fastLength); def slowAvg = ExpAverage(close, slowLength); plot Value = fastAvg - slowAvg; Value.SetDefaultColor(color.CYAN); plot Avg = ExpAverage(Value, MACDLength); Avg.SetDefaultColor(color.YELLOW); plot Diff = (value - avg)*3; # This section is for the medium term MACD def midTermFastAvg = ExpAverage(close(period = middleAggregation) , midTermFastLength); def midTermSlowAvg = ExpAverage(close(period = middleAggregation) , midTermSlowLength); def midTermValue = midTermFastAvg - midTermSlowAvg; def midTermAvg = ExpAverage(midTermValue, midTermMACDLength); plot midTermDiff = (midTermValue - midTermAvg)*3; midTermDiff.Hide(); midTermDiff.HideBubble(); def midTermLower = midTermDiff midTermDiff[1]; rec midTermSignal = if midTermLower then yes else if midTermSignal[1] == yes and midTermHigher == no then yes else no; #plot test = midTermSignal; midTermDiff.AssignValueColor(if midTermSignal then color.RED else color.BLUE); def upTrend = Diff > Diff[1] and midTermSignal == no; def downTrend = Diff Diff[1] and midTermSignal == no then GlobalColor(”UpTrend”) else if Diff 0 then 0 else Double.Nan; zeroLine.AssignValueColor(if Diff > Diff[1] and midTermSignal == no then GlobalColor(”UpTrend”) else if Diff < Diff[1] and midTermSignal == yes then GlobalColor("DownTrend") else GlobalColor("NoTrend") ); zeroLine.SetPaintingStrategy(PaintingStrategy.POINTS); zeroLine.SetLineWeight(3);
( at August 13, 2017 7:13 pm)