Auto Trendline Drawer
Manual trendlines drift the moment you stop watching the chart: a new low prints, the old line no longer fits, and it sits there stale until someone redraws it. This indicator keeps two lines current on its own - one support, one resistance - and only touches them again when a swing that actually changes the fit gets confirmed. "Confirmed" is the operative word. A swing point is a fractal-style extreme with InpSwingBars bars closed on both sides, so a line never anchors to a bar that can still be overtaken by the next tick. That means every line you see is InpSwingBars bars behind the live edge of the market by construction - this is a structural lag, not a repaint, but it is a delay and the two should not be confused when you are reading the chart. A second filter matters as much as the confirmation delay. A line through two swing lows is only kept if the older low sits beneath the newer one - if it does not, that pair does not describe an uptrend and drawing a line through it would just be noise dressed up as support. The mirror rule applies to resistance. When no valid pair exists yet, the indicator simply does not draw that side rather than forcing a line through a shape that is not there. Lines are rebuilt, not accumulated: each redraw moves the same two named objects rather than adding a new trendline on top of the old one, so the chart never fills up with stale lines from six swings ago. Notes and limitations - Needs two confirmed swing lows and two confirmed swing highs before either line can be drawn - on short history, or in a market making new highs or lows without a second confirmed touch, one or both lines may simply be absent. That is by design, not a bug. - Every anchor is InpSwingBars bars old at best. Do not read either line as a real-time signal of the current swing forming on the very edge of price. - Only one support and one resistance line exist at a time. Historical trendlines are not kept or drawn once superseded. - A pair of swings that does not slope the expected way (support sloping down, resistance sloping up) is deliberately not drawn - the absence of a line on one side does not mean price lacks structure, only that this indicator did not find a valid trend pair for it yet. - Alerts fire once per crossing closed bar, gated by bar time, so removing and reattaching the indicator will not spam duplicate alerts for a crossing already reported.
Indicator · MT4 · v1.0 · Free
About Auto Trendline Drawer
Auto Trendline Drawer is an indicator for MetaTrader 4. It can alert you with a pop-up, sound, email or push message. It has 6 settings, such as Swing bars, Support color and Resist color. MQL source code included.
Files in the download: AutoTrendlines.ex4, AutoTrendlines.mq4, AutoTrendlines.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Swing bars | 5 | Bars required on each side to confirm a swing |
| Support color | clrLime | Support (uptrend) line colour |
| Resist color | clrRed | Resistance (downtrend) line colour |
| Line width | 2 | Line width |
| Extend bars | 60 | Bars to extend the line to the right |
| Alerts | true | Alert when a closed bar crosses an active line |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Indicators.
- Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
- Open the .mq4 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: Support & Resistance · Fractals · Alerts · Trend · MT4 Indicator · MQL4 Source Code