//+------------------------------------------------------------------+ //| DRAW_NONE.mq5 | //| Copyright 2000-2024, MetaQuotes Ltd. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2000-2024, MetaQuotes Ltd." #property link "https://www.mql5.com" #property version "1.00" #property indicator_chart_window #property indicator_buffers 1 #property indicator_plots 1 //--- plot Invisible #property indicator_label1 "Bar Index" #property indicator_type1 DRAW_NONE #property indicator_style1 STYLE_SOLID #property indicator_color1 clrRed #property indicator_width1 1 //--- indicator buffers double InvisibleBuffer[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- Bindung vom Array und Indikator-Puffer SetIndexBuffer(0,InvisibleBuffer,INDICATOR_DATA); //--- Wir stellen die Genauigket, mit der der Wert in Data Window angezeigt werden IndicatorSetInteger(INDICATOR_DIGITS,0); //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ 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[]) { static datetime lastbar=0; //--- Wenn dies die erste Berechnung des Indikators ist if(prev_calculated==0) { //--- Durchnumerieren Balken zum ersten Mal CalcValues(rates_total,close); //--- Speichern Öffnungszeit des aktuellen Balkens in lastbar lastbar=(datetime)SeriesInfoInteger(_Symbol,_Period,SERIES_LASTBAR_DATE); } else { //--- Wenn ein neuer Balken erscheint hat, sien Öffnungszeit fällt nicht mit lastbar zusammen if(lastbar!=SeriesInfoInteger(_Symbol,_Period,SERIES_LASTBAR_DATE)) { //--- Durchnummerieren Balken noch einmal CalcValues(rates_total,close); //--- Aktuallisieren Öffnungszeit des aktuellen Balkens in lastbar lastbar=(datetime)SeriesInfoInteger(_Symbol,_Period,SERIES_LASTBAR_DATE); } } //--- return value of prev_calculated for next call return(rates_total); } //+------------------------------------------------------------------+ //| Numeriert Balken wie in Zeitreihen | //+------------------------------------------------------------------+ void CalcValues(int total,double const &array[]) { //--- Wir definieren Indexierung des Indikator-Puffers als in Zeitreihen ArraySetAsSeries(InvisibleBuffer,true); //--- Wir füllen Nummer jedem Balken for(int i=0;i<total;i++) InvisibleBuffer[i]=i; } |