thaiawe

Examples of Rolling Average Using Automated Anchoring

thaiawe 업데이트됨   
In this study, I present a method to expose NaN values to development environment.
This exposure allows NaN values to be used by methods in scripts.

I also show how to use values, even NaN values, as anchors from which statistics can be computed from.
I demonstrate how to do this with constants and variables in methods for computing the cumulative/rolling average of a series.

I also show how to calculate the cumulative/rolling average from the start of a ticker series using the aforementioned methods.

Each method has a description on how some of their parts work as well as their constraints.

Method #1 - Can only be used for computing the rolling average on the ticker series.

Method #2 - The simple moving average from the Pine Script reference.
- Can be used to calculate the rolling average of the ticker series and number values of a series.
- This method seems to cause an error when there are many bars in the series.

Method #3 - The most versatile method due to the use of computing the rolling average using an array.
- Timeout will occur when computing the rolling average of an entire ticker series which is long.
- Timeout has not occurred when computing a rolling average of a series from NaN or non-NaN anchor points even when the series is long.

This is an attempt to get around the constraints of the built-in sma(source, length) function in which length cannot be dynamically adjusted.
Other Pine Script functions have that constraint which we can get around by defining our own functions.
릴리즈 노트:
In case the above description is not clear, this study shows how to expose NaN values to the development environment to be used in calculations. This study also shows the calculation of a statistic, in this case a moving average, using dynamic look-back during runtime rather than a constant. Pine Script’s built-in functions only allows for constant look-backs during runtime, which can only be manually changed and will recalculate the the statistic over the whole source series. You can workaround that issue by defining your own functions to loop on Series types and even more so by looping on Array types which contain the Series data. Although these workarounds work, their inefficiencies can be a hindrance, especially when the loop count becomes lengthy. It is TradingView's responsibility to change their built-in Pine Script functions to support more dynamic arguments at runtime in order to remove the need to write complex code as a workaround.
오픈 소스 스크립트

이 스크립트의 오써는 참된 트레이딩뷰의 스피릿으로 이 스크립트를 오픈소스로 퍼블리쉬하여 트레이더들로 하여금 이해 및 검증할 수 있도록 하였습니다. 오써를 응원합니다! 스크립트를 무료로 쓸 수 있지만, 다른 퍼블리케이션에서 이 코드를 재사용하는 것은 하우스룰을 따릅니다. 님은 즐겨찾기로 이 스크립트를 차트에서 쓸 수 있습니다.

면책사항

이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.

차트에 이 스크립트를 사용하시겠습니까?