- Min : Minimum window size value
- Max : Maximum window size value
- Mult : Multiplicative factor for the rmse, control the channel width.
- Src : Source input of the indicator
The indicator displays the specific window size that maximizes the at the bottom of the lower channel.
When optimizing we want to find parameters such that they maximize or minimize a certain function, here the . The is given by 1 minus the ratio between the sum of squares ( SSE ) of the and the sum of squares of the mean. We know that the mean will always produce an SSE greater or equal to the one of the , so the will always be in a (0,1) range. In the case our data has a linear trend, the will have a better fit, thus having a lower SSE than the SSE of the mean, has such the ratio between the SSE and the mean SSE will be low, 1 minus this ratio will return a greater result. A lower will tell you that your produces a fit similar to the one produced by the mean. The is also given by the square of the between the dependent and independent variables.
In pinescript optimization can be done by running a function inside a loop, we run the function for each setting and keep the one that produces the maximum or minimum result, however, it is not possible to do that with most built-in functions, including the function of interest, correlation, as such we must recreate a rolling correlation function that can be used inside loops, such functions are generally loops-free, this means that they are not computed using a loop in the first place, fortunately, the rolling correlation function is simply based on moving averages and standard deviations, both can be computed without using a loop by using cumulative sums, this is what is done in the code.
Note that because the is based on the SSE of the , maximizing the also minimizes the SSE , another thing that is minimized is the horizontality of the fit.
In the example above we have a total window size of 27, the script will try to find the setting that maximizes the , we must avoid every data points before the volatile candle, using any of these data points will produce a poor fit, we see that the script avoid it, thus running as expected. Another interesting thing is that the best is not always associated to the lowest window size.
Note that optimization does not fix core problems in a model, with the we assume that our data set posses a linear trend, if it's not the case, then no matter how many settings you use you will still have a model that is not adapted to your data.
Become a Patreon and get access to exclusive technical indicators!
You can also check out some of the indicators I made for luxalgo : https://www.tradingview.com/u/LuxAlgo/#published-scripts
이 스크립트의 오써는 참된 트레이딩뷰의 스피릿으로 이 스크립트를 오픈소스로 퍼블리쉬하여 트레이더들로 하여금 이해 및 검증할 수 있도록 하였습니다. 오써를 응원합니다! 스크립트를 무료로 쓸 수 있지만, 다른 퍼블리케이션에서 이 코드를 재사용하는 것은 하우스룰을 따릅니다. 님은 즐겨찾기로 이 스크립트를 차트에서 쓸 수 있습니다.
이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.