This is a very simple script - but it’s giving errant results. By “errant”, what I mean is that while “most” of the results look right, with the 8EMA>21EMA>34EMA>55EMA>89EMA , approx 10-20% of the results are wrong, i.e. the 34EMA might be above the 21EMA or the 55EMA might be above the 34EMA, etc.
Can someone shed some light on what I’m doing wrong?
I tried it multiple ways, including like this (which I think is the best way):
// 8EMA > 21EMA
c1 = MA(Bars=8, STYLE=Exponential, CALC=Close) > MA(Bars=21, STYLE=Exponential, CALC=Close);
// 34EMA > 55EMA
c2 = MA(Bars=34, STYLE=Exponential, CALC=Close) > MA(Bars=55, STYLE=Exponential, CALC=Close);
// 55EMA > 89EMA
c3 = MA(Bars=55, STYLE=Exponential, CALC=Close) > MA(Bars=89, STYLE=Exponential, CALC=Close);
c4 = c1 and c2 and c3;
// 50MA>200MA
c5 = MA(Bars=50, CALC=Close) > MA(Bars=200, CALC=Close);
c4 and c5
==============================================================
I also tried it like this …
// 89EMA<55EMA<34EMA<21EMA<8EMA
c1 = MA(Bars=89, STYLE=Exponential, CALC=Close) < MA(Bars=55, STYLE=Exponential, CALC=Close) < MA(Bars=34, STYLE=Exponential, CALC=Close) < MA(Bars=21, STYLE=Exponential, CALC=Close) < MA(Bars=8, STYLE=Exponential, CALC=Close);
// 200MA<50MA
c2 = MA(Bars=200, CALC=Close) < MA(Bars=50, CALC=Close);
c1 and c2
===========================================================================================
And I even tried it this, although this way gave zero results. The first 2 ways were better:
// 8EMA>21EMA>34EMA>55EMA>89EMA
c1 = MA(Bars=8, STYLE=Exponential, CALC=Close) > MA(Bars=21, STYLE=Exponential, CALC=Close) > MA(Bars=34, STYLE=Exponential, CALC=Close) > MA(Bars=55, STYLE=Exponential, CALC=Close) > MA(Bars=89, STYLE=Exponential, CALC=Close);
// 50MA>200MA
c2 = MA(Bars=50, CALC=Close) > MA(Bars=200, CALC=Close);
c1 and c2