Loading…

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 · MT4 · v1.0 · Free

About Consecutive Candle Counter

Consecutive Candle Counter is an indicator for MetaTrader 4. 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.ex4, ConsecutiveCandles.mq4, ConsecutiveCandles.txt.

Settings

SettingDefaultWhat it does
Alert streak5Alert once a streak reaches this length
AlertstrueAlert once per closed bar on a new qualifying streak

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Indicators.
  3. Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
  4. Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the indicator from the Navigator onto a chart and adjust the settings.

Download the PDF guide

Tags: Alerts · MT4 Indicator · MQL4 Source Code

MetaTrader 4 & 5 indicators · PolyMaria