♥ 0 |
Hi Peter, this code combination merely plots the the upper symbols 21 day HMA on the lower plot. What am I doing wrong?
declare lower;
input price = close; input length = 21; input displace = 0;
plot HMA = MovingAverage(AverageType.HULL, price, length)[-displace];
HMA.DefineColor(“Up”, GetColor(1)); HMA.DefineColor(“Down”, GetColor(0)); HMA.AssignValueColor(if HMA > HMA[1] then HMA.color(“Up”) else HMA.color(“Down”));
Marked as spam
|
Private answer
In the code you provided, the line of code that computes the Hull moving average is:
The MovingAverage() function takes three parameters. Details here: https://toslc.thinkorswim.com/center/reference/thinkScript/Functions/Tech-Analysis/MovingAverage The first parameter is the average type, the second is the price used to compute the moving average and the third is for the length of the moving average. In your code the second parameter is an input variable named "price". And this is the line of code that holds that user input:
So we can see why your Hull moving average is plotting based on the chart ticker symbol instead of the alternate ticker symbol. So simply delete everything except the first three lines. The first three lines are all that is needed to plot the Hull moving average along with the closing prices of the alternate ticker symbol.
There you go. That's all you need. However because this is the second post on this topic I understand from the previous post that you are actually trying to dynamically set the color of the Hull moving average just as it is in the original version provided with Thinkorswim. You did not include that in this current request, but somehow I managed to remember this small detail. The dynamic color assignment is found in the last three of the lines in the code I just told you to delete. So here they are again. This time I have replaced the reference to the HMA plot (which was deleted as per my instructions) , and in it's place I am going to use the plot named "maOne":
Let's make sure we don't leave this incomplete, or else we will have many viewers fail to put all these pieces together correctly:
For those who are wondering how on earth I knew how to do this.... it's just magic. No, I'm totally kidding. Everything you need to know to learn how to do this yourself is contained in the following links to the Thinkorswim Language Reference: https://toslc.thinkorswim.com/center/reference/thinkScript/Functions/Look---Feel/DefineColor https://toslc.thinkorswim.com/center/reference/thinkScript/Functions/Look---Feel/AssignValueColor
Marked as spam
|
Please log in to post questions.