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
- the indicator has no title in a form this converter reads: it is called "Converted indicator" (rename it in the editor)
- the bars before the loop start are unassigned buffer elements in the source; the converted indicator draws nothing there (what the platform draws for them depends on its empty-value default, which is not documented)
- the platform recalculates the forming bar on every tick; the converted indicator follows the product language (the forming bar can differ)
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.