Describes a parameter represented by means of a NumericUpDown control.
        /// <summary>
        /// Creates an empty parameter.
        /// </summary>
        public IndicatorParam()
        {
            SlotNumber    = 0;
            IsDefined     = false;
            SlotType      = SlotTypes.NotDefined;
            IndicatorName = String.Empty;
            IndicatorType = TypeOfIndicator.Indicator;
            ExecutionTime = ExecutionTime.DuringTheBar;
            ListParam     = new ListParam[5];
            NumParam      = new NumericParam[6];
            CheckParam    = new CheckParam[2];

            for (int i = 0; i < 5; i++)
            {
                ListParam[i] = new ListParam();
            }

            for (int i = 0; i < 6; i++)
            {
                NumParam[i] = new NumericParam();
            }

            for (int i = 0; i < 2; i++)
            {
                CheckParam[i] = new CheckParam();
            }
        }
        /// <summary>
        /// Creates an empty parameter.
        /// </summary>
        public IndicatorParam()
        {
            slotNumb        = 0;
            isDefined       = false;
            slotType        = SlotTypes.NotDefined;
            indicatorName   = String.Empty;
            typeOfIndicator = TypeOfIndicator.Indicator;
            timeExecution   = ExecutionTime.DuringTheBar;
            aListParam      = new ListParam[5];
            aNumParam       = new NumericParam[6];
            aCheckParam     = new CheckParam[2];

            for (int i = 0; i < 5; i++)
            {
                aListParam[i] = new ListParam();
            }

            for (int i = 0; i < 6; i++)
            {
                aNumParam[i] = new NumericParam();
            }

            for (int i = 0; i < 2; i++)
            {
                aCheckParam[i] = new CheckParam();
            }
        }
예제 #3
0
        /// <summary>
        /// Returns a copy
        /// </summary>
        public NumericParam Clone()
        {
            NumericParam nparam = new NumericParam();

            nparam.caption = caption;
            nparam.val     = val;
            nparam.min     = min;
            nparam.max     = max;
            nparam.point   = point;
            nparam.enabled = enabled;
            nparam.tip     = tip;

            return(nparam);
        }
예제 #4
0
        /// <summary>
        /// Returns a copy
        /// </summary>
        public NumericParam Clone()
        {
            var numericParam = new NumericParam
            {
                Caption = Caption,
                Value   = Value,
                Min     = Min,
                Max     = Max,
                Point   = Point,
                Enabled = Enabled,
                ToolTip = ToolTip
            };


            return(numericParam);
        }
        /// <summary>
        /// Creates an empty parameter.
        /// </summary>
        public IndicatorParam()
        {
            slotNumb        = 0;
            isDefined       = false;
            slotType        = SlotTypes.NotDefined;
            indicatorName   = String.Empty;
            typeOfIndicator = TypeOfIndicator.Indicator;
            timeExecution   = ExecutionTime.DuringTheBar;
            aListParam      = new ListParam[5];
            aNumParam       = new NumericParam[6];
            aCheckParam     = new CheckParam[2];

            for (int i = 0; i < 5; i++)
                aListParam[i] = new ListParam();

            for (int i = 0; i < 6; i++)
                aNumParam[i] = new NumericParam();

            for (int i = 0; i < 2; i++)
                aCheckParam[i] = new CheckParam();
        }
        /// <summary>
        /// Creates an empty parameter.
        /// </summary>
        public IndicatorParam()
        {
            SlotNumber = 0;
            IsDefined = false;
            SlotType = SlotTypes.NotDefined;
            IndicatorName = String.Empty;
            IndicatorType = TypeOfIndicator.Indicator;
            ExecutionTime = ExecutionTime.DuringTheBar;
            ListParam = new ListParam[5];
            NumParam = new NumericParam[6];
            CheckParam = new CheckParam[2];

            for (int i = 0; i < 5; i++)
                ListParam[i] = new ListParam();

            for (int i = 0; i < 6; i++)
                NumParam[i] = new NumericParam();

            for (int i = 0; i < 2; i++)
                CheckParam[i] = new CheckParam();
        }
        /// <summary>
        /// Tests general parameters of a custom indicator.
        /// </summary>
        /// <param name="indicator">The indicator.</param>
        /// <param name="errorsList">List of the errors</param>
        /// <returns>True, if the test succeed.</returns>
        public static bool CustomIndicatorFastTest(Indicator indicator, out string errorsList)
        {
            bool isOk = true;

            StringBuilder sb = new StringBuilder();

            sb.AppendLine("ERROR: Indicator test failed for the '" + indicator.IndicatorName + "' indicator.");

            // Tests the IndicatorName property.
            if (string.IsNullOrEmpty(indicator.IndicatorName))
            {
                sb.AppendLine("\tThe property 'IndicatorName' is not set.");
                isOk = false;
            }

            // Tests the PossibleSlots property.
            if (!indicator.TestPossibleSlot(SlotTypes.Open) &&
                !indicator.TestPossibleSlot(SlotTypes.OpenFilter) &&
                !indicator.TestPossibleSlot(SlotTypes.Close) &&
                !indicator.TestPossibleSlot(SlotTypes.CloseFilter))
            {
                sb.AppendLine("\tThe property 'PossibleSlots' is not set.");
                isOk = false;
            }

            // Tests the CustomIndicator property.
            if (!indicator.CustomIndicator)
            {
                sb.AppendLine("\tThe indicator '" + indicator.IndicatorName + "' is not marked as custom. Set CustomIndicator = true;");
                isOk = false;
            }

            // Tests the SeparatedChartMaxValue properties.
            if (!indicator.SeparatedChart && indicator.SeparatedChartMaxValue != double.MinValue)
            {
                sb.AppendLine("\tSet SeparatedChart = true; or remove the property: SeparatedChartMaxValue = " + indicator.SeparatedChartMaxValue.ToString());
                isOk = false;
            }

            // Tests the SeparatedChartMinValue properties.
            if (!indicator.SeparatedChart && indicator.SeparatedChartMinValue != double.MaxValue)
            {
                sb.AppendLine("\tSet SeparatedChart = true; or remove the property: SeparatedChartMinValue = " + indicator.SeparatedChartMinValue.ToString());
                isOk = false;
            }

            // Tests the SpecialValues properties.
            if (!indicator.SeparatedChart && indicator.SpecialValues.Length > 0)
            {
                sb.AppendLine("\tSet SeparatedChart = true; or remove the property SpecialValues");
                isOk = false;
            }

            // Tests the IndParam properties.
            if (indicator.IndParam == null)
            {
                sb.AppendLine("\tThe property IndParam is not set. Set IndParam = new IndicatorParam();");
                isOk = false;
            }

            // Tests the IndParam.IndicatorName properties.
            if (indicator.IndParam.IndicatorName != indicator.IndicatorName)
            {
                sb.AppendLine("\tThe property IndParam.IndicatorName is not set. Set IndParam.IndicatorName = IndicatorName;");
                isOk = false;
            }

            // Tests the IndParam.SlotType properties.
            if (indicator.IndParam.SlotType != SlotTypes.NotDefined)
            {
                sb.AppendLine("\tThe property IndParam.SlotType is not set. Set IndParam.SlotType = slotType;");
                isOk = false;
            }

            // Tests the IndParam.ListParam properties.
            for (int iParam = 0; iParam < indicator.IndParam.ListParam.Length; iParam++)
            {
                ListParam listParam = indicator.IndParam.ListParam[iParam];
                if (!listParam.Enabled)
                {
                    continue;
                }

                if (string.IsNullOrEmpty(listParam.Caption))
                {
                    sb.AppendLine("\tThe property IndParam.ListParam[" + iParam + "].Caption is not set.");
                    isOk = false;
                }

                if (listParam.ItemList.Length == 0)
                {
                    sb.AppendLine("\tThe property IndParam.ListParam[" + iParam + "].ItemList is not set.");
                    isOk = false;
                }

                if (listParam.ItemList[listParam.Index] != listParam.Text)
                {
                    sb.AppendLine("\tThe property IndParam.ListParam[" + iParam + "].Text is wrong." +
                                  " Set " + "IndParam.ListParam[" + iParam + "].Text = IndParam.ListParam[" + iParam +
                                  "].ItemList[IndParam.ListParam[" + iParam + "].Index];");
                    isOk = false;
                }

                if (string.IsNullOrEmpty(listParam.ToolTip))
                {
                    sb.AppendLine("\tThe property IndParam.ListParam[" + iParam + "].ToolTip is not set.");
                    isOk = false;
                }
            }

            // Tests the IndParam.NumParam properties.
            for (int param = 0; param < indicator.IndParam.NumParam.Length; param++)
            {
                NumericParam numParam = indicator.IndParam.NumParam[param];
                if (!numParam.Enabled)
                {
                    continue;
                }

                if (string.IsNullOrEmpty(numParam.Caption))
                {
                    sb.AppendLine("\tThe property IndParam.NumParam[" + param + "].Caption is not set.");
                    isOk = false;
                }

                double value = numParam.Value;
                double min   = numParam.Min;
                double max   = numParam.Max;
                double point = numParam.Point;

                if (min > max)
                {
                    sb.AppendLine("\tIndParam.NumParam[" + param + "].Min > IndParam.NumParam[" + param + "].Max.");
                    isOk = false;
                }

                if (value > max)
                {
                    sb.AppendLine("\tIndParam.NumParam[" + param + "].Value > IndParam.NumParam[" + param + "].Max.");
                    isOk = false;
                }

                if (value < min)
                {
                    sb.AppendLine("\tIndParam.NumParam[" + param + "].Value < IndParam.NumParam[" + param + "].Min.");
                    isOk = false;
                }

                if (point < 0)
                {
                    sb.AppendLine("\tIndParam.NumParam[" + param + "].Point cannot be < 0");
                    isOk = false;
                }

                if (point > 6)
                {
                    sb.AppendLine("\tIndParam.NumParam[" + param + "].Point cannot be > 6");
                    isOk = false;
                }

                if (string.IsNullOrEmpty(numParam.ToolTip))
                {
                    sb.AppendLine("\tThe property IndParam.NumParam[" + param + "].ToolTip is not set.");
                    isOk = false;
                }
            }

            // Tests the IndParam.CheckParam properties.
            for (int param = 0; param < indicator.IndParam.CheckParam.Length; param++)
            {
                CheckParam checkParam = indicator.IndParam.CheckParam[param];
                if (!checkParam.Enabled)
                {
                    continue;
                }

                if (string.IsNullOrEmpty(checkParam.Caption))
                {
                    sb.AppendLine("\tThe property IndParam.CheckParam[" + param + "].Caption is not set.");
                    isOk = false;
                }

                if (string.IsNullOrEmpty(checkParam.ToolTip))
                {
                    sb.AppendLine("\tThe property IndParam.CheckParam[" + param + "].ToolTip is not set.");
                    isOk = false;
                }
            }

            try
            {
                indicator.Calculate(SlotTypes.NotDefined);
            }
            catch (Exception exc)
            {
                sb.AppendLine("\tError when executing Calculate(SlotTypes.NotDefined). " + exc.Message);
                isOk = false;
            }

            try
            {
                indicator.SetDescription(SlotTypes.NotDefined);
            }
            catch (Exception exc)
            {
                sb.AppendLine("\tError when executing SetDescription(SlotTypes.NotDefined). " + exc.Message);
                isOk = false;
            }

            try
            {
                indicator.ToString();
            }
            catch (Exception exc)
            {
                sb.AppendLine("\tError when executing ToString(). " + exc.Message);
                isOk = false;
            }

            if (isOk)
            {
                errorsList = string.Empty;
            }
            else
            {
                errorsList = sb.ToString();
            }

            return(isOk);
        }
        /// <summary>
        /// Returns a copy
        /// </summary>
        public NumericParam Clone()
        {
            var numericParam = new NumericParam
                                   {
                                       Caption = Caption,
                                       Value = Value,
                                       Min = Min,
                                       Max = Max,
                                       Point = Point,
                                       Enabled = Enabled,
                                       ToolTip = ToolTip
                                   };

            return numericParam;
        }
        /// <summary>
        /// Returns a copy
        /// </summary>
        public NumericParam Clone()
        {
            NumericParam nparam = new NumericParam();

            nparam.caption = caption;
            nparam.val     = val;
            nparam.min     = min;
            nparam.max     = max;
            nparam.point   = point;
            nparam.enabled = enabled;
            nparam.tip     = tip;

            return nparam;
        }