Plotting two EMA’s on a lower study


Category:
0
0

I am trying to plot two different EMAs on a lower study I am having trouble. When I just put one variable in the pot data the EMA will plot. But when I put two variables it doesn’t work. Please help!

 

declare lower;

def cc = ExpAverage(close, 13);
def mm = ExpAverage(close, 48);

plot data = mm and cc;

Marked as spam
Posted by (Questions: 34, Answers: 56)
Asked on May 17, 2017 5:27 pm
132 views
1
Private answer

This post had a duplicate so I deleted the second one.

So let me me explain what you are actually doing before providing the solution. When you say:

plot data = mm and cc;

What you are actually plotting is a true/false statement that says both mm and cc are true. Problem is that is not all what you want.

You can do this very simply by making very subtle changes to your existing code:

declare lower;
plot cc = ExpAverage(close, 13);
plot mm = ExpAverage(close, 48);

Yep, that really is all there is to it. If you want to see an example of displaying multiple plots in a lower study just take a look at the standard MACD study included with Thinkorswim. Experiment with it for a bit to understand how it works. The process of writing code, which is the continual process of learning, is nothing much more than taking something that works and breaking it. After you see the result of breaking something, you instantly learn something about it’s nature. The advanced programmer has highly developed skills of breaking things, in a way that reveals the true nature of the object being broken. Wow, that is a bit deep. Hope it inspires someone!

Marked as spam
Posted by (Questions: 37, Answers: 4087)
Answered on May 17, 2017 9:02 pm
0

Thank you….. that was pretty inspiring…

( at May 19, 2017 3:33 am)