## Standard Error Bands

Here you can post and download custom indicators. PLEASE: Do not start topics unless you are posting your own indicator, they will be moved to appropriate section even if you do.

### Standard Error Bands

Smoothed Linear Regression Line: Generally a 21-period linear regression curve that is smoothed by a 3-period simple moving average
Upper Standard Error Band: The linear regression line plus 2 standard errors.
Lower Standard Error Band: The linear regression line minus 2 standard errors.
Introduced by John Andersen in a September 1996 'Stock and Commodities' magazine artikle.
Standard Error Bands.lua

Apprentice
FXCodeBase: Confirmed User

Posts: 20369
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

### Re: Standard Error Bands

MQL4 version of Standard Error Bands indicator: viewtopic.php?f=38&t=62244.
Alexander.Gettinger
FXCodeBase: Confirmed User

Posts: 3507
Joined: Wed Mar 31, 2010 9:40 pm
Location: Russia, Omsk

### Re: Standard Error Bands

Minor Update.

Apprentice
FXCodeBase: Confirmed User

Posts: 20369
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

### Re: Standard Error Bands

Just for the record, Bands are badly calculated.

Here's the implementation I made at TradingView's Pine if you like to re-code it to LUA:

Basically you need to define 2 functions prior to calculate error which are Alpha and Beta, then define the Standard Error Estimate from the Linear Regression Curve (I like to use TSF)

Code: Select all
`beta(array,periods) where    n     = barindex    val1 = sum(n*array,periods)-(periods*sma(n,periods)*sma(array,periods))    val2 = sum(pow(n,2),periods)-(periods*pow(sma(n,periods),2))    calcB = val1/val2alpha(array,periods) =>    n       = barindex    calcA = sma(array,periods)-(beta(array,periods)*sma(n,periods))see(array,periods)  //  This function must supplant StdDev for band creation with mult factor    lr = linearregression(array,periods)  // Can be supplanted with TSF     val1 = (sum(pow(array,2),periods))-((alpha(array,periods)*sum(array,periods)))-((beta(array,periods)*sum(n*array,periods)))    val2 = periods - 2    eest = sqrt(val1/val2)`

Hope it helps!
xel_arjona

Posts: 1
Joined: Tue Jun 07, 2016 4:24 pm

### Re: Standard Error Bands

Bugzilla Bug 3539

Apprentice
FXCodeBase: Confirmed User

Posts: 20369
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

### Re: Standard Error Bands

The indicator was revised and updated.

Apprentice
FXCodeBase: Confirmed User

Posts: 20369
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

### Re: Standard Error Bands

xel_arjona wrote:Just for the record, Bands are badly calculated.

Here's the implementation I made at TradingView's Pine if you like to re-code it to LUA:

Basically you need to define 2 functions prior to calculate error which are Alpha and Beta, then define the Standard Error Estimate from the Linear Regression Curve (I like to use TSF)

Please, try this version of the indicator:

Standard Error Bands2.lua
Alexander.Gettinger
FXCodeBase: Confirmed User

Posts: 3507
Joined: Wed Mar 31, 2010 9:40 pm
Location: Russia, Omsk

### Re: Standard Error Bands

The Indicator was revised and updated.

Apprentice
FXCodeBase: Confirmed User

Posts: 20369
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia