Percent difference between two Moving averages


Category:
0
0

Hello

first this code is from another you provided to me, I switched it up a bit, Thanks again

What I am looking for is to add the 50 sma is 20% less than the 100 sma.

Thank you for any solutions you can provide

I removed part of the code so it would fit here

input maLength50 = 50;
input maType50 = AverageType.SIMPLE;
input maPrice50 = close;

input maLength100 = 100;
input maType100 = AverageType.SIMPLE;
input maPrice100 = close;

input maLength200 = 200;
input maType200 = AverageType.SIMPLE;
input maPrice200 = close;

def ma50 = MovingAverage(maType50, maPrice50, maLength50);
def ma100 = MovingAverage(maType100, maPrice100, maLength100);
def ma200 = MovingAverage(maType200, maPrice200, maLength200);

def movingAveragesStackedBelow = ma50 < ma100 and ma100 ma50 and ma3 > ma5 and ma5 > ma8 and ma8 > ma50;

plot value = movingAveragesStackedBelow;

Marked as spam
Posted by (Questions: 11, Answers: 16)
Asked on July 7, 2020 9:05 am
264 views
0
error;……..\\”def movingAveragesStackedBelow = ma50 ma5 and ma5 > ma8 and ma8 > ma50;\\” _____________________________________________________________________________ suppose to be ; def movingAveragesStackedBelow = ma50 < ma100 and ma100 ma8 and ma8 > ma50; and I should clarify when the 50 is 20% or more, under the 100 sma
( at July 7, 2020 9:08 am)
0
Private answer

Percent difference between two moving averages has already been requested and solved in the following post:

https://www.hahn-tech.com/ans/moving-average-is-x-percent-away-or-greater-from-another-moving-average/

HINT: You don't need to modify your existing code. Simply use the code from that previous post as a separate Study Filter in the same condition group, set to "all of the following".

Marked as spam
Posted by (Questions: 37, Answers: 4087)
Answered on July 7, 2020 11:48 am