OPEN-SOURCE SCRIPT
Cập nhật

Averages - PineCoders FAQ

9 785
█ WARNING


The publication of our ConditionalAverages library has deprecated this publication.



█ ORIGINAL DESCRIPTION


The need to calculate averages (arithmetic mean) comes up here and there in scripts. When you want the average of a value only when a given condition has occurred, you will often not be able to use the standard sma function in Pine because it will average all values in the series. Even if you take care to use your condition to set non-conforming values to zero, this ends up skewing your results with zero values.

This script calculates:
1. The running average of all up volumes,
2. The average of last x occurrences of up volume ,
3. The average up volume occurrences in last y bars.



Look first. Then leap.

Phát hành các Ghi chú

  • Made code for cases 2 and 3 into functions.
  • Added examples of multiple-result functions.
Phát hành các Ghi chú

Conversion to v4.
Phát hành các Ghi chú
Fixes to comments.
Phát hành các Ghi chú
Simplified Case 1 code.
Phát hành các Ghi chú
Changes to comments.
Phát hành các Ghi chú
Updated calculations.
Phát hành các Ghi chú
v8
Rewrite of code using techniques that eliminate all `for` loops.
Phát hành các Ghi chú
v9
Functionalized case 1.

Thông báo miễn trừ trách nhiệm

Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.