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에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.

차트에 이 스크립트를 사용하시겠습니까?
//@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)