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. קרא עוד בתנאים וההגבלות.

רוצה להשתמש בסקריפ זה בגרף?