Display Moving Averages as Dots in Lower Study


Category:
0
0

Hi Pete,

Do you know how to create a lower chart study that plots moving averages greater than another moving average as dots as opposed to lines, similar to the study in this illustration? I found a snippet of code in a study that I think would be helpful, but I’m not sure how to use it to build a complete study.

SetPaintingStrategy(PaintingStrategy.Points)

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. 9 EMA is greater than the 20 EMA), 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 4:04 pm
175 views
0
Private answer

In the brief 15 minutes I allow for free solutions in the Q&A Forum I can give you an example that includes one signal row of dots:

declare lower;
input timeFrameOne = AggregationPeriod.FIFTEEN_MIN;
input maLengthOne = 9;
input maTypeOne = AverageType.EXPONENTIAL;
input maLengthTwo = 20;
input maTypeTwo = AverageType.EXPONENTIAL;
def maOne = MovingAverage(maTypeOne, close(period = timeFrameOne), maLengthOne);
def maTwo = MovingAverage(maTypeTwo, close(period = timeFrameOne), maLengthTwo);
plot rowOne = if !IsNaN(close) then 0 else Double.NaN;
rowOne.SetPaintingStrategy(PaintingStrategy.POINTS);
rowOne.AssignValueColor(if maOne > maTwo then Color.GREEN else Color.RED);
rowOne.SetLineWeight(3);

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on January 13, 2021 5:18 pm