Display MACD as Dots in Lower Study


Category:
0
0

Hi Pete,

I asked a similar question in this thread about moving averages, which you helped me resolve. This is my last request for this type of indicator.

Do you know how to create a lower chart study that plots when a MACD Value is greater than its Avg as dots as opposed to lines and a Histogram?

Also, to provide more clarity, I’d like the lower chart study to allow you to select multiple timeframes, for multi-timeframe analysis. So if I’m using a 1M chart to trade, I’d like to see a row of dots for additional timeframes in this study. One row could be 5 minutes; another could be 15 minutes, etc.

If the condition exists (e.g. Value is greater than the Avg), I’d like the corresponding row (e.g. 5 or 15 minute) to display a Green dot after every 1 minute candle (primary chart I’m trading on). If the condition does not exist, I’d like it to display a Red dot.

RESOLVED
Marked as spam
Posted by (Questions: 4, Answers: 1)
Asked on January 13, 2021 7:35 pm
401 views
0
Private answer

This solution is very much the same as the one you linked in your question. Start with a basic MACD, add the secondary aggregation components to allow adjustment of the time frame, plot a single row of dots colored based the same rules. Most of this was just a copy/paste with just a few modifications. Compare this code to the one you linked in your question to see where each component is reused.

declare lower;
input timeFrameOne = AggregationPeriod.FIFTEEN_MIN;
input fastLength = 12;
input slowLength = 26;
input macdLength = 9;
input macdAverageType = AverageType.EXPONENTIAL;
def value = MovingAverage(macdAverageType, close(period = timeFrameOne), fastLength) - MovingAverage(macdAverageType, close(period = timeFrameOne), slowLength);
def average = MovingAverage(macdAverageType, value, macdLength);
plot rowOne = if !IsNaN(close) then 0 else Double.NaN;
rowOne.SetPaintingStrategy(PaintingStrategy.POINTS);
rowOne.AssignValueColor(if value > average then Color.GREEN else Color.RED);
rowOne.SetLineWeight(3);

Once you read and understand how the code functions you can replicate this to plot as many different rows of other time frames as you require.

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on January 14, 2021 11:02 am