FIFOQueue is a class that is provided for users doing Advanced coding of paintbars. It contains most of the features that would be needed for indicator/paintbar calculation functionality.
It is mostly superseded by the StateFIFOQueue class that has exactly the same functionality but makes it more convenient to use it in the state-machine paintbars.
This is a FIFO (first in - first out) queue buffer of a set size containing double values, combined with various housekeeping and statistical functions.
You create it by calling
new FIFOQueue(size); // where size is the size of the buffer (or "period" for a lot of indicators)
for state-keeping purposes, there is a deep-copy function
public void CopyTo(FIFOQueue copy) // copies contents to identically defined Buffer
It's also indexed, so if you have the code:
FIFOQueue Q = new FIFOQueue(10);
Q.Add(1);
Q.Add(2);
Q.Add(3);
then Q[1] will return 2. Q[2] will return 1.
The other useful functions/properties include
Name |
Type |
Purpose |
Add |
void |
adds a value to the end of the buffer |
Average |
double |
returns the average of the values in the buffer |
Capacity |
int |
returns the maximum size/capacity of the buffer |
Clear |
void |
clears out/zeroes the buffer |
COG |
double |
returns the Center of Gravity (COG) of the values in the buffer |
Count |
int |
returns the number of values in the buffer |
DeleteFirst |
void |
deletes the first (oldest) value in the buffer |
DeleteLast |
void |
deletes the last (newest) value in the buffer |
First |
double |
returns the first (oldest) value in the buffer |
Full |
boolean |
returns true if Count == Capacity |
GetHighLow |
void |
(3 different overrides) returns the highest and the lowest values in the buffer |
GetPercentRank |
double |
returns a value's percent rank when compared to all the values in the buffer |
GetStDev |
double |
returns the Standard Deviation for the values in the buffer |
Last |
double |
returns the last (newest) value in the buffer |
MeanDev |
double |
returns the Mean Deviation for the values in the buffer |
ReplaceLast |
void |
replaces the last (newest) value in the buffer with another value |
Sum |
double |
returns the sum of all the values in the buffer |
SumPos |
double |
returns the sum of all the positive values in the buffer |
SumNeg |
double |
returns the sum of all the negative values in the buffer (SumNeg is always <=0) |
WeightedAverage |
double |
returns the Weighted Average of the values in the buffer |