/// <summary>
        /// Sets the default indicator parameters for the designated slot type
        /// </summary>
        public Enter_Once(SlotTypes slotType)
        {
            // General properties
            IndicatorName = "Enter Once";
            PossibleSlots = SlotTypes.OpenFilter;

            // Setting up the indicator parameters
            IndParam = new IndicatorParam();
            IndParam.IndicatorName = IndicatorName;
            IndParam.SlotType      = slotType;
            IndParam.IndicatorType = TypeOfIndicator.DateTime;

            // The ComboBox parameters
            IndParam.ListParam[0].Caption = "Logic";
            IndParam.ListParam[0].ItemList = new string[]
            {
                "Enter no more than once a bar",
                "Enter no more than once a day",
                "Enter no more than once a week",
                "Enter no more than once a month"
            };
            IndParam.ListParam[0].Index   = 0;
            IndParam.ListParam[0].Text    = IndParam.ListParam[0].ItemList[IndParam.ListParam[0].Index];
            IndParam.ListParam[0].Enabled = true;
            IndParam.ListParam[0].ToolTip = "Indicator's logic.";

            return;
        }
        /// <summary>
        /// Sets the default indicator parameters for the designated slot type.
        /// </summary>
        public Account_Percent_Stop(SlotTypes slotType)
        {
            // General properties
            IndicatorName   = "Account Percent Stop";
            PossibleSlots   = SlotTypes.Close;
            SeparatedChart  = false;

            // Setting up the indicator parameters
            IndParam = new IndicatorParam();
            IndParam.IndicatorName = IndicatorName;
            IndParam.SlotType      = slotType;
            IndParam.IndicatorType = TypeOfIndicator.Additional;

            // The ComboBox parameters
            IndParam.ListParam[0].Caption  = "Logic";
            IndParam.ListParam[0].ItemList = new string[]
            {
                "Limit the risk to percent of the account"
            };
            IndParam.ListParam[0].Index   = 0;
            IndParam.ListParam[0].Text    = IndParam.ListParam[0].ItemList[IndParam.ListParam[0].Index];
            IndParam.ListParam[0].Enabled = true;
            IndParam.ListParam[0].ToolTip = "Logic of application of the indicator.";

            // The NumericUpDown parameters
            IndParam.NumParam[0].Caption = "Account percent";
            IndParam.NumParam[0].Value   = 2;
            IndParam.NumParam[0].Min     = 1;
            IndParam.NumParam[0].Max     = 20;
            IndParam.NumParam[0].Enabled = true;
            IndParam.NumParam[0].ToolTip = "Maximum account to risk.";

            return;
        }
        /// <summary>
        /// Sets the default indicator parameters for the designated slot type
        /// </summary>
        public Bar_Opening(SlotTypes slotType)
        {
            // General properties
            IndicatorName = "Bar Opening";
            PossibleSlots = SlotTypes.Open;

            // Setting up the indicator parameters
            IndParam = new IndicatorParam();
            IndParam.IndicatorName = IndicatorName;
            IndParam.SlotType      = slotType;
            IndParam.IndicatorType = TypeOfIndicator.Additional;
            IndParam.ExecutionTime = ExecutionTime.AtBarOpening;

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

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

            return;
        }
        /// <summary>
        /// Sets the default indicator parameters for the designated slot type
        /// </summary>
        public Long_or_Short(SlotTypes slotType)
        {
            // General properties
            IndicatorName = "Long or Short";
            PossibleSlots = SlotTypes.OpenFilter;

            // Setting up the indicator parameters
            IndParam = new IndicatorParam();
            IndParam.IndicatorName = IndicatorName;
            IndParam.SlotType      = slotType;
            IndParam.IndicatorType = TypeOfIndicator.Additional;

            // The ComboBox parameters
            IndParam.ListParam[0].Caption  = "Logic";
            IndParam.ListParam[0].ItemList = new string[]
            {
                "Open long positions only",
                "Open short positions only",
            };
            IndParam.ListParam[0].Index   = 0;
            IndParam.ListParam[0].Text    = IndParam.ListParam[0].ItemList[IndParam.ListParam[0].Index];
            IndParam.ListParam[0].Enabled = true;
            IndParam.ListParam[0].ToolTip = "Logic of application of the indicator.";

            return;
        }
Beispiel #5
0
        public Indicator()
        {
            IndParam = new IndicatorParam();

            IndicatorName = string.Empty;
            PossibleSlots = SlotTypes.NotDefined;
            SlotType = SlotTypes.NotDefined;

            SeparatedChart = false;
            SeparatedChartMinValue = double.MaxValue;
            SeparatedChartMaxValue = double.MinValue;
            SpecialValues = new double[0];

            IsDiscreteValues = false;
            CustomIndicator = false;
            IsBacktester = true;
            IsGeneratable = true;
            WarningMessage = string.Empty;
            AllowClosingFilters = false;

            IndicatorAuthor = "Forex Software Ltd";
            IndicatorVersion = "1.0";
            IndicatorDescription = "Bundled in FSB distribution.";

            ExitFilterShortDescription = "Not defined";
            EntryFilterShortDescription = "Not defined";
            ExitFilterLongDescription = "Not defined";
            EntryFilterLongDescription = "Not defined";
            ExitPointShortDescription = "Not defined";
            ExitPointLongDescription = "Not defined";
            EntryPointShortDescription = "Not defined";
            EntryPointLongDescription = "Not defined";

            Component = new IndicatorComp[] {};
        }
        /// <summary>
        /// Sets the default indicator parameters for the designated slot type
        /// </summary>
        public Lot_Limiter(SlotTypes slotType)
        {
            // General properties
            IndicatorName = "Lot Limiter";
            PossibleSlots = SlotTypes.OpenFilter;

            // Setting up the indicator parameters
            IndParam = new IndicatorParam();
            IndParam.IndicatorName = IndicatorName;
            IndParam.SlotType      = slotType;
            IndParam.IndicatorType = TypeOfIndicator.Additional;

            // The ComboBox parameters
            IndParam.ListParam[0].Caption  = "Logic";
            IndParam.ListParam[0].ItemList = new string[] { "Limit the number of open lots" };
            IndParam.ListParam[0].Index    = 0;
            IndParam.ListParam[0].Text     = IndParam.ListParam[0].ItemList[IndParam.ListParam[0].Index];
            IndParam.ListParam[0].Enabled  = true;
            IndParam.ListParam[0].ToolTip  = "Indicator's logic";

            // The NumericUpDown parameters
            IndParam.NumParam[0].Caption = "Maximum lots";
            IndParam.NumParam[0].Value   = 5;
            IndParam.NumParam[0].Min     = 1;
            IndParam.NumParam[0].Max     = 100;
            IndParam.NumParam[0].Enabled = true;
            IndParam.NumParam[0].ToolTip = "Maximum number of open lots.";

            return;
        }
        /// <summary>
        /// Sets the default indicator parameters for the designated slot type
        /// </summary>
        public N_Bars_Exit(SlotTypes slotType)
        {
            // General properties
            IndicatorName = "N Bars Exit";
            PossibleSlots = SlotTypes.CloseFilter;

            // Setting up the indicator parameters
            IndParam = new IndicatorParam();
            IndParam.IndicatorName = IndicatorName;
            IndParam.SlotType      = slotType;
            IndParam.IndicatorType = TypeOfIndicator.Additional;

            // The ComboBox parameters
            IndParam.ListParam[0].Caption  = "Logic";
            IndParam.ListParam[0].ItemList = new string[]
            {
                "Exit N Bars after entry",
            };
            IndParam.ListParam[0].Index   = 0;
            IndParam.ListParam[0].Text    = IndParam.ListParam[0].ItemList[IndParam.ListParam[0].Index];
            IndParam.ListParam[0].Enabled = true;
            IndParam.ListParam[0].ToolTip = "Logic of application of the indicator.";

            // The NumericUpDown parameters
            IndParam.NumParam[0].Caption = "N Bars";
            IndParam.NumParam[0].Value   = 10;
            IndParam.NumParam[0].Min     = 1;
            IndParam.NumParam[0].Max     = 10000;
            IndParam.NumParam[0].Enabled = true;
            IndParam.NumParam[0].ToolTip = "The number of bars after entry to exit the position.";

            return;
        }
        /// <summary>
        /// Sets the default indicator parameters for the designated slot type
        /// </summary>
        public Take_Profit(SlotTypes slotType)
        {
            // General properties
            IndicatorName = "Take Profit";
            PossibleSlots = SlotTypes.Close;

            // Setting up the indicator parameters
            IndParam = new IndicatorParam();
            IndParam.IndicatorName = IndicatorName;
            IndParam.SlotType      = slotType;
            IndParam.IndicatorType = TypeOfIndicator.Additional;

            // The ComboBox parameters
            IndParam.ListParam[0].Caption  = "Logic";
            IndParam.ListParam[0].ItemList = new string[]
            {
                "Exit at the Take Profit level",
            };
            IndParam.ListParam[0].Index   = 0;
            IndParam.ListParam[0].Text    = IndParam.ListParam[0].ItemList[IndParam.ListParam[0].Index];
            IndParam.ListParam[0].Enabled = true;
            IndParam.ListParam[0].ToolTip = "Logic of application of the indicator.";

            // The NumericUpDown parameters
            IndParam.NumParam[0].Caption = "Take Profit";
            IndParam.NumParam[0].Value   = 200;
            IndParam.NumParam[0].Min     = 5;
            IndParam.NumParam[0].Max     = 5000;
            IndParam.NumParam[0].Enabled = true;
            IndParam.NumParam[0].ToolTip = "The Take Profit value (in pips).";

            return;
        }
        /// <summary>
        /// Sets the default indicator parameters for the designated slot type
        /// </summary>
        public Market_Facilitation_Index(SlotTypes slotType)
        {
            // General properties
            IndicatorName  = "Market Facilitation Index";
            PossibleSlots  = SlotTypes.OpenFilter | SlotTypes.CloseFilter;
            SeparatedChart = true;
            SeparatedChartMinValue = 0;

            // Setting up the indicator parameters
            IndParam = new IndicatorParam();
            IndParam.IndicatorName = IndicatorName;
            IndParam.SlotType      = slotType;

            // The ComboBox parameters
            IndParam.ListParam[0].Caption  = "Logic";
            IndParam.ListParam[0].ItemList = new string[]
            {
                "The Market Facilitation Index rises",
                "The Market Facilitation Index falls",
                "The Market Facilitation Index changes its direction upward",
                "The Market Facilitation Index changes its direction downward"
            };
            IndParam.ListParam[0].Index   = 0;
            IndParam.ListParam[0].Text    = IndParam.ListParam[0].ItemList[IndParam.ListParam[0].Index];
            IndParam.ListParam[0].Enabled = true;
            IndParam.ListParam[0].ToolTip = "Logic of application of the indicator.";

            // The CheckBox parameters
            IndParam.CheckParam[0].Caption = "Use previous bar value";
            IndParam.CheckParam[0].Checked = PrepareUsePrevBarValueCheckBox(slotType);
            IndParam.CheckParam[0].Enabled = true;
            IndParam.CheckParam[0].ToolTip = "Use the indicator value from the previous bar.";

            return;
        }
        /// <summary>
        /// Sets the default indicator parameters for the designated slot type
        /// </summary>
        public Trailing_Stop_Limit(SlotTypes slotType)
        {
            // General properties
            IndicatorName  = "Trailing Stop Limit";
            PossibleSlots  = SlotTypes.Close;
            WarningMessage = "The Trailing Stop Limit indicator trails once per bar." +
                " It means that the indicator doesn't move the position's SL at every new top / bottom, as in the real trade, but only when a new bar begins." +
                " The Stop Loss remains constant during the whole bar. Take Profit level is constant by definition.";

            // Setting up the indicator parameters
            IndParam = new IndicatorParam();
            IndParam.IndicatorName = IndicatorName;
            IndParam.SlotType      = slotType;
            IndParam.IndicatorType = TypeOfIndicator.Additional;

            // The ComboBox parameters
            IndParam.ListParam[0].Caption  = "Logic";
            IndParam.ListParam[0].ItemList = new string[]
            {
                "Exit at the trailing Stop Loss or at the constant Take Profit level",
            };
            IndParam.ListParam[0].Index   = 0;
            IndParam.ListParam[0].Text    = IndParam.ListParam[0].ItemList[IndParam.ListParam[0].Index];
            IndParam.ListParam[0].Enabled = true;
            IndParam.ListParam[0].ToolTip = "Logic of application of the indicator.";

            IndParam.ListParam[1].Caption  = "Trailing mode";
            IndParam.ListParam[1].ItemList = new string[]
            {
                "Trails once a bar",
            };
            IndParam.ListParam[1].Index   = 0;
            IndParam.ListParam[1].Text    = IndParam.ListParam[1].ItemList[IndParam.ListParam[1].Index];
            IndParam.ListParam[1].Enabled = true;
            IndParam.ListParam[1].ToolTip = "Mode of operation of Trailing Stop.";

            // The NumericUpDown parameters
            IndParam.NumParam[0].Caption = "Initial Stop Loss";
            IndParam.NumParam[0].Value   = 200;
            IndParam.NumParam[0].Min     = 5;
            IndParam.NumParam[0].Max     = 5000;
            IndParam.NumParam[0].Enabled = true;
            IndParam.NumParam[0].ToolTip = "The initial Stop Loss value (in pips).";

            IndParam.NumParam[1].Caption = "Take Profit";
            IndParam.NumParam[1].Value   = 200;
            IndParam.NumParam[1].Min     = 5;
            IndParam.NumParam[1].Max     = 5000;
            IndParam.NumParam[1].Enabled = true;
            IndParam.NumParam[1].ToolTip = "The constant Take Profit value (in pips).";

            return;
        }
        /// <summary>
        /// Sets the default indicator parameters for the designated slot type
        /// </summary>
        public Trailing_Stop_Limit(SlotTypes slotType)
        {
            // General properties
            IndicatorName = "Trailing Stop Limit";
            PossibleSlots = SlotTypes.Close;

            // Setting up the indicator parameters
            IndParam = new IndicatorParam();
            IndParam.IndicatorName = IndicatorName;
            IndParam.SlotType      = slotType;
            IndParam.IndicatorType = TypeOfIndicator.Additional;

            // The ComboBox parameters
            IndParam.ListParam[0].Caption  = "Logic";
            IndParam.ListParam[0].ItemList = new string[]
            {
                "Exit at the trailing Stop Loss or at the constant Take Profit level",
            };
            IndParam.ListParam[0].Index   = 0;
            IndParam.ListParam[0].Text    = IndParam.ListParam[0].ItemList[IndParam.ListParam[0].Index];
            IndParam.ListParam[0].Enabled = true;
            IndParam.ListParam[0].ToolTip = "Logic of application of the indicator.";

            IndParam.ListParam[1].Caption  = "Trailing mode";
            IndParam.ListParam[1].ItemList = new string[]
            {
                "Trails once a bar",
                "Trails at a new top/bottom",
            };
            IndParam.ListParam[1].Index   = 0;
            IndParam.ListParam[1].Text    = IndParam.ListParam[1].ItemList[IndParam.ListParam[1].Index];
            IndParam.ListParam[1].Enabled = true;
            IndParam.ListParam[1].ToolTip = "Mode of operation of Trailing Stop.";

            // The NumericUpDown parameters
            IndParam.NumParam[0].Caption = "Initial Stop Loss";
            IndParam.NumParam[0].Value   = 200;
            IndParam.NumParam[0].Min     = 5;
            IndParam.NumParam[0].Max     = 5000;
            IndParam.NumParam[0].Enabled = true;
            IndParam.NumParam[0].ToolTip = "The initial Stop Loss value (in pips).";

            IndParam.NumParam[1].Caption = "Take Profit";
            IndParam.NumParam[1].Value   = 200;
            IndParam.NumParam[1].Min     = 5;
            IndParam.NumParam[1].Max     = 5000;
            IndParam.NumParam[1].Enabled = true;
            IndParam.NumParam[1].ToolTip = "The constant Take Profit value (in pips).";

            return;
        }
 /// <summary>
 ///  The default constructor.
 /// </summary>
 public IndicatorSlot()
 {
     slotNumb         = 0;
     slotType         = SlotTypes.NotDefined;
     group            = "";
     isDefined        = false;
     slotStatus       = StrategySlotStatus.Open;
     indicatorName    = "Not defined";
     indicatorParam   = new IndicatorParam();
     isSeparatedChart = false;
     component        = new IndicatorComp[] { };
     adSpecValue      = new double[] { };
     minValue         = double.MaxValue;
     maxValue         = double.MinValue;
 }
 /// <summary>
 ///  The default constructor.
 /// </summary>
 public IndicatorSlot()
 {
     SlotNumber = 0;
     SlotType = SlotTypes.NotDefined;
     LogicalGroup = "";
     IsDefined = false;
     SlotStatus = StrategySlotStatus.Open;
     IndicatorName = "Not defined";
     IndParam = new IndicatorParam();
     SeparatedChart = false;
     Component = new IndicatorComp[] {};
     SpecValue = new double[] {};
     MinValue = double.MaxValue;
     MaxValue = double.MinValue;
 }
        /// <summary>
        /// Sets the default indicator parameters for the designated slot type
        /// </summary>
        public Bar_Closing(SlotTypes slotType)
        {
            // General properties
            IndicatorName = "Bar Closing";
            PossibleSlots = SlotTypes.Open | SlotTypes.Close;
            AllowClosingFilters = true;

            // Setting up the indicator parameters
            IndParam = new IndicatorParam();
            IndParam.IndicatorName = IndicatorName;
            IndParam.SlotType      = slotType;
            IndParam.IndicatorType = TypeOfIndicator.Additional;
            IndParam.ExecutionTime = ExecutionTime.AtBarClosing;

            // The ComboBox parameters
            IndParam.ListParam[0].Caption = "Logic";
            if (slotType == SlotTypes.Open)
            {
                IndParam.ListParam[0].ItemList = new string [] { "Enter the market at the end of the bar" };
                IndParam.ListParam[1].ToolTip  = "The execution price of all entry orders.";
            }
            else
            {
                IndParam.ListParam[0].ItemList = new string[] { "Exit the market at the end of the bar" };
                IndParam.ListParam[1].ToolTip  = "The execution price of all exit orders.";
            }
            IndParam.ListParam[0].Index   = 0;
            IndParam.ListParam[0].Text    = IndParam.ListParam[0].ItemList[IndParam.ListParam[0].Index];
            IndParam.ListParam[0].Enabled = true;
            IndParam.ListParam[0].ToolTip = "Logic of application of the indicator.";

            IndParam.ListParam[1].Caption  = "Base price";
            IndParam.ListParam[1].ItemList = new string[] { "Close" };
            IndParam.ListParam[1].Index    = 0;
            IndParam.ListParam[1].Text     = IndParam.ListParam[1].ItemList[IndParam.ListParam[1].Index];
            IndParam.ListParam[1].Enabled  = true;

            return;
        }
        /// <summary>
        /// Sets the default indicator parameters for the designated slot type
        /// </summary>
        public Close_and_Reverse(SlotTypes slotType)
        {
            // General properties
            IndicatorName = "Close and Reverse";
            PossibleSlots = SlotTypes.Close;

            // Setting up the indicator parameters
            IndParam = new IndicatorParam();
            IndParam.IndicatorName = IndicatorName;
            IndParam.SlotType      = slotType;
            IndParam.IndicatorType = TypeOfIndicator.Additional;
            IndParam.ExecutionTime = ExecutionTime.CloseAndReverse;

            // The ComboBox parameters
            IndParam.ListParam[0].Caption  = "Logic";
            IndParam.ListParam[0].ItemList = new string[] { "Close all positions and open a new one in the opposite direction" };
            IndParam.ListParam[0].Index    = 0;
            IndParam.ListParam[0].Text     = IndParam.ListParam[0].ItemList[IndParam.ListParam[0].Index];
            IndParam.ListParam[0].Enabled  = true;
            IndParam.ListParam[0].ToolTip  = "Logic of application of the indicator.";

            return;
        }
        /// <summary>
        ///     Returns a copy
        /// </summary>
        public IndicatorParam Clone()
        {
            var indicatorParam = new IndicatorParam
            {
                SlotNumber = SlotNumber,
                IsDefined = IsDefined,
                SlotType = SlotType,
                IndicatorName = IndicatorName,
                IndicatorType = IndicatorType,
                ExecutionTime = ExecutionTime,
                IsDeafultGroupAll = IsDeafultGroupAll,
                IsAllowLTF = IsAllowLTF,
                ListParam = new ListParam[5],
                NumParam = new NumericParam[6],
                CheckParam = new CheckParam[2]
            };

            for (int i = 0; i < 5; i++)
                indicatorParam.ListParam[i] = ListParam[i].Clone();

            for (int i = 0; i < 6; i++)
                indicatorParam.NumParam[i] = NumParam[i].Clone();

            for (int i = 0; i < 2; i++)
                indicatorParam.CheckParam[i] = CheckParam[i].Clone();

            return indicatorParam;
        }
        /// <summary>
        ///     Sets the controls' parameters.
        /// </summary>
        private void UpdateFromIndicatorParam(IndicatorParam ip)
        {
            indicatorName = ip.IndicatorName;
            LblIndicator.Text = indicatorName;

            isPaintAllowed = false;

            // List params
            for (int i = 0; i < 5; i++)
            {
                ListParam[i].Items.Clear();
                ListParam[i].Items.AddRange(ip.ListParam[i].ItemList);
                ListLabel[i].Text = ip.ListParam[i].Caption;
                ListParam[i].SelectedIndex = ip.ListParam[i].Index;
                ListParam[i].Enabled = ip.ListParam[i].Enabled;
                toolTip.SetToolTip(ListParam[i], ip.ListParam[i].ToolTip);
            }

            // Numeric params
            for (int i = 0; i < 6; i++)
            {
                NumParam[i].BeginInit();
                NumLabel[i].Text = ip.NumParam[i].Caption;
                NumParam[i].Minimum = (decimal) ip.NumParam[i].Min;
                NumParam[i].Maximum = (decimal) ip.NumParam[i].Max;
                NumParam[i].Value = (decimal) ip.NumParam[i].Value;
                NumParam[i].DecimalPlaces = ip.NumParam[i].Point;
                NumParam[i].Increment = (decimal) Math.Pow(10, -ip.NumParam[i].Point);
                NumParam[i].Enabled = ip.NumParam[i].Enabled;
                NumParam[i].EndInit();
                toolTip.SetToolTip(NumParam[i],
                                   ip.NumParam[i].ToolTip + Environment.NewLine + "Minimum: " + NumParam[i].Minimum +
                                   " Maximum: " + NumParam[i].Maximum);
            }

            // Check params
            for (int i = 0; i < 2; i++)
            {
                CheckParam[i].Text = ip.CheckParam[i].Caption;
                CheckParam[i].Checked = ip.CheckParam[i].Checked;
                toolTip.SetToolTip(CheckParam[i], ip.CheckParam[i].ToolTip);

                if (Data.AutoUsePrvBarValue && ip.CheckParam[i].Caption == "Use previous bar value")
                    CheckParam[i].Enabled = false;
                else
                    CheckParam[i].Enabled = ip.CheckParam[i].Enabled;
            }

            isPaintAllowed = true;
        }