Ascending or descending moving average

Mahan1994
8
Mahan1994  

Hi everybody. 

I want to compare moving average of two points to check if moving average chart is ascending or not. 

double startEMA = iMA(NULL,TimeFrame,MovingAveragePeriod,0,MODE_EMA,PRICE_CLOSE,1);
double endEMA   = iMA(NULL,TimeFrame,MovingAveragePeriod,0,MODE_EMA,PRICE_CLOSE,15);
if (startEMA - endEMA > 0) 
   SlopeDirection = "+";
else  
   SlopeDirection = "-";

But the result is not correct! 

Could you please help me to solve it?

Thank you in advance.

Keith Watford
Moderator
32147
Mahan1994:

Hi everybody. 

I want to compare moving average of two points to check if moving average chart is ascending or not. 

But the result is not correct! 

Could you please help me to solve it?

Thank you in advance.

What do you mean? What result are you getting?

How do you know that it is not correct?

Is the variable 

SlopeDirection 
a string?
William Roeder
25838
William Roeder  
Mahan1994: But the result is not correct!

“Doesn't work” is meaningless — just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires — meaningless.
     How To Ask Questions The Smart Way. 2004
          When asking about code