Source »
Day Closing - 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 Closing
/// </summary>
public class Day_Closing : Indicator
{
/// <summary>
/// The default constructor.
/// </summary>
public Day_Closing()
{
}
/// <summary>
/// Sets the default parameters for the designated slot type.
/// </summary>
/// <param name="slotType">The slot type.</param>
public Day_Closing(SlotTypes slotType)
{
sIndicatorName = "Day Closing";
parameters = new IndicatorParam();
bSeparatedChart = false;
component = new IndicatorComp[] { };
afSpecValue = new float[] { };
bIsCalculated = false;
timeExecution = TimeExecution.Closing;
typeOfIndicator = TypeOfIndicator.DateTime;
// The indicator name.
parameters.IndicatorName = "Day Closing";
// The slot type.
parameters.SlotType = slotType;
// The ComboBox parameters.
parameters.ListParam[0].Caption = "Logic";
if (slotType == SlotTypes.Open)
{
parameters.ListParam[0].ItemList = new string[] { "Enter the market at the end of the day" };
parameters.ListParam[1].ToolTip = "The execution price of all entry orders";
}
else
{
parameters.ListParam[0].ItemList = new string[] { "Exit the market at the end of the day" };
parameters.ListParam[1].ToolTip = "The execution price of all exit orders";
}
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[] { "Close" };
parameters.ListParam[1].Index = 0;
parameters.ListParam[1].Text = parameters.ListParam[1].ItemList[parameters.ListParam[1].Index];
parameters.ListParam[1].Enabled = true;
}
/// <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[] afClosePrice = new float[Bars];
for (int iBar = 1; iBar < Bars; iBar++)
if (Date[iBar - 1].Day != Date[iBar].Day)
afClosePrice[iBar - 1] = Close[iBar - 1];
// Saving the components
component = new IndicatorComp[1];
component[0] = new IndicatorComp();
component[0].CompName = "Closing price of the day";
component[0].DataType = IndComponentType.ClosePrice;
component[0].ChartType = IndChartType.NoChart;
component[0].FirstBar = 2;
component[0].Value = afClosePrice;
bIsCalculated = true;
}
}
}
Top