How to calculate CCI from current price

 

I wonder how MetaTrader calculates the current value of CCI (i.e. the value based on current price).

Let's suppose we have prices from timeframe T. The last closed bar is closed at time j. The formula for CCI calculation is:

(where M is period for SMA and stdev, TP is typical price).

When I calculate CCI value for current price i, i.e. the last bar belongs to one of those intervals:

a) from j to i

or

b) from i-T to i

I get very often a big discontinuity right after time j that is not what I usually see in Metatrader.

I am a newbie with MQL so cannot read this information from the MQL file (I use Python for my calculations).

Can you help me?

 
uelel:

I wonder how MetaTrader calculates the current value of CCI (i.e. the value based on current price).

https://docs.mql4.com/indicators/icci

https://www.mql5.com/files/docs/mt5/mql5/chm/mql5.chm

https://docs.mql4.com/indicators/icci

iCCI - Technical Indicators - MQL4 Reference
iCCI - Technical Indicators - MQL4 Reference
  • docs.mql4.com
iCCI - Technical Indicators - MQL4 Reference
 

Now I can transform my question like this:

Let's say we have time 15:24. We run an indicator with 1 hour rates. What are the times of prices passed in price array into OnCalculate function?

a) 15:24, 14:24, 13:24...

b) 15:24, 15:00, 14:00...

 

To answer my question: b is correct. I recorded prices and CCI over time and at the beginning of the new bars there are leaps of CCI values.

Reason: