Since you logged into the forum using your Twitter account we don't have a valid email address for you. This means you are not getting email notifications when you post new content on our website. Don't post your email address here or you will get spammed. Contact me directly and we can get that updated.
Here is the solution you requested:
input minimumValue = 0.0;
input maximumValue = 0.35;
input maLengthOne = 21;
input maTypeOne = AverageType.EXPONENTIAL;
input maPriceOne = close;
def maOne = MovingAverage(maTypeOne, maPriceOne, maLengthOne);
plot percentFrom = 10 * (close / maOne – 1);
percentFrom.AssignValueColor(if percentFrom > minimumValue and percentFrom < maximumValue then Color.BLACK else Color.CURRENT); AssignBackgroundColor(if percentFrom > minimumValue and percentFrom < maximumValue then Color.GREEN else Color.CURRENT);
I included user inputs for min/max values so the rest of our viewers can use this for their own preferences.
And while I was working this I realized the percentFrom variable is not computed correctly. That line of code should be as follows:
plot percentFrom = 100 * (close / maOne – 1);
But changing this would also require you to update the min/max value inputs to account for the adjusted value. I am providing this correction for the benefit of those who come across this post at a later date. And I will updated the solution in the original post as well.