org.encog.app.quant.util

## Class BarBuffer

- java.lang.Object
- - org.encog.app.quant.util.BarBuffer

-     public class BarBuffer
      extends Object

  A buffer of bar segments.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `BarBuffer(int thePeriods)` Construct the object.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `add(double d)` Add a bar.
    `void` | `add(double[] d)` Add a bar.
    `double` | `average(int idx)` Average all of the bars.
    `double` | `averageGain(int idx)` Get the average gain.
    `double` | `averageLoss(int idx)` Get the average loss.
    `List<double[]>` | `getData()`
    `boolean` | `getFull()` Determine if the buffer is full.
    `double` | `max(int idx)` Get the max for the specified index.
    `double` | `min(int idx)` Get the min for the specified index.
    `double[]` | `pop()` Pop (and remove) the oldest bar in the buffer.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### BarBuffer

          public BarBuffer(int thePeriods)

      Construct the object.
      Parameters:
        `thePeriods` - The number of periods.

  - ### Method Detail

    - #### add

          public final void add(double d)

      Add a bar.
      Parameters:
        `d` - The bar data.

    - #### add

          public final void add(double[] d)

      Add a bar.
      Parameters:
        `d` - The bar data.

    - #### average

          public final double average(int idx)

      Average all of the bars.
      Parameters:
        `idx` - The bar index to average.
      Returns:
        The average.

    - #### averageGain

          public final double averageGain(int idx)

      Get the average gain.
      Parameters:
        `idx` - The field to get the average gain for.
      Returns:
        The average gain.

    - #### averageLoss

          public final double averageLoss(int idx)

      Get the average loss.
      Parameters:
        `idx` - The index to check for.
      Returns:
        The average loss.

    - #### getData

          public final List<double[]> getData()

      Returns:
        The data.

    - #### getFull

          public final boolean getFull()

      Determine if the buffer is full.
      Returns:
        True if the buffer is full.

    - #### max

          public final double max(int idx)

      Get the max for the specified index.
      Parameters:
        `idx` - The index to check.
      Returns:
        The max.

    - #### min

          public final double min(int idx)

      Get the min for the specified index.
      Parameters:
        `idx` - The index to check.
      Returns:
        The min.

    - #### pop

          public final double[] pop()

      Pop (and remove) the oldest bar in the buffer.
      Returns:
        The oldest bar in the buffer.

Copyright © 2014. All Rights Reserved.