Voir comment télécharger gratuitement des robots de trading
Retrouvez-nous sur Facebook !
Rejoignez notre page de fans
Un script intéressant ?
Poster un lien vers celui-ci -
laisser les autres l'évaluer
Vous avez aimé le script ? Essayez-le dans le terminal MetaTrader 5
Indicateurs

Candle Countdown Timer and Spread Display on Chart - indicateur pour MetaTrader 5

Vues:
44
Note:
(1)
Publié:
MQL5 Freelance Besoin d'un robot ou d'un indicateur basé sur ce code ? Commandez-le sur Freelance Aller sur Freelance

Candle Countdown Timer and Spread Display on Chart

The idea behind it

Two pieces of information matter to many traders at the moment of a decision: how long until the candle closes, and how much the broker charges as spread right now. Many strategies act on closed candles, and the last seconds before the close are often the most active. A wide spread, on the other hand, can turn a good setup into a bad trade, especially during news, rollover or low liquidity.

This indicator puts both values on the chart in a clear, configurable text block. It uses a one-second timer for the countdown, so the display keeps running during quiet periods when ticks come rarely. It reads only the open time of the last bar and does not scan the history.

How to interpret it

  • Candle label - time left until the current candle closes. The format adapts to the timeframe: MM:SS under one hour, HH:MM:SS from one hour, and Nd HH:MM:SS when a day or more remains (D1, W1 and MN1 charts).
  • Spread label - the current difference between Ask and Bid, in points or in pips depending on InpSpreadUnit. With the pip unit, 1 pip equals 10 points on 3- and 5-digit symbols.
  • Warning color - if InpSpreadWarnLevel is greater than zero and the spread (in points) exceeds it, the spread label changes to InpWarnColor. This is a quick visual alert that trading conditions have worsened.
  • Position - the labels are stacked from the selected chart corner, so they do not move when you scroll or zoom the chart.

External variables (inputs)

Input Default Purpose
Display
InpShowCountdown true Show the candle countdown timer
InpShowSpread true Show the current spread
InpSpreadUnit SPREAD_POINTS Spread unit: SPREAD_POINTS or SPREAD_PIPS
InpSpreadWarnLevel 0 Spread warning level in points; 0 disables the warning
Position
InpCorner CORNER_RIGHT_UPPER Chart corner where the labels are placed
InpXDistance 10 Horizontal distance from the corner in pixels (0 and above)
InpYDistance 20 Vertical distance from the corner in pixels (0 and above)
Font and colors
InpFontName Consolas Font name; a monospaced font keeps the countdown from jittering
InpFontSize 12 Font size (6 to 40)
InpTextColor clrWhite Color of the labels
InpWarnColor clrTomato Color of the spread label when it exceeds the warning level

Recommended use

  • Works on any symbol and any timeframe. Set the text color so that it contrasts with your chart background.
  • The countdown uses the trade server time ( TimeTradeServer() ), so it keeps running between ticks. Its accuracy depends on the synchronization of your terminal clock with the server, normally within about a second.
  • When the market is closed (weekends, holidays) no new bar appears, so the countdown stays at zero after the expected close time.
  • On MN1 charts the length of the month is approximated by the terminal ( PeriodSeconds() ), so the countdown is approximate.
  • The spread is taken from the current Ask and Bid prices, so it follows floating spreads. Commissions charged by ECN or raw-spread accounts are not included in it.
  • Choose the warning level according to the symbol: a few points for major Forex pairs, more for metals, indices or exotic pairs.
  • The indicator creates two labels with the prefix CdSp_ and removes them, together with the timer, when it is deleted from the chart.
  • It does not trade, so it works the same on netting and hedging accounts.


Fig. 1. CandleTimerSpread on an M15 chart with default settings (black and white image per Code Base guidelines).

ATR Dynamic Support and Resistance Bands ATR Dynamic Support and Resistance Bands

Dynamic support and resistance bands built from a moving average and the Average True Range (ATR). The bands widen when volatility rises and narrow when it falls.

Supertrend EA Gold Breakeven Supertrend EA Gold Breakeven

Supertrend expert advisor for MT5 on Gold (XAUUSD), forex and indices: entry on the closed candle of the flip, stop at the Supertrend line, target by stop multiple, breakeven and lot by risk percent. Open source code.

Supertrend Indicator with Trend Color Change Supertrend Indicator with Trend Color Change

Supertrend trend-following indicator based on ATR. The line changes color and side of the price when the trend changes, with optional signal arrows and alerts.

Daily Open Line with Distance in Points Daily Open Line with Distance in Points

Draws the daily open price as a horizontal line and shows, in points, how far the current price is from today's open. The label changes color depending on whether the price is above or below the open.