Topic: Base classes, methods, properties and enumerations.

Every indicator (original or custom) inherits the base class Indicator. This base class provides the common indicator architecture. It provides also access to the historical prices and market information:

        /// <summary>
        /// Time frame of the loaded historical data
        /// </summary>
        protected static DataPeriods Period { get { return Data.Period; } }

        /// <summary>
        /// The minimal price change.
        /// </summary>
        protected static double Point { get { return Data.InstrProperties.Point; } }

        /// <summary>
        /// Number of digits after the decimal point of the historical data.
        /// </summary>
        protected static int Digits { get { return Data.InstrProperties.Digits; } }

        /// <summary>
        /// Number of loaded bars
        /// </summary>
        protected static int Bars { get { return Data.Bars; } }

        /// <summary>
        /// Bar opening price
        /// </summary>
        protected static double[] Open { get { return Data.Open; } }

        /// <summary>
        /// Bar opening date and time
        /// </summary>
        protected static DateTime[] Date { get { return Data.Date; } }

        /// <summary>
        /// Bar highest price
        /// </summary>
        protected static double[] High { get { return Data.High; } }

        /// <summary>
        /// Bar lowest price
        /// </summary>
        protected static double[] Low { get { return Data.Low; } }

        /// <summary>
        /// Bar closing price
        /// </summary>
        protected static double[] Close { get { return Data.Close; } }

        /// <summary>
        /// Bar volume
        /// </summary>
        protected static int[] Volume { get { return Data.Volume; } }
 

The base classes are available for download here: Indicators_Base.zip

Re: Base classes, methods, properties and enumerations.

Data Period
-------------------------

DataPeriods Period

It gets the time frame of the currently loaded instrument.
The value of each period is equal to its duration in minutes.

public enum DataPeriods
{
    min1  = 1,
    min5  = 5,
    min15 = 15,
    min30 = 30,
    hour1 = 60,
    hour4 = 240,
    day   = 1440,
    week  = 10080
}

Application:
-------------------------

1. Setting a variable to DataPeriods

DataPeriods myPeriod = DataPeriods.min5;

Result: myPeriod is 5 minutes


2. Checking if a given chart is a daily chart:

if(Period == DataPeriods.day)
{
  // This is daily chart
}
else
{
  // This is not a daily chart
}

3. Converting DataPeriods to minutes

int iMinutes = (int)DataPeriod.day;

Result: iMinutes = 1440


4. Converting minutes to DataPeriods

DataPeriods myPeriod = (DataPeriods)60;

Result: myPeriod = DataPeriods.hour1

Re: Base classes, methods, properties and enumerations.

Value of one pip
----------------------------

double Point

A Point represents the smallest price change that a given exchange rate can make.


Examples:

For EURUSD 1.3245 one point is 0.0001
For USDJPY 103.22 one point is 0.01

Re: Base classes, methods, properties and enumerations.

Digits
----------------------------

int Digits

It shows the number of digits after the decimal point of the historical data.


Examples:

For EURUSD 1.3245 Digits = 4
For USDJPY 103.22 Digits = 2

Point = Math.Pow(10, -Digits);

Re: Base classes, methods, properties and enumerations.

Number of data bars
-------------------------------

int Bars

It show the number of loaded historical data bars.

Re: Base classes, methods, properties and enumerations.

Historical data
-----------------------

The historical forex data is stored in arrays. The length of these arrays is Bars.

The last (newest bar) is the rightmost bar.
The first (oldest) bar is the leftmost bar.

DateTime[] Date; // The date and time of bar opening
double[] Open;   // Bar opening price
double[] High;   // Bar highest price
double[] Low;    // Bar lowest price
double[] Close;  // Bar closing price
int[] Volume;    // Tick volume during the bar

Application:

1. First bar opening price:

double dOpenPrice = Open[0];

2. Last (newest) bar closing price:

double dClosePrice = Close[Bars - 1];

3. Momentum oscillator

int iPeriod = 10; // Period of Momentum
double[] adMomentum = new double[Bars]; // An array to store Momentum

for(int iBar = iPeriod; iBar < Bars; iBar++)
{
    adMomentum[iBar] = Close[iBar] - Close[iBar - 1];
}

Re: Base classes, methods, properties and enumerations.

where are the base classes and do they will change to expand functionality of FSB  !!!

Regards