//+-------------------------------------------------------------------------------------+
//| Получение значений МА на двух соседних барах |
//+-------------------------------------------------------------------------------------+
double GetCurAndPrevMA(int maPeriod, double& prevMA)
{
prevMA = iMA(NULL, i_TF, maPeriod, 0, MODE_EMA, MODE_CLOSE, 1);
return (iMA(NULL, i_TF, maPeriod, 0, MODE_EMA, MODE_CLOSE, 0));
}
//+-------------------------------------------------------------------------------------+
//| Получение положения машек между собой |
//+-------------------------------------------------------------------------------------+
void GetStateMa(int& crossDir[])
{
double ema365_1;
double ema365_0 = GetCurAndPrevMA(365, ema365_1);
// ArrayResize(crossDir,4);
for (int i=0; i<4; i++)
{
double ema1;
double ema0 = GetCurAndPrevMA(g_maPeriod[i], ema1);
crossDir[i] = CROSS_NO;
Print("ema0_1 = ", i, "___", ema1);
Print("ema0_0 = ", i, "___", ema0);
Print("ema365_1 = ", i, "___", ema365_1);
Print("ema365_0 = ", i, "___", ema365_0);
Print("crossDir[i] = ", i, "___", crossDir[i]);
if (ema1 < ema365_1 && ema0 > ema365_0)
{
Print("ema1b < 365_1 ___ ", ema1 ," < ", ema365_1, "___",i);
Print("ema0b > 365_0 ___ ", ema0 ," > ", ema365_0, "___",i);
crossDir[i] = CROSS_UP;
}
if (ema1 > ema365_1 && ema0 < ema365_0)
{
Print("ema1s > 365_1 ___", ema1 ," > ", ema365_1, "___",i);
Print("ema0s < 365_0 ___ ", ema0 ," < ", ema365_0, "___",i);
crossDir[i] = CROSS_DN;
}
}
}