StrategyCoder History

← Examples

Momentum (close minus close 10 bars ago) Experimental

MQL5 → Cuprel · converter mql5 0.2.0 · converted · 3 lines out

Source (MQL5)
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_plots 1
#property indicator_type1 DRAW_LINE
double Mom[];
int OnInit() {
  SetIndexBuffer(0, Mom, INDICATOR_DATA);
  return(INIT_SUCCEEDED);
}
int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) {
  ArraySetAsSeries(close, false);
  ArraySetAsSeries(Mom, false);
  for (int i = 10; i < rates_total; i++) {
    Mom[i] = close[i] - close[i - 10];
  }
  return(rates_total);
}
Converted (Cuprel)
indicator("Converted indicator", edition = 1, overlay = false)
plot((if bar.index < 10 then na else (close - close[10])), name = "Mom")

Known differences

Experimental means: the converter reads a thin, tested slice, adds warnings, and says no when it is unsure. Run the converted program on your own data before relying on it.

Open in the converter MQL5 → Cuprel route All examples