Rebuild a CCI reading from five candles

Rebuild a CCI reading from five candles

Start with the candle under the cursor

Attach Commodity Channel Index to a chart, set the period to 5 and choose Typical Price. Open the Data Window and point to a closed candle. Record the high, low and close for that candle and its four predecessors, oldest first. Keep more decimals than the indicator displays. Typical price gives the high, low and close equal weight; substituting the close alone changes both the centre and the distance from it.

Build the denominator first

Use synthetic typical prices 98, 99, 100, 101 and 102. Their mean is 100. Measure each price against this same mean; the five absolute distances sum to 6. Dividing by 5 gives 1.2. A spreadsheet that takes a separate trailing mean at each row will quietly answer a different question. Strip out intermediate rounding and keep a column of the five distances so this mistake is visible.

CCI = (TP − mean(TP)) / (0.015 × mean(|TP − mean(TP)|))

Explain the final reading

The final price sits 2 units above the mean. Divide that distance by 0.015 times 1.2 to get about 111.11. Now replace the window with 96, 100, 100, 102 and 102. The mean and final price are unchanged, but the distances sum to 8. The new reading is about 83.33. The drop through 100 came entirely from the spread of the observations; there was no fall in the final price.

Check a disagreement at its source

Compare the intermediate values in order: timestamp, applied price, mean, mean absolute deviation, final rounding. Using a standard deviation function changes the denominator even on the first example. If all five prices are identical the expression has a zero denominator. Flag that row separately and inspect your terminal's convention before treating any displayed zero as a genuine crossing.

Take the result back to a chart

Pick one closed candle near a threshold and the next closed candle. Slide the window by exactly one row. Mark both the outgoing price and the incoming price. If the threshold crossing disappears when you accidentally keep the old mean, you have found a windowing error. Save the two timestamped worksheets with the symbol and timeframe so a second reader can reproduce the comparison.

Practice files

These CSV files contain synthetic teaching data, not market observations or investment results.

Download the CSV

Sources and further reading

Back to top

MQLume Bespoke

Built around your ambition.

Explore bespoke services →

Have something more specific in mind?

Ask us about advanced custom development. Share your requirements through private support or email; we will discuss the scope and quote separately.

100% committed to following up on your delivery and support requests.

Free downloads. Real source files.

FREE

Lizard [MQLume]

MQL5 / MT5Version v2.21

Free editable gold breakout project with six independently selectable cores, session filters and flexible position sizing.

US$149.00FREE
FREE

Scraper Gold [MQLume]

MQL5 / MT5Version v3.80

Free editable source with compiled EX5: four gold breakout engines with independent profiles, sizing, direction and exits.

US$95.00FREE
FREE

EA Black Dragon [MQLume]

MQL5 / MT5Version v13.0

Trend-based entries with optional grid additions, side controls and virtual exits.

US$30.00FREE
FREE

Hamster Scalping [MQLume]

MQL5 / MT5Version v21.0

RSI entries with two ATR filters, configurable sessions and optional grid management.

US$30.00FREE
MQLume

More to explore. A community to share it with.

Stay close to MQLume, wherever you like to learn.

YouTube

See our EAs in action. Explore backtests, walkthroughs and practical guides.

Watch on YouTube

Telegram

Meet other EA users, share ideas and keep up with what’s new.

Join the community Follow official updates

Cart

One personal-use licence per project. Each project can be added once.

Your cart is waiting for its first passenger.

Choose an EA or source edition to get started.

Continue shopping