Source » Bar Opening - source code

// Forex Strategy Builder
// Copyright (c) 2006 - 2008 Miroslav Popov - All rights reserved!
// http://forexsb.com
// info(a)forexsb.com
//
// Last changed on: 2006-09-01

using System;
using System.Drawing;

namespace Forex_Strategy_Builder
{
    /// <summary>
    /// Indicator Bar Opening.
    /// </summary>
    public class Bar_Opening : Indicator
    {
        /// <summary>
        /// The default constructor.
        /// </summary>
        public Bar_Opening()
        {
        }

        /// <summary>
        /// Sets the default parameters for the designated slot type.
        /// </summary>
        /// <param name="slotType">The slot type.</param>
        public Bar_Opening(SlotTypes slotType)
        {
            sIndicatorName  = "Bar Opening";
            parameters      = new IndicatorParam();
            bSeparatedChart = false;
            component       = new IndicatorComp[] { };
            afSpecValue     = new float[] { };
            bIsCalculated   = false;
            typeOfIndicator = TypeOfIndicator.Additional;
            timeExecution   = TimeExecution.Opening;

            // The indicator name.
            parameters.IndicatorName = sIndicatorName;

            // The slot type.
            parameters.SlotType = slotType;

            // The ComboBox parameters.
            parameters.ListParam[0].Caption  = "Logic";
            parameters.ListParam[0].ItemList = new string[] { "Enter the market at the beginning of the bar" };
            parameters.ListParam[0].Index    = 0;
            parameters.ListParam[0].Text     = parameters.ListParam[0].ItemList[parameters.ListParam[0].Index];
            parameters.ListParam[0].Enabled  = true;
            parameters.ListParam[0].ToolTip  = "Logic of application of the indicator";

            parameters.ListParam[1].Caption  = "Base price";
            parameters.ListParam[1].ItemList = new string[] { "Open" };
            parameters.ListParam[1].Index    = 0;
            parameters.ListParam[1].Text     = parameters.ListParam[1].ItemList[parameters.ListParam[1].Index];
            parameters.ListParam[1].Enabled  = true;
            parameters.ListParam[1].ToolTip  = "The execution price of all entry orders";
        }

        /// <summary>
        /// Calculates the indicator's components.
        /// </summary>
        /// <param name="slotType">The slot type.</param>
        public override void Calculate(SlotTypes slotType)
        {
            if (parameters.SlotType == SlotTypes.NotDefined) return;

            // Calculation
            float[] afPriceOpen = Data.Open;

            // Saving the components
            component = new IndicatorComp[1];

            component[0]           = new IndicatorComp();
            component[0].CompName  = "Opening price of the bar";
            component[0].DataType  = IndComponentType.OpenPrice;
            component[0].ChartType = IndChartType.NoChart;
            component[0].FirstBar  = 2;
            component[0].Value     = afPriceOpen;

            bIsCalculated = true;
        }
    }
}

Top