Rates in a custom indicator. What do they count?

 

what do they count? do they count every variation of price on every tick, or on each bar?


for example here:

#property indicator_separate_window
#property indicator_minimum 1
#property indicator_maximum 100
#property indicator_buffers 1
#property indicator_plots   1
//--- plot TII
#property indicator_label1  "TII"
#property indicator_type1   DRAW_LINE
#property indicator_color1  clrRed
#property indicator_style1  STYLE_SOLID
#property indicator_width1  1
//--- input parameters
input int      MA;
input double   PriceDesviations;
//--- indicator buffers
double         TIIBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0,TIIBuffer,INDICATOR_DATA);
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const int begin,
                const double &price[])
  {
//---
   
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
 
Javier Santiago Gaston De Iriarte Cabrera:

what do they count? do they count every variation of price on every tick, or on each bar?


for example here:

I've seen that on OnCalculate, it counts each variation on tick, but, how do I do an indicator that counts on each time period bar?

 

Bars


rates_total parameter represents the total number of bars on the chart

prev_calculated parameter indicates the number of bars that have been calculated in the previous call of the OnCalculate function

begin parameter indicates the index of the first bar to be calculated in the current call

price array contains the price data for the bars

 
Javier Santiago Gaston De Iriarte Cabrera #:

I've seen that on OnCalculate, it counts each variation on tick, but, how do I do an indicator that counts on each time period bar?

Actually, if you want to count ticks you use for loops within OnCalculate.


    // Iterate over each bar
    for (int i = prev_calculated; i < rates_total; i++)
    {

        // Count ticks within the bar
     
    }
 
phade #:

Actually, if you want to count ticks you use for loops within OnCalculate.


Thanks