Page 1 of 1

A custom spread indicator that paints the background when too wide

Posted: Wed Oct 21, 2026 9:29 pm
by FXS London Scalper
A visual cue on the chart helps avoid entering when spread is wide. An indicator that changes the chart background colour when spread exceeds a threshold is simple and effective.

Logic:
- On each tick, calculate spread.
- If spread > threshold, set chart background to a warning colour.
- If spread < threshold, restore normal background.

MQL5 snippet:

Code: Select all

void OnTick() {
   double spr = (SymbolInfoDouble(_Symbol,SYMBOL_ASK) - SymbolInfoDouble(_Symbol,SYMBOL_BID)) / _Point;
   color bg = (spr > MaxSpreadPts) ? clrMaroon : clrBlack;
   ChartSetInteger(0, CHART_COLOR_BACKGROUND, bg);
}
(For an indicator, use OnCalculate instead of OnTick.)

Refinements:
- Different thresholds by hour.
- Gradual colour change (yellow, orange, red).
- Display current spread as a label.

This kind of visual cue works because it's impossible to miss, unlike a number in the corner.

Does anyone use something similar? Share your version.