//+------------------------------------------------------------------+
//| 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
//--- gösterge tamponları
double InvisibleBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- Gösterge tamponunun dizi ile bağlanması
SetIndexBuffer(0,InvisibleBuffer,INDICATOR_DATA);
//--- Veri Penceresinde görüntülenecek değerlerin kesinliğini ayarla
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;
//--- Eğer bu göstergenin ilk hesaplanışı ise
if(prev_calculated==0)
{
//--- Çubukları ilk sefer için yeniden numarala
CalcValues(rates_total,close);
//--- Mevcut çubuğun lastbar içindeki açılış zamanını hatırla
lastbar=(datetime)SeriesInfoInteger(_Symbol,_Period,SERIES_LASTBAR_DATE);
}
else
{
//--- Eğer yeni bir çubuk oluşmuşsa, bunun açılış zamanı lastbar'dan farklı olacak
if(lastbar!=SeriesInfoInteger(_Symbol,_Period,SERIES_LASTBAR_DATE))
{
//--- Çubukları bir kez daha numarala
CalcValues(rates_total,close);
//--- Mevcut çubuğun lastbar içindeki açılış zamanını güncelle
lastbar=(datetime)SeriesInfoInteger(_Symbol,_Period,SERIES_LASTBAR_DATE);
}
}
//--- bir sonraki çağrı için prev_calculated değerine dönüş yap
return(rates_total);
}
//+------------------------------------------------------------------+
//| Çubukları zaman serilerindeki gibi indisle |
//+------------------------------------------------------------------+
void CalcValues(int total,double const &array[])
{
//--- Gösterge tamponunun indisleme yönünü zaman-serilerindeki gibi yap
ArraySetAsSeries(InvisibleBuffer,true);
//--- Her çubuğu kendi numarasıyla doldur
for(int i=0;i<total;i++) InvisibleBuffer[i]=i;
}
|