xel_arjona

Standard Error of the Estimate -Composite Bands-

Standard Error of the Estimate - Code and adaptation by @glaz & @XeL_arjona
Ver. 2.00.a


Original implementation idea of bands by:
Traders issue: Stocks & Commodities V. 14:9 (375-379):
Standard Error Bands by Jon Andersen


This code is a former update to previous "Standard Error Bands" that was wrongly applied given that previous version in reality use the Standard Error OF THE MEAN, not THE ESTIMATE as it should be used by Jon Andersen original idea and corrected in this version.

As always I am very Thankfully with the support at the Pine Script Editor chat room, with special mention to user @glaz in order to help me adequate the alpha-beta (y-y') algorithm, as well to give him full credit to implement the "wide" version of the former bands.

For a quick and publicly open explanation of this truly statistical (regression analysis) indicator, you can refer at Here!

Extract from the former URL:
Standard Error Bands are quite different than Bollinger's. First, they are bands constructed around a linear regression curve. Second, the bands are based on two standard errors above and below this regression line. The error bands measure the standard error of the estimate around the linear regression line. Therefore, as a price series follows the course of the regression line the bands will narrow, showing little error in the estimate. As the market gets noisy and random, the error will be greater resulting in wider bands.

オープンソーススクリプト

TradingViewの精神に則り、このスクリプトの作者は、トレーダーが理解し検証できるようにオープンソースで公開しています。作者に敬意を表します!無料で使用することができますが、このコードを投稿で再利用するには、ハウスルールに準拠する必要があります。 お気に入りに登録してチャート上でご利用頂けます。

免責事項

これらの情報および投稿は、TradingViewが提供または保証する金融、投資、取引、またはその他の種類のアドバイスや推奨を意図したものではなく、またそのようなものでもありません。詳しくは利用規約をご覧ください。

チャートでこのスクリプトを利用したいですか?
//@version=2
study("Standard Error of the Estimate -Composite Bands-", shorttitle="SEE", overlay=true)
p = input(title="Rolling Lookback Window:", defval=21)
sdeg = input(title="Smoothing Factor:", defval=3)

// Standard Error of the Estimate Algorithm's
beta(array,per) =>
    val1 = sum(n*array,per)-(per*sma(n,per)*sma(array,per))
    val2 = sum(pow(n,2),per)-(per*pow(sma(n,per),2))
    calcB = val1/val2
alpha(array,per) =>
    calcA = sma(array,per)-(beta(array,per)*sma(n,per))
see(array,per,mult,dir,type) =>
    lr = linreg(array,per,0)
    val1 = (sum(pow(array,2),per))-((alpha(array,per)*sum(array,per)))-((beta(array,per)*sum(n*array,per)))
    val2 = per - 2
    narrow = sqrt(val1/val2)
    est = sum(pow(lr-array,2),per) / (per - 2 )
    wide = sqrt(est)
    d = dir ? 1 : -1
    band = type ? narrow : wide
    seb = lr + d * mult * band

// Plotting
UWB = plot(sma(see(close,p,2,true,false),sdeg),color=red,transp=90)
UNB = plot(sma(see(close,p,2,true,true),sdeg),color=red,transp=90)
middle = plot(sma(linreg(close,p,0),sdeg),color=red,style=line,transp=0)
BNB = plot(sma(see(close,p,2,false,true),sdeg),color=red,transp=90)
BWB = plot(sma(see(close,p,2,false,false),sdeg),color=red,transp=90)
fill(UWB,BWB,transp=95,title="WSEE",color=red)
fill(UNB,BNB,transp=90,title="NSEE",color=red)