Source »
Day Open - 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 Day Open
/// </summary>
public class Day_Opening : Indicator
{
/// <summary>
/// The default constructor.
/// </summary>
public Day_Opening()
{
}
/// <summary>
/// Sets the default parameters for the designated slot type.
/// </summary>
/// <param name="slotType">The slot type.</param>
public Day_Opening(SlotTypes slotType)
{
sIndicatorName = "Day Opening";
parameters = new IndicatorParam();
bSeparatedChart = false;
component = new IndicatorComp[] { };
afSpecValue = new float[] { };
fMinValue = 0;
fMaxValue = 0;
bIsCalculated = false;
typeOfIndicator = TypeOfIndicator.DateTime;
timeExecution = TimeExecution.Opening;
// The indicator name.
parameters.IndicatorName = "Day Opening";
// 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 day" };
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;
// Reading the parameters
// Calculation
float[] afOpenPrice = new float[Bars];
for (int iBar = 1; iBar < Bars; iBar++)
if (Date[iBar - 1].Day != Date[iBar].Day)
afOpenPrice[iBar] = Open[iBar];
// Saving the components
component = new IndicatorComp[1];
component[0] = new IndicatorComp();
component[0].CompName = "Opening price of the day";
component[0].DataType = IndComponentType.OpenPrice;
component[0].ChartType = IndChartType.NoChart;
component[0].FirstBar = 2;
component[0].Value = afOpenPrice;
bIsCalculated = true;
}
}
}
Top