Simple question

 
Why the alert return value from fasterMAnow but fasterMAprevious returns 0? i men the problem is in the MA and MAMode stuff, but what is the problem?

#property copyright ""
#property link ""


//---- input parameters
extern double TakeProfit = 25;
extern double Lots = 0.01;
extern double TrailingStop = 10;
extern double InitialStop = 20;
extern double slip = 2;
extern double MA = 21;
extern double MAMode = 1;
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
int init()
{
//----
return(0);
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
int deinit()
{
//----
return(0);
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
int start()
{
int Trend;
double fasterMAnow,fasterMAprevious;
fasterMAnow = iMA(NULL, PERIOD_D1, 21, 0, 1, PRICE_CLOSE, 0);
fasterMAprevious = iMA(NULL, PERIOD_D1, MA, 0, MAMode, PRICE_CLOSE, 1);

Alert(fasterMAnow+"-"+fasterMAprevious);
......................
 
Could it be the fact that you have defined the mode (MaMode) as double instead of int?

Cheers!

Max
 
i tried int too, do the same
 
I've just tried the code you provided as an EA, works fine with me and both MAnow and previous values are displayed in the Alert window...
 
Hi,
 
I have turned your Simple Question into "SimpleAnswer.mq4" and have no trouble whatsoever.\
 
Cheers!
 
Max



Files:
Reason: