Skip to content

Instantly share code, notes, and snippets.

@matthewkastor
Last active January 23, 2016 21:07
Show Gist options
  • Save matthewkastor/a570b9cd1b294f7d17de to your computer and use it in GitHub Desktop.
Save matthewkastor/a570b9cd1b294f7d17de to your computer and use it in GitHub Desktop.
functions for getting the MACD indicator in metatrader 4
input int MovingPeriod = 12;
input int MovingShift = 0;
double GetMacd(int mode, int period, int shift) {
int fastEmaPeriod = period / 2.1555;
int slowEmaPeriod = period;
int signalPeriod = (period / 2.1555) * 0.75;
return iMACD(Symbol(),0,fastEmaPeriod,slowEmaPeriod,signalPeriod,PRICE_TYPICAL,mode,shift);
}
double GetMacdMain() {
return GetMacd(MODE_MAIN, MovingPeriod, MovingShift);
}
double GetMacdSignal() {
return GetMacd(MODE_SIGNAL, MovingPeriod, MovingShift);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment