StateFIFOQueue is a class that is provided for users doing Advanced coding of paintbars. It is equivalent to the FIFOQueue class, but extends it to have the state saving and restoring functions.
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 StateFIFOQueue(size); // where size is the size of the buffer (or "period" for a lot of indicators)
for state-keeping purposes, there are two functions.
public void SaveState() // should be called in PaintbarSaveState function
public void RestoreState() // should be called in PaintbarRestoreState function
It's also indexed, so if you have the code:
StateFIFOQueue Q = new StateFIFOQueue(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 |