Source » Stop Limit - source code

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

using System;
using System.Drawing;

namespace Forex_Strategy_Builder
{
    /// <summary>
    /// indicator: Stop Limit
    /// The implimentation of logic is in Market.AnalyseClose(int iBar)
    /// </summary>
    public class Stop_Limit : Indicator
    {
        /// <summary>
        /// The default constructor.
        /// </summary>
        public Stop_Limit()
        {
        }

        /// <summary>
        /// Sets the default parameters for the designated slot type.
        /// </summary>
        /// <param name="slotType">The slot type.</param>
        public Stop_Limit(SlotTypes slotType)
        {
            sIndicatorName  = "Stop Limit";
            parameters      = new IndicatorParam();
            component       = new IndicatorComp[] { };
            bSeparatedChart = false;
            bIsCalculated   = false;

            typeOfIndicator = TypeOfIndicator.Additional;

            // 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[]
            {
                "Exit at Stop Loss or at Take Profit level",
            };
            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";

            // The NumericUpDown parameters.
            parameters.NumParam[0].Caption = "Stop Loss";
            parameters.NumParam[0].Value   = -20;
            parameters.NumParam[0].Min     = -2000;
            parameters.NumParam[0].Max     = -5;
            parameters.NumParam[0].Enabled = true;
            parameters.NumParam[0].ToolTip = "The Stop Loss value (in pips)";

            parameters.NumParam[1].Caption = "Take Profit";
            parameters.NumParam[1].Value   = 20;
            parameters.NumParam[1].Min     = 5;
            parameters.NumParam[1].Max     = 2000;
            parameters.NumParam[1].Enabled = true;
            parameters.NumParam[1].ToolTip = "The Take Profit value (in pips)";
        }

        /// <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;

            bIsCalculated = true;
        }
    }
}

Top