The non repaint buy sell indicator draws one line, called Non. It fits a short least-squares regression to the last Period closes. Every bar gets a fresh fit, and the plotted value locks in once its bar closes. It suits a trader who wants a single slope-based line to read direction from.
This build ships as non-repaint-buy-sell-indicator-indicator-forexmt4systems.ex4 for MT4 and non-repaint-buy-sell-indicator-indicator-forexmt4systems.ex5 for MT5; the screenshots below come from EURUSD H1.
| Platforms | MT4 (.ex4) + MT5 (.ex5) |
|---|---|
| Chart window | Main price chart |
| Plots | 1: Non |
| Alerts | popup, push notification, email, sound |
| Inputs | 7 |
What the Non Repaint Buy Sell Indicator draws on the chart
Non (indian red) is the only plotted line. It is the least-squares regression value fitted to the last Period closes.
- Non: plot, indian red

How the Non Repaint Buy Sell Indicator calculates its values
Fitting the regression window
Non comes from one fit per bar. For every bar i, the code loops across a Period-wide window of k values, reading close[i – k] as y against x = k.
It sums sx, sy, sxy and sxx, the four totals a least-squares fit needs. The window sets x = 0 at the newest bar, so the intercept alone becomes the value the code stores.
Crossover alert logic
After the fit runs, a separate block compares the two most recently closed bars against Non. A BUY message needs close two bars back at or below Non, and close one bar back strictly above it.
A SELL message mirrors that, with price crossing down through Non instead. Both checks run only once per newly closed bar, guarded by a stored timestamp.
Recalculating as new bars close
The scan does not redo the whole chart on every tick. It fits from Period forward on the first run, then only extends onto bars prev_calculated has not reached yet.
Nothing about an already-set Non value changes later. Each bar’s fit depends only on the Period closes behind it, and those closes never move once a bar is done.
How to read the signals
Price crossing from at or below Non to above it is the bullish read. The alert logic confirms that on the last two closed bars.
Price crossing from at or above Non to below it is the bearish mirror of that same check.
Period is only 7 bars by default, so Non tracks price closely. It can flip direction several times inside a choppy session.
The indicator only recomputes from the newest bar forward on each tick. Older parts of the Non line never redraw once the code has set them.
Alert channels in this build: popup, push notification, email and sound, one message per closed bar.
EnableAlerts turns on popup, push, email and sound alerts together, firing at most once per newly closed bar through the stored alert-bar guard.
Every Non Repaint Buy Sell Indicator input
Core settings
| Setting | What it does | Default |
|---|---|---|
Period |
Period sets how many closes feed the least-squares fit. It defaults to 7. Raising it smooths Non into a slower, less reactive line. The window always uses the most recent Period closes, so it slides forward one bar at a time as new bars form. | 7 |
Alert settings
| Setting | What it does | Default |
|---|---|---|
EnableAlerts |
(see inputs panel) | on |
EnablePopup |
(see inputs panel) | on |
EnablePushNotify |
(see inputs panel) | off |
EnableEmail |
(see inputs panel) | off |
EnableSound |
(see inputs panel) | off |
SoundFile |
(see inputs panel) | alert.wav |

Settings that fit your chart
The screenshot pair is EURUSD on H1, where a 7-bar window reacts fast enough to catch short intraday swings. The regression math only reads recent closes, so the same logic runs on any symbol and timeframe MT4 and MT5 support. A short window like 7 bars will cross more often on lower timeframes. A trader who wants a slower read can raise Period well past 7 without touching anything else in the setup.
When the Non Repaint Buy Sell Indicator fails
A 7-bar least-squares fit is short. It can whipsaw across its own line several times during one ranging session, so the crossover alert can fire without leading anywhere.
The fit only uses closes and ignores wicks. A bar with a long wick and a small body can still trigger a cross, even when price never closed decisively on one side.
The buffer only stores the intercept of the fit, not its slope. Two windows with very different steepness can still end near the same Non value on a given bar.
The fit treats every bar in the window the same way. A single outlier bar near the edge of the window can pull the line as much as several ordinary bars combined.
Copy non-repaint-buy-sell-indicator-indicator-forexmt4systems.ex4 into MQL4/Indicators and non-repaint-buy-sell-indicator-indicator-forexmt4systems.ex5 into MQL5/Indicators, then restart the terminal and drag the Non Repaint Buy Sell Indicator onto a chart. The step-by-step guide with screenshots is at how to install MT4 and MT5 indicators.
Background reading on the method behind the Non Repaint Buy Sell Indicator: Royalty fund on Wikipedia, igator (GATOR) at the MQL5 Documentation.
Download the Non Repaint Buy Sell Indicator for MT4 and MT5
The zip non-repaint-buy-sell-indicator-indicator-forexmt4systems.zip holds non-repaint-buy-sell-indicator-indicator-forexmt4systems.ex4, non-repaint-buy-sell-indicator-indicator-forexmt4systems.ex5 and a short README, compiled files only. Enter your email below and the download link arrives in your inbox.
Download this indicator free
Enter your email and the file is yours. You also get the full MT4 and MT5 library.
FAQ
Why does the Non line use a 7-bar window instead of a longer one?
The window size comes from Period, which defaults to 7. A short window like that keeps the fit close to price, so Non reacts fast to a fresh slope change. A wider window pulls in more history, trading that speed for a steadier, slower line with fewer false crosses. The window always uses the freshest data available, since Period counts back from the current bar on every recalculation.
How is the Non line different from a simple moving average?
Non is not an average of prices. It is the endpoint of a straight line fitted through the last Period closes by ordinary least squares. That factors in the slope of recent price action rather than just summing and dividing closes, so it can turn a little sooner than a plain SMA of the same length. Both approaches use the last Period bars of data, but the fit weighs the whole window’s shape rather than collapsing it to one number.
When does the crossover alert fire on this indicator?
The alert block checks the two most recently closed bars. It fires a BUY message when price sat at or below Non on the older bar. It closes above Non on the newer one. A SELL message fires on the mirrored downward cross. Both checks run only once per newly closed bar. Nothing in the fit gives extra weight to the newest bar over the oldest one in the window, aside from where each sits on the x axis.
Why can’t the crossover alert flip after it has already fired?
The alert logic only looks at the two most recently closed bars. It compares close two bars back against Non at that same bar. It compares close one bar back against Non one bar back. Neither value can change once those bars close, so a fired BUY or SELL will not repaint later. A trader who prefers fewer, later signals can lengthen Period instead of watching every small wiggle near the line.
Does the Non line ever plot on the bar that is still forming?
No. Every calculation in the code, the fit itself and the crossover check, only touches closed bars. The still-forming bar never contributes a value to sx, sy, sxy or sxx, and the alert block only compares bars that have already printed a final close. That is what keeps a fired BUY or SELL from disappearing partway through the next candle.
Are results guaranteed?
No. Trading involves risk. Results are not guaranteed; past performance is not indicative of future results. Use the Non Repaint Buy Sell Indicator as one input. Always backtest before trading live.
Category: this is part of our Signal and Forecast collection. Browse more Signal and Forecast for MetaTrader, or explore every MT4 indicator and MT5 indicator on the site.
External references
- Learn more about the underlying method in Royalty fund on Wikipedia.
- For wider market background, see igator (GATOR) at the MQL5 Documentation.
