MQL4 - Moving Average Cross Over Signal
img
string getMAcrossoverSignal()
{
string Signal;
//current chart, current period, 20, no shift, simple, close price
double SlowMovingAverage = iMA(NULL,0,50,0,MODE_SMA, PRICE_CLOSE, 0);
//current chart, current period, 20, no shift, simple, close price
double LastSlowMovingAverage = iMA(NULL,0,50,0,MODE_SMA, PRICE_CLOSE, 1);
//current chart, current period, 10, no shift, simple, close price
double FastMovingAverage = iMA(NULL,0,20,0,MODE_SMA, PRICE_CLOSE, 0);
//current chart, current period, 10, no shift, simple, close price
double LastFastMovingAverage = iMA(NULL,0,20,0,MODE_SMA, PRICE_CLOSE, 1);
if ((LastFastMovingAverage < LastSlowMovingAverage) && (FastMovingAverage > SlowMovingAverage))
{
Comment ("CrossOver:", "BUY");
Signal = "BUY";
}
if ((LastFastMovingAverage > LastSlowMovingAverage) && (FastMovingAverage < SlowMovingAverage))
{
Comment ("CrossOver:", "SELL");
Signal = "SELL";
}
return Signal;
}
Langgan:
Catat Ulasan
(
Atom
)
Tiada ulasan :
Catat Ulasan