Consecutive Candle Counter
Walks the closed-bar history and, for every bar, counts how long the current same-direction run has been going: a third bullish bar in a row reads 3, a fifth bearish bar in a row reads -5. Bullish streaks plot as blue bars above the zero line, bearish streaks as red bars below it, so an extended run is visible as a tall bar without reading the number. A bar whose close equals its open (a perfect doji) breaks whatever streak was running without starting a new one in either direction - it is genuinely neither bullish nor bearish, and counting it as one would misstate how long the run actually was. Notes and limitations - Each bar's streak length depends on every older bar in the same run, so this indicator recomputes the full visible history on every call rather than doing a partial incremental update - a deliberate simplification that keeps the run-counting logic simple and unquestionably correct at the cost of doing more work than strictly necessary on each tick. On any history length a terminal can reasonably hold, the cost is not noticeable. - This counts direction only, not size - five small bullish bars in a row and one large bullish bar read very differently on a price chart but can produce the same streak count here. Combine with a range or body-size read if that distinction matters to your use case. - Uses no chart objects - both plots are ordinary indicator buffers with nothing to clean up in OnDeinit.
Indicator · MT5 · v1.0 · Free
About Consecutive Candle Counter
Consecutive Candle Counter is an indicator for MetaTrader 5. It can alert you with a pop-up, sound, email or push message. It has 2 settings, such as Alert streak and Alerts. MQL source code included.
Files in the download: ConsecutiveCandles.ex5, ConsecutiveCandles.mq5, ConsecutiveCandles.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Alert streak | 5 | Alert once a streak reaches this length |
| Alerts | true | Alert once per closed bar on a new qualifying streak |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Indicators.
- Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
- Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the indicator from the Navigator onto a chart and adjust the settings.
Tags: Alerts · MT5 Indicator · MQL5 Source Code