OPEN-SOURCE SCRIPT

Averages - PineCoders FAQ

Telah dikemas kini
█ 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.

Nota Keluaran

  • Made code for cases 2 and 3 into functions.
  • Added examples of multiple-result functions.
Nota Keluaran

Conversion to v4.
Nota Keluaran
Fixes to comments.
Nota Keluaran
Simplified Case 1 code.
Nota Keluaran
Changes to comments.
Nota Keluaran
Updated calculations.
Nota Keluaran
v8
Rewrite of code using techniques that eliminate all `for` loops.
Nota Keluaran
v9
Functionalized case 1.
averagefaqMoving Averagespinecoders

Skrip sumber terbuka

Dalam semangat sebenar TradingView, penulis telah menerbitkan kod Pine ini sebagai sumber terbuka supaya pedagang dapat memahami dan mengesahkannya. Sorakan kepada penulis! Anda boleh menggunakan perpustakaan ini secara percuma, tetapi penggunaan semula kod dalam penerbitan ini adalah dikawal oleh Peraturan dalaman. Anda boleh menyukainya untuk menggunakannya pada carta.

Ingin menggunakan skrip ini pada carta?


Tools and ideas for all Pine coders: pinecoders.com
Our Pine FAQ & Code: pinecoders.com/faq_and_code/
Pine news broadcasts: t.me/PineCodersSquawkBox or twitter.com/PineCoders
Juga pada:

Penafian