Candle Counter - MetaTrader 5 Script | Forex Indicator Download - MT4/MT5 Resources - MetaTrader 5 Resources

Weekly selection :
The SelectedWeek parameter defines which week of the month is numbered.
If SelectedWeek = 0, all weeks are considered and all candles will be numbered.
For non-zero values, only candles of the specified week are numbered.
When NumberFirstCandle = false, numbering starts with the last candle of the day and proceeds backwards.
Dynamic filtering :
The indicator filters candles based on the selected week ( SelectedWeek ) and ignores other weeks.
Dynamic text positioning :
These numbers are located above or below the candle, depending on whether the candle is bullish or bearish.
The spacing between text and candlesticks is controlled by the PriceOffsetFactor parameter.
Visual customization :
Colors, fonts, text size, and anchor type can be adjusted to enhance the appearance.
Optimize performance :
The indicator deletes old chart objects before creating new ones, ensuring there is no unnecessary overhead on the chart.
price offset coefficient
Dynamic spacing factor between text and candle.
Enter text color above
The color of the text above the candle (for bullish candles).
InpTextColourBelow
The color of the text below the candle (for bearish candles).
clr orchid
The font type used to display numbers.
The type of anchor point used to position the text (center, top, bottom, etc.).
Numbers first candle
Defines whether counting starts from the first candle of the day ( true ) or the last candle ( false ).
Select the week to count (0 = every week).
1. Filter by week
The GetWeekOfMonth() function calculates the week of the month for each candlestick.
The condition if(SelectedWeek != 0 && currentWeek != SelectedWeek) ensures that only the candles of the selected week are processed.
2. Sequential counting
Whenever the date changes (candleDay! = previousDay), the counting starts again.
If NumberFirstCandle = true , counting starts from the first candle of the day.
If NumberFirstCandle = false , counting starts with the last candle of the day and continues backwards.
3. Text positioning
If the closing price is lower than the opening price (bearish candle), the text is above the candle.
If the closing price is higher than the opening price (bullish candle), the text is below the candle.
4. Create and update chart objects
The CreateText() function creates or updates a chart object on the chart.
These objects are uniquely named using the ObjectPrefix to avoid conflicts.
5. Automatic cleaning
When deleting or reinitializing an indicator, the DeleteObjects() function deletes all graphical objects created by the indicator.

Attachment download
📎 candle_counter.mq5 (19 KB)
Source: MQL5 #56432
💡 Featured Recommendations
✍️ Latest by the author
- •
- •
- •
- •
- •
- •
📌 Popular topics
- •
- •
- •
- •
- •
- •
- •
- •
🔗 You May Be Interested In
- •
- •
- •
- •
- •
- •