• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Entities.IndicatorComp类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ForexStrategyBuilder.Infrastructure.Entities.IndicatorComp的典型用法代码示例。如果您正苦于以下问题:C# IndicatorComp类的具体用法?C# IndicatorComp怎么用?C# IndicatorComp使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IndicatorComp类属于ForexStrategyBuilder.Infrastructure.Entities命名空间,在下文中一共展示了IndicatorComp类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Calculate

        public override void Calculate(IDataSet dataSet)
        {
            DataSet = dataSet;

            // Reading the parameters
            var entryHour = (int) IndParam.NumParam[0].Value;
            var entryMinute = (int) IndParam.NumParam[1].Value;
            var entryTime = new TimeSpan(entryHour, entryMinute, 0);

            // Calculation
            const int firstBar = 1;
            var adBars = new double[Bars];

            // Calculation of the logic
            for (int bar = firstBar; bar < Bars; bar++)
            {
                adBars[bar] = Time[bar].TimeOfDay == entryTime ? Open[bar] : 0;
            }

            // Saving the components
            Component = new IndicatorComp[1];

            Component[0] = new IndicatorComp
                {
                    CompName = "Entry hour",
                    DataType = IndComponentType.OpenPrice,
                    ChartType = IndChartType.NoChart,
                    ShowInDynInfo = false,
                    FirstBar = firstBar,
                    Value = adBars
                };
        }
开发者ID:jagatfx,项目名称:Forex-Strategy-Trader,代码行数:32,代码来源:EntryHour.cs


示例2: Calculate

        public override void Calculate(IDataSet dataSet)
        {
            DataSet = dataSet;

            // Calculation
            const int firstBar = 2;
            var adIb = new double[Bars];

            for (int iBar = 2; iBar < Bars; iBar++)
            {
                adIb[iBar] = ((High[iBar - 1] < High[iBar - 2]) && (Low[iBar - 1] > Low[iBar - 2])) ? 1 : 0;
            }

            // Saving the components
            Component = new IndicatorComp[2];

            Component[0] = new IndicatorComp
                {
                    CompName = "Allow long entry",
                    DataType = IndComponentType.AllowOpenLong,
                    ChartType = IndChartType.NoChart,
                    FirstBar = firstBar,
                    Value = adIb
                };

            Component[1] = new IndicatorComp
                {
                    CompName = "Allow short entry",
                    DataType = IndComponentType.AllowOpenShort,
                    ChartType = IndChartType.NoChart,
                    FirstBar = firstBar,
                    Value = adIb
                };
        }
开发者ID:kevinegstorf,项目名称:Forex-Strategy-Builder,代码行数:34,代码来源:InsideBar.cs


示例3: Calculate

        public override void Calculate(IDataSet dataSet)
        {
            DataSet = dataSet;

            // Reading the parameters
            var price = (BasePrice) IndParam.ListParam[1].Index;
            double margin = IndParam.NumParam[0].Value*Point;
            int prvs = IndParam.CheckParam[0].Checked ? 1 : 0;

            // TimeExecution
            if (price == BasePrice.Open && Math.Abs(margin - 0) < Epsilon)
                IndParam.ExecutionTime = ExecutionTime.AtBarOpening;
            else if (price == BasePrice.Close && Math.Abs(margin - 0) < Epsilon)
                IndParam.ExecutionTime = ExecutionTime.AtBarClosing;

            // Calculation
            double[] adBasePr = Price(price);
            var adUpBand = new double[Bars];
            var adDnBand = new double[Bars];

            int firstBar = 1 + prvs;

            for (int iBar = firstBar; iBar < Bars; iBar++)
            {
                adUpBand[iBar] = adBasePr[iBar - prvs] + margin;
                adDnBand[iBar] = adBasePr[iBar - prvs] - margin;
            }

            // Saving the components
            Component = new IndicatorComp[2];

            Component[0] = new IndicatorComp
                {
                    CompName = "Up Price",
                    ChartType = IndChartType.NoChart,
                    FirstBar = firstBar,
                    Value = adUpBand
                };

            Component[1] = new IndicatorComp
                {
                    CompName = "Down Price",
                    ChartType = IndChartType.NoChart,
                    FirstBar = firstBar,
                    Value = adDnBand
                };

            switch (IndParam.ListParam[0].Text)
            {
                case "Enter long after an upward move":
                    Component[0].DataType = IndComponentType.OpenLongPrice;
                    Component[1].DataType = IndComponentType.OpenShortPrice;
                    break;

                case "Enter long after a downward move":
                    Component[0].DataType = IndComponentType.OpenShortPrice;
                    Component[1].DataType = IndComponentType.OpenLongPrice;
                    break;
            }
        }
开发者ID:edisonh,项目名称:Forex-Strategy-Trader,代码行数:60,代码来源:PriceMove.cs


示例4: Calculate

        public override void Calculate(IDataSet dataSet)
        {
            DataSet = dataSet;

            if (!IsBacktester)
            {
                // FST sends the N bars for exit to the expert. Expert watches the position and closes it.
                return;
            }

            var nExit = (int) IndParam.NumParam[0].Value;

            // Saving the components
            Component = new IndicatorComp[1];

            Component[0] = new IndicatorComp
                {
                    CompName = "N Bars Exit (" + nExit.ToString(CultureInfo.InvariantCulture) + ")",
                    DataType = IndComponentType.ForceClose,
                    ChartType = IndChartType.NoChart,
                    ShowInDynInfo = true,
                    FirstBar = 1,
                    Value = new double[Bars]
                };
        }
开发者ID:edisonh,项目名称:Forex-Strategy-Trader,代码行数:25,代码来源:NBarsExit.cs


示例5: Calculate

        public override void Calculate(IDataSet dataSet)
        {
            DataSet = dataSet;

            // Calculation
            var adClosePrice = new double[Bars];

            for (int bar = 1; bar < Bars; bar++)
                if (Time[bar - 1].Day != Time[bar].Day)
                    adClosePrice[bar - 1] = Close[bar - 1];

            // Check the last bar
            TimeSpan tsBarClosing = Time[Bars - 1].TimeOfDay.Add(new TimeSpan(0, (int) Period, 0));
            var tsDayClosing = new TimeSpan(24, 0, 0);
            if (tsBarClosing == tsDayClosing)
                adClosePrice[Bars - 1] = Close[Bars - 1];

            // Saving the components
            Component = new IndicatorComp[1];

            Component[0] = new IndicatorComp
                {
                    CompName = "Closing price of the day",
                    DataType = IndComponentType.ClosePrice,
                    ChartType = IndChartType.NoChart,
                    FirstBar = 2,
                    Value = adClosePrice
                };
        }
开发者ID:kevinegstorf,项目名称:Forex-Strategy-Builder,代码行数:29,代码来源:DayClosing.cs


示例6: Calculate

        public override void Calculate(IDataSet dataSet)
        {
            DataSet = dataSet;

            // Reading the parameters
            var fromHour = (int) IndParam.NumParam[0].Value;
            var fromMin = (int) IndParam.NumParam[1].Value;
            var untilHour = (int) IndParam.NumParam[2].Value;
            var untilMin = (int) IndParam.NumParam[3].Value;
            var fromTime = new TimeSpan(fromHour, fromMin, 0);
            var untilTime = new TimeSpan(untilHour, untilMin, 0);

            // Calculation
            const int firstBar = 1;
            var adBars = new double[Bars];

            // Calculation of the logic
            for (int bar = firstBar; bar < Bars; bar++)
            {
                if (fromTime < untilTime)
                    adBars[bar] = Time[bar].TimeOfDay >= fromTime &&
                                  Time[bar].TimeOfDay < untilTime
                                      ? 1
                                      : 0;
                else if (fromTime > untilTime)
                    adBars[bar] = Time[bar].TimeOfDay >= fromTime ||
                                  Time[bar].TimeOfDay < untilTime
                                      ? 1
                                      : 0;
                else
                    adBars[bar] = 1;
            }

            // Saving the components
            Component = new IndicatorComp[2];

            Component[0] = new IndicatorComp
                {
                    CompName = "Is long entry allowed",
                    DataType = IndComponentType.AllowOpenLong,
                    ChartType = IndChartType.NoChart,
                    ShowInDynInfo = false,
                    FirstBar = firstBar,
                    Value = adBars
                };

            Component[1] = new IndicatorComp
                {
                    CompName = "Is short entry allowed",
                    DataType = IndComponentType.AllowOpenShort,
                    ChartType = IndChartType.NoChart,
                    ShowInDynInfo = false,
                    FirstBar = firstBar,
                    Value = adBars
                };
        }
开发者ID:edisonh,项目名称:Forex-Strategy-Trader,代码行数:56,代码来源:EntryTime.cs


示例7: Calculate

        public override void Calculate(IDataSet dataSet)
        {
            DataSet = dataSet;

            // Reading the parameters
            var dowFromDay = (DayOfWeek) IndParam.ListParam[1].Index;
            var dowUntilDay = (DayOfWeek) IndParam.ListParam[2].Index;

            // Calculation
            const int firstBar = 1;
            var signal = new double[Bars];

            // Calculation of the logic
            for (int bar = firstBar; bar < Bars; bar++)
            {
                if (dowFromDay < dowUntilDay)
                    signal[bar] = Time[bar].DayOfWeek >= dowFromDay &&
                                  Time[bar].DayOfWeek < dowUntilDay
                        ? 1
                        : 0;
                else if (dowFromDay > dowUntilDay)
                    signal[bar] = Time[bar].DayOfWeek >= dowFromDay ||
                                  Time[bar].DayOfWeek < dowUntilDay
                        ? 1
                        : 0;
                else
                    signal[bar] = 1;
            }

            // Saving the components
            Component = new IndicatorComp[2];

            Component[0] = new IndicatorComp
            {
                CompName = "Allow long entry",
                DataType = IndComponentType.AllowOpenLong,
                ChartType = IndChartType.NoChart,
                ShowInDynInfo = false,
                FirstBar = firstBar,
                Value = signal
            };

            Component[1] = new IndicatorComp
            {
                CompName = "Allow short entry",
                DataType = IndComponentType.AllowOpenShort,
                ChartType = IndChartType.NoChart,
                ShowInDynInfo = false,
                FirstBar = firstBar,
                Value = signal
            };
        }
开发者ID:dsimba,项目名称:FSB_Pro_Indicators,代码行数:52,代码来源:DaysOfWeek.cs


示例8: Calculate

        public override void Calculate(IDataSet dataSet)
        {
            DataSet = dataSet;

            // Reading the parameters
            var maMethod = (MAMethod) IndParam.ListParam[1].Index;
            var period = (int) IndParam.NumParam[0].Value;
            var multipl = (int) IndParam.NumParam[1].Value;
            int prev = IndParam.CheckParam[0].Checked ? 1 : 0;

            // Calculation
            int firstBar = period + 2;

            var atr = new double[Bars];

            for (int bar = 1; bar < Bars; bar++)
                atr[bar] = Math.Max(High[bar], Close[bar - 1]) - Math.Min(Low[bar], Close[bar - 1]);

            atr = MovingAverage(period, 0, maMethod, atr);

            var atrStop = new double[Bars];
            double pip = (Digits == 5 || Digits == 3) ? 10*Point : Point;
            double minStop = 5*pip;

            for (int bar = firstBar; bar < Bars - prev; bar++)
                atrStop[bar + prev] = Math.Max(atr[bar]*multipl, minStop);

            // Saving the components
            Component = new IndicatorComp[2];

            Component[0] = new IndicatorComp
                {
                    CompName = "ATR Stop margin",
                    DataType = IndComponentType.IndicatorValue,
                    FirstBar = firstBar,
                    ShowInDynInfo = false,
                    Value = atrStop
                };

            Component[1] = new IndicatorComp
                {
                    CompName = "ATR Stop for the transferred position",
                    DataType = IndComponentType.Other,
                    ShowInDynInfo = false,
                    FirstBar = firstBar,
                    Value = new double[Bars]
                };
        }
开发者ID:edisonh,项目名称:Forex-Strategy-Trader,代码行数:48,代码来源:AtrStop.cs


示例9: Calculate

        public override void Calculate(IDataSet dataSet)
        {
            DataSet = dataSet;

            // Saving the components
            Component = new IndicatorComp[1];

            Component[0] = new IndicatorComp
                {
                    CompName = "Trailing Stop for the transferred position",
                    DataType = IndComponentType.Other,
                    ShowInDynInfo = false,
                    FirstBar = 1,
                    Value = new double[Bars]
                };
        }
开发者ID:jagatfx,项目名称:Forex-Strategy-Trader,代码行数:16,代码来源:TrailingStop.cs


示例10: Calculate

        public override void Calculate(IDataSet dataSet)
        {
            DataSet = dataSet;

            // Saving the components
            Component = new IndicatorComp[1];

            Component[0] = new IndicatorComp
                {
                    CompName = "Opening price of the bar",
                    DataType = IndComponentType.OpenPrice,
                    ChartType = IndChartType.NoChart,
                    FirstBar = 2,
                    Value = Open
                };
        }
开发者ID:edisonh,项目名称:Forex-Strategy-Trader,代码行数:16,代码来源:BarOpening.cs


示例11: Calculate

        public override void Calculate(IDataSet dataSet)
        {
            DataSet = dataSet;

            // Saving the components
            Component = new IndicatorComp[1];

            Component[0] = new IndicatorComp
                {
                    CompName = "Close Price",
                    DataType = (IndParam.SlotType == SlotTypes.Open) ? IndComponentType.OpenPrice : IndComponentType.ClosePrice,
                    ChartType = IndChartType.NoChart,
                    FirstBar = 2,
                    Value = Close
                };
        }
开发者ID:edisonh,项目名称:Forex-Strategy-Trader,代码行数:16,代码来源:BarClosing.cs


示例12: Calculate

        public override void Calculate(IDataSet dataSet)
        {
            DataSet = dataSet;

            // Saving the components
            Component = new IndicatorComp[2];

            Component[0] = new IndicatorComp
                {
                    CompName = "Is long entry allowed",
                    DataType = IndComponentType.AllowOpenLong,
                    ChartType = IndChartType.NoChart,
                    FirstBar = 0,
                    Value = new double[Bars]
                };

            Component[1] = new IndicatorComp
                {
                    CompName = "Is short entry allowed",
                    DataType = IndComponentType.AllowOpenShort,
                    ChartType = IndChartType.NoChart,
                    FirstBar = 0,
                    Value = new double[Bars]
                };

            // Calculation of the logic
            switch (IndParam.ListParam[0].Text)
            {
                case "Open long positions only":
                    for (int i = 0; i < Bars; i++)
                    {
                        Component[0].Value[i] = 1;
                        Component[1].Value[i] = 0;
                    }
                    break;

                case "Open short positions only":
                    for (int i = 0; i < Bars; i++)
                    {
                        Component[0].Value[i] = 0;
                        Component[1].Value[i] = 1;
                    }
                    break;
            }
        }
开发者ID:jorgealvarado212,项目名称:Forex-Strategy-Builder,代码行数:45,代码来源:LongOrShort.cs


示例13: Calculate

        public override void Calculate(IDataSet dataSet)
        {
            DataSet = dataSet;

            // Reading the parameters
            int hour = (int) IndParam.NumParam[0].Value;
            int minute = (int) IndParam.NumParam[1].Value;

            // Calculation
            const int firstBar = 2;
            double[] signal = new double[Bars];

            // Calculation of the logic
            for (int bar = firstBar; bar < Bars; bar++)
            {
                DateTime closeTime = Time[bar].AddMinutes((int) Period);
                if (closeTime.Hour == hour && closeTime.Minute == minute)
                    signal[bar] = 1;
            }

            // Saving the components
            Component = new IndicatorComp[2];

            Component[0] = new IndicatorComp
            {
                CompName = "Close out long position",
                DataType = IndComponentType.ForceCloseLong,
                ChartType = IndChartType.NoChart,
                ShowInDynInfo = true,
                FirstBar = firstBar,
                Value = signal
            };

            Component[1] = new IndicatorComp
            {
                CompName = "Close out short position",
                DataType = IndComponentType.ForceCloseShort,
                ChartType = IndChartType.NoChart,
                ShowInDynInfo = true,
                FirstBar = firstBar,
                Value = signal
            };
        }
开发者ID:dsimba,项目名称:FSB_Pro_Indicators,代码行数:43,代码来源:ExitTime.cs


示例14: Calculate

        public override void Calculate(IDataSet dataSet)
        {
            DataSet = dataSet;

            // Reading the parameters
            var exitHour = (int) IndParam.NumParam[0].Value;
            var tsExitHour = new TimeSpan(exitHour, 0, 0);

            // Calculation
            const int firstBar = 1;
            var adBars = new double[Bars];

            // Calculation of the logic
            for (int bar = firstBar; bar < Bars; bar++)
            {
                if (Time[bar - 1].DayOfYear == Time[bar].DayOfYear &&
                    Time[bar - 1].TimeOfDay < tsExitHour &&
                    Time[bar].TimeOfDay >= tsExitHour)
                    adBars[bar - 1] = Close[bar - 1];
                else if (Time[bar - 1].DayOfYear != Time[bar].DayOfYear &&
                         Time[bar - 1].TimeOfDay < tsExitHour)
                    adBars[bar - 1] = Close[bar - 1];
                else
                    adBars[bar] = 0;
            }

            // Check the last bar
            if (Time[Bars - 1].TimeOfDay.Add(new TimeSpan(0, (int) Period, 0)) == tsExitHour)
                adBars[Bars - 1] = Close[Bars - 1];

            // Saving the components
            Component = new IndicatorComp[1];

            Component[0] = new IndicatorComp
                {
                    CompName = "Exit hour",
                    DataType = IndComponentType.ClosePrice,
                    ChartType = IndChartType.NoChart,
                    ShowInDynInfo = false,
                    FirstBar = firstBar,
                    Value = adBars
                };
        }
开发者ID:jagatfx,项目名称:Forex-Strategy-Trader,代码行数:43,代码来源:ExitHour.cs


示例15: Calculate

        public override void Calculate(IDataSet dataSet)
        {
            DataSet = dataSet;

            // Calculation
            var adOpenPrice = new double[Bars];

            for (int iBar = 1; iBar < Bars; iBar++)
                if (Time[iBar - 1].Day != Time[iBar].Day)
                    adOpenPrice[iBar] = Open[iBar];

            // Saving the components
            Component = new IndicatorComp[1];

            Component[0] = new IndicatorComp
                {
                    CompName = "Opening price of the day",
                    DataType = IndComponentType.OpenPrice,
                    ChartType = IndChartType.NoChart,
                    FirstBar = 2,
                    Value = adOpenPrice
                };
        }
开发者ID:edisonh,项目名称:Forex-Strategy-Trader,代码行数:23,代码来源:DayOpening.cs


示例16: Calculate

        public override void Calculate(IDataSet dataSet)
        {
            DataSet = dataSet;

            // Calculation
            const int firstBar = 1;
            var adBars = new double[Bars];

            // Calculation of the logic
            for (int bar = 0; bar < Bars - 1; bar++)
            {
                if (Time[bar].DayOfWeek > DayOfWeek.Wednesday &&
                    Time[bar + 1].DayOfWeek < DayOfWeek.Wednesday)
                    adBars[bar] = Close[bar];
                else
                    adBars[bar] = 0;
            }

            // Check the last bar
            TimeSpan tsBarClosing = Time[Bars - 1].TimeOfDay.Add(new TimeSpan(0, (int) Period, 0));
            var tsDayClosing = new TimeSpan(24, 0, 0);
            if (Time[Bars - 1].DayOfWeek == DayOfWeek.Friday && tsBarClosing == tsDayClosing)
                adBars[Bars - 1] = Close[Bars - 1];

            // Saving the components
            Component = new IndicatorComp[1];

            Component[0] = new IndicatorComp
                {
                    CompName = "Week Closing",
                    DataType = IndComponentType.ClosePrice,
                    ChartType = IndChartType.NoChart,
                    ShowInDynInfo = false,
                    FirstBar = firstBar,
                    Value = adBars
                };
        }
开发者ID:edisonh,项目名称:Forex-Strategy-Trader,代码行数:37,代码来源:WeekClosing.cs


示例17: Calculate

        public override void Calculate(IDataSet dataSet)
        {
            DataSet = dataSet;

            var fromHour = (int) IndParam.NumParam[0].Value;
            var fromMin = (int) IndParam.NumParam[1].Value;
            var untilHour = (int) IndParam.NumParam[2].Value;
            var untilMin = (int) IndParam.NumParam[3].Value;

            var tsFromTime = new TimeSpan(fromHour, fromMin, 0);
            var tsUntilTime = new TimeSpan(untilHour, untilMin, 0);

            double shift = IndParam.NumParam[4].Value*Point;

            const int firstBar = 2;

            // Calculation
            var adHighPrice = new double[Bars];
            var adLowPrice = new double[Bars];

            double dMinPrice = double.MaxValue;
            double dMaxPrice = double.MinValue;
            adHighPrice[0] = 0;
            adLowPrice[0] = 0;

            bool bPrevPeriod = false;
            for (int iBar = 1; iBar < Bars; iBar++)
            {
                bool bPeriod;

                if (tsFromTime < tsUntilTime)
                    bPeriod = Time[iBar].TimeOfDay >= tsFromTime && Time[iBar].TimeOfDay < tsUntilTime;
                else if (tsFromTime > tsUntilTime)
                    bPeriod = Time[iBar].TimeOfDay >= tsFromTime || Time[iBar].TimeOfDay < tsUntilTime;
                else
                    bPeriod = true;

                if (bPeriod)
                {
                    if (dMaxPrice < High[iBar]) dMaxPrice = High[iBar];
                    if (dMinPrice > Low[iBar]) dMinPrice = Low[iBar];
                }

                if (!bPeriod && bPrevPeriod)
                {
                    adHighPrice[iBar] = dMaxPrice;
                    adLowPrice[iBar] = dMinPrice;
                    dMaxPrice = double.MinValue;
                    dMinPrice = double.MaxValue;
                }
                else
                {
                    adHighPrice[iBar] = adHighPrice[iBar - 1];
                    adLowPrice[iBar] = adLowPrice[iBar - 1];
                }

                bPrevPeriod = bPeriod;
            }

            // Shifting the price
            var adUpperBand = new double[Bars];
            var adLowerBand = new double[Bars];
            for (int iBar = firstBar; iBar < Bars; iBar++)
            {
                adUpperBand[iBar] = adHighPrice[iBar] + shift;
                adLowerBand[iBar] = adLowPrice[iBar] - shift;
            }

            // Saving the components
            Component = new IndicatorComp[4];

            Component[0] = new IndicatorComp
                {
                    CompName = "Hourly High",
                    DataType = IndComponentType.IndicatorValue,
                    ChartType = IndChartType.Level,
                    ChartColor = Color.DarkGreen,
                    FirstBar = firstBar,
                    Value = adHighPrice
                };

            Component[1] = new IndicatorComp
                {
                    CompName = "Hourly Low",
                    DataType = IndComponentType.IndicatorValue,
                    ChartType = IndChartType.Level,
                    ChartColor = Color.DarkRed,
                    FirstBar = firstBar,
                    Value = adLowPrice
                };

            Component[2] = new IndicatorComp
                {
                    ChartType = IndChartType.NoChart,
                    FirstBar = firstBar,
                    Value = new double[Bars]
                };

            Component[3] = new IndicatorComp
                {
//.........这里部分代码省略.........
开发者ID:kevinegstorf,项目名称:Forex-Strategy-Builder,代码行数:101,代码来源:HourlyHighLow.cs


示例18: Calculate

        public override void Calculate(IDataSet dataSet)
        {
            DataSet = dataSet;

            // Reading the parameters
            var maMethod = (MAMethod) IndParam.ListParam[1].Index;
            var basePrice = (BasePrice) IndParam.ListParam[2].Index;
            var iPeriod = (int) IndParam.NumParam[0].Value;
            var iSmooth = (int) IndParam.NumParam[1].Value;
            double dLevel = IndParam.NumParam[2].Value;
            int iPrvs = IndParam.CheckParam[0].Checked ? 1 : 0;

            int iFirstBar = iPrvs + iPeriod + iSmooth + 2;
            var adMomentum = new double[Bars];
            double[] adBasePrice = Price(basePrice);

            for (int iBar = iPeriod; iBar < Bars; iBar++)
                adMomentum[iBar] = adBasePrice[iBar] - adBasePrice[iBar - iPeriod];

            if (iSmooth > 0)
                adMomentum = MovingAverage(iSmooth, 0, maMethod, adMomentum);

            // Saving the components
            Component = new IndicatorComp[3];

            Component[0] = new IndicatorComp
                {
                    CompName = "Momentum",
                    DataType = IndComponentType.IndicatorValue,
                    ChartType = IndChartType.Line,
                    ChartColor = Color.Blue,
                    FirstBar = iFirstBar,
                    Value = adMomentum
                };

            Component[1] = new IndicatorComp
                {
                    ChartType = IndChartType.NoChart,
                    FirstBar = iFirstBar,
                    Value = new double[Bars]
                };

            Component[2] = new IndicatorComp
                {
                    ChartType = IndChartType.NoChart,
                    FirstBar = iFirstBar,
                    Value = new double[Bars]
                };

            // Sets the Component's type
            if (SlotType == SlotTypes.OpenFilter)
            {
                Component[1].DataType = IndComponentType.AllowOpenLong;
                Component[1].CompName = "Is long entry allowed";
                Component[2].DataType = IndComponentType.AllowOpenShort;
                Component[2].CompName = "Is short entry allowed";
            }
            else if (SlotType == SlotTypes.CloseFilter)
            {
                Component[1].DataType = IndComponentType.ForceCloseLong;
                Component[1].CompName = "Close out long position";
                Component[2].DataType = IndComponentType.ForceCloseShort;
                Component[2].CompName = "Close out short position";
            }

            // Calculation of the logic
            var indLogic = IndicatorLogic.It_does_not_act_as_a_filter;

            switch (IndParam.ListParam[0].Text)
            {
                case "Momentum rises":
                    indLogic = IndicatorLogic.The_indicator_rises;
                    SpecialValues = new double[] {0};
                    break;

                case "Momentum falls":
                    indLogic = IndicatorLogic.The_indicator_falls;
                    SpecialValues = new double[] {0};
                    break;

                case "Momentum is higher than the Level line":
                    indLogic = IndicatorLogic.The_indicator_is_higher_than_the_level_line;
                    SpecialValues = new[] {dLevel, -dLevel};
                    break;

                case "Momentum is lower than the Level line":
                    indLogic = IndicatorLogic.The_indicator_is_lower_than_the_level_line;
                    SpecialValues = new[] {dLevel, -dLevel};
                    break;

                case "Momentum crosses the Level line upward":
                    indLogic = IndicatorLogic.The_indicator_crosses_the_level_line_upward;
                    SpecialValues = new[] {dLevel, -dLevel};
                    break;

                case "Momentum crosses the Level line downward":
                    indLogic = IndicatorLogic.The_indicator_crosses_the_level_line_downward;
                    SpecialValues = new[] {dLevel, -dLevel};
                    break;

//.........这里部分代码省略.........
开发者ID:edisonh,项目名称:Forex-Strategy-Trader,代码行数:101,代码来源:Momentum.cs


示例19: Calculate

        public override void Calculate(IDataSet dataSet)
        {
            DataSet = dataSet;

            // Reading the parameters
            var maSignalMAMethod = (MAMethod) IndParam.ListParam[2].Index;
            var period1 = (int) IndParam.NumParam[0].Value;
            var period2 = (int) IndParam.NumParam[1].Value;
            int prvs = IndParam.CheckParam[0].Checked ? 1 : 0;

            // Calculation
            int firstBar = period1 + period2 + 2;
            var adOscillator = new double[Bars];

// ---------------------------------------------------------
            var roc1 = new RateOfChange();
            roc1.Initialize(SlotType);
            roc1.IndParam.ListParam[1].Index = IndParam.ListParam[1].Index;
            roc1.IndParam.ListParam[2].Index = IndParam.ListParam[3].Index;
            roc1.IndParam.NumParam[0].Value = IndParam.NumParam[0].Value;
            roc1.IndParam.CheckParam[0].Checked = IndParam.CheckParam[0].Checked;
            roc1.Calculate(DataSet);

            double[] adIndicator1 = roc1.Component[0].Value;
            double[] adIndicator2 = MovingAverage(period2, 0, maSignalMAMethod, adIndicator1);
// ----------------------------------------------------------

            for (int bar = firstBar; bar < Bars; bar++)
            {
                adOscillator[bar] = adIndicator1[bar] - adIndicator2[bar];
            }

            // Saving the components
            Component = new IndicatorComp[3];

            Component[0] = new IndicatorComp
                {
                    CompName = "Oscillator",
                    DataType = IndComponentType.IndicatorValue,
                    ChartType = IndChartType.Histogram,
                    FirstBar = firstBar,
                    Value = adOscillator
                };

            Component[1] = new IndicatorComp
                {
                    ChartType = IndChartType.NoChart,
                    FirstBar = firstBar,
                    Value = new double[Bars]
                };

            Component[2] = new IndicatorComp
                {
                    ChartType = IndChartType.NoChart,
                    FirstBar = firstBar,
                    Value = new double[Bars]
                };

            // Sets the Component's type
            if (SlotType == SlotTypes.OpenFilter)
            {
                Component[1].DataType = IndComponentType.AllowOpenLong;
                Component[1].CompName = "Is long entry allowed";
                Component[2].DataType = IndComponentType.AllowOpenShort;
                Component[2].CompName = "Is short entry allowed";
            }
            else if (SlotType == SlotTypes.CloseFilter)
            {
                Component[1].DataType = IndComponentType.ForceCloseLong;
                Component[1].CompName = "Close out long position";
                Component[2].DataType = IndComponentType.ForceCloseShort;
                Component[2].CompName = "Close out short position";
            }

            // Calculation of the logic
            var indLogic = IndicatorLogic.It_does_not_act_as_a_filter;

            switch (IndParam.ListParam[0].Text)
            {
                case "ROC MA Oscillator rises":
                    indLogic = IndicatorLogic.The_indicator_rises;
                    break;

                case "ROC MA Oscillator falls":
                    indLogic = IndicatorLogic.The_indicator_falls;
                    break;

                case "ROC MA Oscillator is higher than the zero line":
                    indLogic = IndicatorLogic.The_indicator_is_higher_than_the_level_line;
                    break;

                case "ROC MA Oscillator is lower than the zero line":
                    indLogic = IndicatorLogic.The_indicator_is_lower_than_the_level_line;
                    break;

                case "ROC MA Oscillator crosses the zero line upward":
                    indLogic = IndicatorLogic.The_indicator_crosses_the_level_line_upward;
                    break;

                case "ROC MA Oscillator crosses the zero line downward":
//.........这里部分代码省略.........
开发者ID:jorgealvarado212,项目名称:Forex-Strategy-Builder,代码行数:101,代码来源:RocMaOscillator.cs


示例20: Calculate

        public override void Calculate(IDataSet dataSet)
        {
            DataSet = dataSet;

            // Reading the parameters
            var maMethod = (MAMethod) IndParam.ListParam[1].Index;
            var basePrice = (BasePrice) IndParam.ListParam[2].Index;
            var iPeriod = (int) IndParam.NumParam[0].Value;
            var iSmooth = (int) IndParam.NumParam[1].Value;
            int iPrvs = IndParam.CheckParam[0].Checked ? 1 : 0;

            // Calculation
            int iFirstBar = iPeriod + 2;

            double[] adBasePrice = Price(basePrice);
            var adCumulativeSum = new double[Bars];

            adCumulativeSum[iPeriod - 1] = 0;

            for (int iBar = 0; iBar < iPeriod; iBar++)
            {
                adCumulativeSum[iPeriod - 1] += adBasePrice[iBar];
            }

            for (int iBar = iPeriod; iBar < Bars; iBar++)
            {
                adCumulativeSum[iBar] = adCumulativeSum[iBar - 1] - adBasePrice[iBar - iPeriod] + adBasePrice[iBar];
            }

            adCumulativeSum = MovingAverage(iSmooth, 0, maMethod, adCumulativeSum);

            // Saving the components
            Component = new IndicatorComp[3];

            Component[0] = new IndicatorComp
                {
                    CompName = "Cumulative Sum",
                    DataType = IndComponentType.IndicatorValue,
                    ChartType = IndChartType.Line,
                    ChartColor = Color.Blue,
                    FirstBar = iFirstBar,
                    Value = adCumulativeSum
                };

            Component[1] = new IndicatorComp
                {
                    ChartType = IndChartType.NoChart,
                    FirstBar = iFirstBar,
                    Value = new double[Bars]
                };

            Component[2] = new IndicatorComp
                {
                    ChartType = IndChartType.NoChart,
                    FirstBar = iFirstBar,
                    Value = new double[Bars]
                };

            // Sets the Component's type
            if (SlotType == SlotTypes.OpenFilter)
            {
                Component[1].DataType = IndComponentType.AllowOpenLong;
                Component[1].CompName = "Is long entry allowed";
                Component[2].DataType = IndComponentType.AllowOpenShort;
                Component[2].CompName = "Is short entry allowed";
            }
            else if (SlotType == SlotTypes.CloseFilter)
            {
                Component[1].DataType = IndComponentType.ForceCloseLong;
                Component[1].CompName = "Close out long position";
                Component[2].DataType = IndComponentType.ForceCloseShort;
                Component[2].CompName = "Close out short position";
            }

            // Calculation of the logic
            var indLogic = IndicatorLogic.It_does_not_act_as_a_filter;

            switch (IndParam.ListParam[0].Text)
            {
                case "Cumulative Sum rises":
                    indLogic = IndicatorLogic.The_indicator_rises;
                    break;

                case "Cumulative Sum falls":
                    indLogic = IndicatorLogic.The_indicator_falls;
                    break;

                case "Cumulative Sum changes its direction upward":
                    indLogic = IndicatorLogic.The_indicator_changes_its_direction_upw 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Foundation.Foundation类代码示例发布时间:2022-05-26
下一篇:
C# Forays.PhysicalObject类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap