EndPointAverage
EndPointAverage[N](price) in ProBuilder returns the end point moving average over N bars, a least-squares based average that reduces lag for trend analysis.
Syntax
EndPointAverage[N](price)Parameters
| Name | Type | Default | Description |
|---|---|---|---|
N | integer | none | Number of bars in the regression window. Larger values give a smoother, slower line. |
price | price source | close | Series the average is computed on, for example close, open, high, or low. |
Formula
Fit a least-squares line y = a + b * x to the last N values of price
EndPointAverage = value of that line at the most recent barInstead of averaging the window symmetrically, the end point method projects the fitted trend line to the newest bar, which is why the line hugs price more closely than a simple average.
How it works
A simple moving average reports the mean of the window, which effectively describes price as it was half a window ago. The end point average removes much of that delay by fitting a straight regression line through the same window and returning where that line ends, at the current bar. When price trends steadily, the end point average sits close to price; when price is flat, it behaves like an ordinary average.
The trade-off is overshoot. Because the value extrapolates the window's slope to its edge, sharp reversals make the line overshoot the turn before catching up. This makes the end point average responsive in trends but twitchier than smoother averages around turning points.
This calculation is also the moving average selected by MAtype = 5 in indicators that take a moving average type parameter, such as ElderRayBullPower.
Examples
Example 1, Trend slope from the end point average (Indicator)
// Endpoint of a 50-period regression on the close
i1 = EndPointAverage[50](close)
// Ratio of the current value to its value 10 bars ago
slope = i1 / i1[10]
RETURN slopeComputes the 50-period end point average and divides it by its own value 10 bars back. A ratio above 1 means the line has risen over the last 10 bars, a compact trend-strength gauge.
Example 2, Price crossing the end point average (ProBacktest)
// Trend-following entries on crosses of a 30-period end point average
epma = EndPointAverage[30](close)
IF NOT OnMarket THEN
IF close CROSSES OVER epma THEN
BUY 1 CONTRACT AT MARKET
ENDIF
ELSIF LongOnMarket THEN
IF close CROSSES UNDER epma THEN
SELL AT MARKET
ENDIF
ENDIFUses the end point average as a dynamic trend line. The reduced lag produces earlier crosses than a simple average of the same period.
Example 3, Screening for price above a rising line (ProScreener)
epma = EndPointAverage[50](close)
// Price above the line and the line itself rising
SCREENER[close > epma AND epma > epma[5]](epma AS "EPMA 50")Lists instruments trading above a 50-period end point average that has risen over the last 5 bars, a two-part uptrend filter.
Interpretation
As with any moving average, the two standard readings are position and slope. Price above a rising end point average supports a bullish bias, price below a falling line supports a bearish one. Crossovers between price and the line, or between a short and a long end point average, are used as trend-change signals.
Because the line reacts faster than a simple or exponential average of equal length, it suits trend-following logic where lag is costly. In choppy, range-bound markets the same responsiveness generates more false crossings, so a longer period or an additional filter is advisable there.
Common errors and gotchas
- Overshoot at reversals. The value extrapolates the window's regression slope, so it can briefly continue in the old direction, or exaggerate the new one, right after a sharp turn. Signals taken at V-shaped reversals are less reliable than in steady trends.
- Wrong bracket type. The period belongs in square brackets and the price source in parentheses:
EndPointAverage[50](close).EndPointAverage(50, close)raises a syntax error. - Confusing it with a simple average endpoint. The name refers to the endpoint of a fitted regression line, not the last element of an averaging window. Comparing it 1:1 with
Average[N]values leads to misread distances. - Period longer than available history. With fewer than
Nbars loaded, early values are unreliable. Ensure the chart or backtest preloads enough bars before acting on the line.
Related instructions
LinearRegression, the regression line value the end point method is built on.LinearRegressionSlope, slope of the fitted regression line.TimeSeriesAverage, closely related regression-based average, MAtype 6.Average, simple moving average for comparison.ExponentialAverage, exponentially weighted alternative.WeightedAverage, linearly weighted alternative.HullAverage, another low-lag moving average design.ZLEMA, zero-lag exponential moving average.
