Advanced - TimePeriodQueue

TimePeriodQueue is a class that is provided for users doing Advanced coding of paintbars. It is similar to the FIFOQueue class except that where FIFOQueue has a set number of entries, TimePeriodQueue has a set time period over which the entries are collected.

 

For example, you could use it to see in a historical chart how many candles over the last 30 days were green. Note: not over the last 30 candles (for that you'd use FIFOQueue) but for the last 30 calendar days.

 

You create it by calling  

 

 new TimePeriodQueue(30, MTUtil.TimePeriodType.days);

 

for state-keeping purposes, there is a deep-copy function

 

 public void CopyTo(TimePeriodQueue copy)  // copies contents to identically defined Buffer

 

to add a value, you would call:

 

 public void Add(float value, DateTime DT)  

 

Here are the useful functions/properties

 

Name

Type

Purpose

Add

void

adds a value to the end of the buffer

Average

float

returns the average of the values in the buffer (Total/Count)

Clear

void

clears out/zeroes the buffer

Count

int

returns the number of values in the buffer

Newest

DateTime

newest date in the buffer

Oldest

DateTime

oldest date in the buffer

Total

float

returns the sum of all values in the buffer