PineCoders

Averages - PineCoders FAQ

PineCoders Mod 已更新   
█ 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.

版本注释:
  • Made code for cases 2 and 3 into functions.
  • Added examples of multiple-result functions.
版本注释:
Conversion to v4.
版本注释:
Fixes to comments.
版本注释:
Simplified Case 1 code.
版本注释:
Changes to comments.
版本注释:
Updated calculations.
版本注释:
v8
Rewrite of code using techniques that eliminate all `for` loops.
版本注释:
v9
Functionalized case 1.

Tools and ideas for all Pine coders: www.pinecoders.com
Our Pine FAQ & Code: www.pinecoders.com/faq_and_code/
Pine news broadcasts: t.me/PineCodersSquawkBox or twitter.com/PineCoders
开源脚本

本着真正的TradingView精神,该脚本的作者将其开源发布,以便交易者可以理解和验证它。为作者喝彩!您可以免费使用它,但在出版物中重复使用此代码受网站规则的约束。 您可以收藏它以在图表上使用。

免责声明

这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。

想在图表上使用此脚本?