Ich habe auch eine Serienversion kodiert
das Code-Styling ist die "Mozilla"-Auswahl in MetaEditor
#property indicator_separate_window #property indicator_buffers 5 #property indicator_plots 1 #property indicator_color1 clrGreen, clrRed #property indicator_type1 DRAW_COLOR_HISTOGRAM double plot[]; double col[]; double incomingVolume[]; double ma[]; double closes[]; input bool grannularTrend = false; // Grannularer Trend int period = 20; //+------------------------------------------------------------------+ //| Benutzerdefinierte Initialisierungsfunktion für Indikatoren | //+------------------------------------------------------------------+ int OnInit() { //--- Zuordnung von Indikatorpuffern SetIndexBuffer(0, plot, INDICATOR_DATA); SetIndexBuffer(1, col, INDICATOR_COLOR_INDEX); SetIndexBuffer(2, ma, INDICATOR_CALCULATIONS); SetIndexBuffer(3, incomingVolume, INDICATOR_CALCULATIONS); SetIndexBuffer(4, closes, INDICATOR_CALCULATIONS); ArraySetAsSeries(plot, true); ArraySetAsSeries(col, true); ArraySetAsSeries(ma, true); ArraySetAsSeries(incomingVolume, true); ArraySetAsSeries(closes, true); return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Benutzerdefinierte Indikator-Iterationsfunktion| //+------------------------------------------------------------------+ 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); ArrayCopy(incomingVolume, tick_volume, 0, rates_total-1); ArrayCopy(closes, close, 0, rates_total-1); int buffSize = ArraySize(incomingVolume); ArraySetAsSeries(close, true); if(prev_calculated == 0) { initialzeBuffers(); } long volumeThreshold = 0; long sum = 0; for (int j = 0; j < period; j++) sum += tick_volume[j]; volumeThreshold = sum / 20; int empty_data = rates_total - buffSize; for(int i = buffSize-1; i>=empty_data; i--) { plot[i] = incomingVolume[i]; trend(period, i, ma, closes); if (i < buffSize - 1) { if (!grannularTrend) { col[i] = ma[0] > ma[1] ? 0 : 1; } else { col[i] = (ma[i] > ma[i+1]) ? 0 : 1; } } } for(int i = buffSize-2; i>=0; i--) { closes[i+1] = closes[i]; incomingVolume[i+1] = incomingVolume[i]; } return buffSize; } void initialzeBuffers(){ ArrayInitialize(plot, EMPTY_VALUE); ArrayInitialize(col, EMPTY_VALUE); ArrayInitialize(ma, EMPTY_VALUE); ArrayInitialize(incomingVolume, EMPTY_VALUE); ArrayInitialize(closes, EMPTY_VALUE); } void trend(int per, int idx, double &arr[], const double &close[]) { double sum = 0.0; for(int k = 1; k < per && (idx + k) < ArraySize(close); k++) { sum += close[idx + k]; } arr[idx] = sum / per; }
Sie verpassen Handelsmöglichkeiten:
- Freie Handelsapplikationen
- Über 8.000 Signale zum Kopieren
- Wirtschaftsnachrichten für die Lage an den Finanzmärkte
Registrierung
Einloggen
Sie stimmen der Website-Richtlinie und den Nutzungsbedingungen zu.
Wenn Sie kein Benutzerkonto haben, registrieren Sie sich
Intrabar Volume Flow:
Ein Indikator, der die zeitliche Entwicklung des Volumens innerhalb jedes Balkens visualisiert. Er zeigt das Tick-Volumen in einem rollierenden Histogramm-Format an.
Author: Conor Mcnamara