当前位置: 首页>>代码示例>>C#>>正文


C# StockSerie类代码示例

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


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

示例1: ApplyTo

        public override void ApplyTo(StockSerie stockSerie)
        {
            // Calculate Bands
             int period = (int)this.parameters[0];
             FloatSerie ema = stockSerie.GetIndicator("EMA(" + period + ")").Series[0];
             FloatSerie atr = stockSerie.GetIndicator("ATR(" + period + ")").Series[0];

             float upCoef = (float)this.parameters[1];
             float downCoef = (float)this.parameters[2];

             FloatSerie upperKeltnerBand = ema + atr * upCoef;
             this.series[0] = upperKeltnerBand;
             this.Series[0].Name = this.SerieNames[0];

             FloatSerie lowerKeltnerBand = ema + atr * downCoef;
             this.series[1] = lowerKeltnerBand;
             this.Series[1].Name = this.SerieNames[1];

             // Detecting events
             this.CreateEventSeries(stockSerie.Count);

             FloatSerie closeSerie = stockSerie.GetSerie(StockDataType.CLOSE);
             FloatSerie lowSerie = stockSerie.GetSerie(StockDataType.LOW);
             FloatSerie highSerie = stockSerie.GetSerie(StockDataType.HIGH);

             for (int i = 1; i < upperKeltnerBand.Count; i++)
             {
            this.eventSeries[0][i] = closeSerie[i] > upperKeltnerBand[i];
            this.eventSeries[1][i] = closeSerie[i] < lowerKeltnerBand[i];
            this.eventSeries[2][i] = closeSerie[i] >= lowerKeltnerBand[i] && closeSerie[i] <= upperKeltnerBand[i];
             }
        }
开发者ID:dadelcarbo,项目名称:StockAnalyzer,代码行数:32,代码来源:StockIndicator_KeltnerBand.cs

示例2: StockAlertDef

 public StockAlertDef(StockSerie.StockBarDuration barDuration, string indicatorType, string indicatorName, string eventName)
 {
     this.BarDuration = barDuration;
      this.IndicatorType = indicatorType;
      this.IndicatorName = indicatorName;
      this.EventName = eventName;
 }
开发者ID:dadelcarbo,项目名称:StockAnalyzer,代码行数:7,代码来源:StockAlertDef.cs

示例3: ApplyTo

        public override void ApplyTo(StockSerie stockSerie)
        {
            // Calculate Bands
             int period = (int)this.parameters[0];
             FloatSerie ema = stockSerie.GetIndicator("EMA(" + period + ")").Series[0];
             FloatSerie highEma = stockSerie.GetSerie(StockDataType.HIGH).CalculateEMA(period);
             FloatSerie lowEma = stockSerie.GetSerie(StockDataType.LOW).CalculateEMA(period);
             FloatSerie diff = highEma - lowEma;

             FloatSerie atr = stockSerie.GetIndicator("ATR(" + period + ")").Series[0];

             float upCoef = (float)this.parameters[1];
             float downCoef = (float)this.parameters[2];

             FloatSerie upperMYBAND = ema + diff * upCoef;
             this.series[0] = upperMYBAND;
             this.Series[0].Name = this.SerieNames[0];

             FloatSerie lowerMYBAND = ema + diff * downCoef;
             this.series[1] = lowerMYBAND;
             this.Series[1].Name = this.SerieNames[1];

             this.series[2] = ema;

             // Detecting events
             this.CreateEventSeries(stockSerie.Count);

             FloatSerie closeSerie = stockSerie.GetSerie(StockDataType.CLOSE);
             FloatSerie lowSerie = stockSerie.GetSerie(StockDataType.LOW);
             FloatSerie highSerie = stockSerie.GetSerie(StockDataType.HIGH);

             bool waitingForBearSignal = false;
             bool waitingForBullSignal = false;

             for (int i = 1; i < upperMYBAND.Count; i++)
             {
            if (waitingForBearSignal && highSerie[i - 1] >= highSerie[i] && closeSerie[i - 1] >= closeSerie[i])
            {
               // BearishSignal
               this.eventSeries[3][i] = true;
               waitingForBearSignal = false;
            }
            if (highSerie[i] >= upperMYBAND[i])
            {
               waitingForBearSignal = true;
               this.eventSeries[0][i] = true;
            }
            if (waitingForBullSignal && lowSerie[i - 1] <= lowSerie[i] && closeSerie[i - 1] <= closeSerie[i])
            {
               // BullishSignal
               this.eventSeries[2][i] = true;
               waitingForBullSignal = false;
            }
            if (lowSerie[i] <= lowerMYBAND[i])
            {
               waitingForBullSignal = true;
               this.eventSeries[1][i] = lowSerie[i] <= lowerMYBAND[i];
            }
             }
        }
开发者ID:dadelcarbo,项目名称:StockAnalyzer,代码行数:60,代码来源:StockIndicator_MYBAND.cs

示例4: ApplyTo

        public override void ApplyTo(StockSerie stockSerie)
        {
            FloatSerie longStopSerie;
             FloatSerie shortStopSerie;
             FloatSerie highSerie = stockSerie.GetSerie(StockDataType.HIGH);
             FloatSerie lowSerie = stockSerie.GetSerie(StockDataType.LOW);

             float indicatorMax = (float)this.Parameters[2];
             float indicatorCenter = (float)this.Parameters[3];
             float indicatorWeight = (float)this.Parameters[4];

             stockSerie.CalculateVarTrailStop((int)this.Parameters[0], ((string)this.Parameters[1]).Replace('_', ','), indicatorMax, indicatorCenter, indicatorWeight, out longStopSerie, out shortStopSerie);
             this.Series[0] = longStopSerie;
             this.Series[1] = shortStopSerie;

             // Detecting events
             this.CreateEventSeries(stockSerie.Count);

             for (int i = (int)this.Parameters[0]; i < stockSerie.Count; i++)
             {
            this.Events[0][i] = !float.IsNaN(longStopSerie[i]);
            this.Events[1][i] = !float.IsNaN(shortStopSerie[i]);
            this.Events[2][i] = float.IsNaN(longStopSerie[i - 1]) && !float.IsNaN(longStopSerie[i]);
            this.Events[3][i] = float.IsNaN(shortStopSerie[i - 1]) && !float.IsNaN(shortStopSerie[i]);
            this.Events[4][i] = !float.IsNaN(longStopSerie[i - 1]) && !float.IsNaN(longStopSerie[i]) && longStopSerie[i - 1] < longStopSerie[i];
            this.Events[5][i] = !float.IsNaN(shortStopSerie[i - 1]) && !float.IsNaN(shortStopSerie[i]) && shortStopSerie[i - 1] > shortStopSerie[i];
            this.Events[6][i] = !float.IsNaN(longStopSerie[i]) && !float.IsNaN(longStopSerie[i - 1]) && lowSerie[i] > longStopSerie[i] && lowSerie[i - 1] <= longStopSerie[i - 1];
            this.Events[7][i] = !float.IsNaN(shortStopSerie[i]) && !float.IsNaN(shortStopSerie[i - 1]) && highSerie[i] < shortStopSerie[i] && highSerie[i - 1] >= shortStopSerie[i - 1];
             }
        }
开发者ID:dadelcarbo,项目名称:StockAnalyzer,代码行数:30,代码来源:StockTrailStop_TRAILVAR.cs

示例5: ApplyTo

        public override void ApplyTo(StockSerie stockSerie)
        {
            int period = (int)this.parameters[0];

             IStockIndicator momentum = stockSerie.GetIndicator("MOMENTUM(" + period + ",1,10)");
             FloatSerie momentumSerie = momentum.Series[0];

             FloatSerie atrSerie = stockSerie.GetSerie(StockDataType.ATR);
             FloatSerie distSerie = momentumSerie.Div(atrSerie.Cumul(period));

             //cciSerie = cciSerie.CalculateSigmoid(100f, 0.02f).CalculateEMA((int)Math.Sqrt();
             //FloatSerie closeSerie = stockSerie.GetSerie(StockDataType.CLOSE);
             //for (int i = 10; i < cciSerie.Count; i++)
             //{
             //    if (cciSerie[i] > overbought && cciSerie[i] <= cciSerie[i - 1] && closeSerie[i] >= closeSerie[i-1])
             //    {
             //        cciSerie[i] = cciSerie[i - 1] + (100 - cciSerie[i - 1]) / 4f;
             //    }
             //    else if (cciSerie[i] < oversold && cciSerie[i] >= cciSerie[i - 1] && closeSerie[i] <= closeSerie[i-1])
             //    {
             //        cciSerie[i] = cciSerie[i - 1] *0.75f;
             //    }
             //}

             this.series[0] = distSerie;
             this.series[0].Name = this.Name;
        }
开发者ID:dadelcarbo,项目名称:StockAnalyzer,代码行数:27,代码来源:StockIndicator_DIST.cs

示例6: Initialise

 public override void Initialise(StockSerie stockSerie, StockOrder lastBuyOrder, bool supportShortSelling)
 {
     base.Initialise(stockSerie, lastBuyOrder, supportShortSelling);
      this.oscSerie = null;
      this.trailStop = StockTrailStopManager.CreateTrailStop("TRAILHL(3)");
      this.trailStop.ApplyTo(stockSerie);
 }
开发者ID:dadelcarbo,项目名称:StockAnalyzer,代码行数:7,代码来源:MyOSCSimpleStrategy.cs

示例7: StockStrategyScannerDlg

        public StockStrategyScannerDlg(StockDictionary stockDictionary, StockSerie.Groups stockGroup, StockSerie.StockBarDuration barDuration, string strategyName)
        {
            InitializeComponent();

             this.stockDictionary = stockDictionary;
             this.barDuration = barDuration;

             // Initialise group combo box
             groupComboBox.Items.AddRange(this.stockDictionary.GetValidGroupNames().ToArray());
             groupComboBox.SelectedItem = stockGroup.ToString();
             groupComboBox.SelectedValueChanged += new EventHandler(groupComboBox_SelectedValueChanged);

             // Initialise Strategy Combo box
             this.strategyComboBox.Items.Clear();
             List<string> strategyList = StrategyManager.GetStrategyList();
             foreach (string name in strategyList)
             {
            this.strategyComboBox.Items.Add(name);
             }
             this.strategyComboBox.SelectedItem = strategyName;
             this.strategyComboBox.SelectedValueChanged += new EventHandler(strategyComboBox_SelectedValueChanged);

             periodComboBox.SelectedIndex = 0;

             OnBarDurationChanged(barDuration);
        }
开发者ID:dadelcarbo,项目名称:StockAnalyzer,代码行数:26,代码来源:StockStrategyScannerDlg.cs

示例8: ApplyTo

        public override void ApplyTo(StockSerie stockSerie)
        {
            FloatSerie longStopSerie;
             FloatSerie shortStopSerie;

             FloatSerie lowSerie = stockSerie.GetSerie(StockDataType.LOW);
             FloatSerie HighSerie = stockSerie.GetSerie(StockDataType.HIGH);

             IStockIndicator bbIndicator = stockSerie.GetIndicator(this.Name.Replace("TRAIL", ""));
             stockSerie.CalculateBBTrailStop(bbIndicator.Series[1], bbIndicator.Series[0], out longStopSerie, out shortStopSerie);
             this.Series[0] = longStopSerie;
             this.Series[1] = shortStopSerie;

             // Detecting events
             this.CreateEventSeries(stockSerie.Count);

             for (int i = 5; i < stockSerie.Count; i++)
             {
            bool upTrend;
            this.Events[0][i] = upTrend = float.IsNaN(shortStopSerie[i]);
            this.Events[1][i] = !upTrend;
            this.Events[2][i] = upTrend && !this.Events[0][i - 1];
            this.Events[3][i] = !upTrend && !this.Events[1][i - 1];
            this.Events[4][i] = upTrend && this.Events[0][i - 1] && lowSerie[i - 1] <= longStopSerie[i - 1] && lowSerie[i] > longStopSerie[i];
            this.Events[5][i] = !upTrend && this.Events[1][i - 1] && HighSerie[i - 1] >= shortStopSerie[i - 1] && HighSerie[i] < shortStopSerie[i]; ;
             }
        }
开发者ID:dadelcarbo,项目名称:StockAnalyzer,代码行数:27,代码来源:StockTrailStop_TRAILBB.cs

示例9: ApplyTo

        public override void ApplyTo(StockSerie stockSerie)
        {
            FloatSerie longStopSerie;
             FloatSerie shortStopSerie;
             FloatSerie highSerie = stockSerie.GetSerie(StockDataType.HIGH);
             FloatSerie lowSerie = stockSerie.GetSerie(StockDataType.LOW);

             stockSerie.CalculateHLAVGTrailStop((int)this.Parameters[0], (int)this.Parameters[1], out longStopSerie, out shortStopSerie);
             this.Series[0] = longStopSerie;
             this.Series[1] = shortStopSerie;

             // Detecting events
             this.CreateEventSeries(stockSerie.Count);

             for (int i = 5; i < stockSerie.Count; i++)
             {
            this.Events[0][i] = !float.IsNaN(longStopSerie[i]);
            this.Events[1][i] = !float.IsNaN(shortStopSerie[i]);
            this.Events[2][i] = float.IsNaN(longStopSerie[i - 1]) && !float.IsNaN(longStopSerie[i]);
            this.Events[3][i] = float.IsNaN(shortStopSerie[i - 1]) && !float.IsNaN(shortStopSerie[i]);
            this.Events[4][i] = !float.IsNaN(longStopSerie[i - 1]) && !float.IsNaN(longStopSerie[i]) && longStopSerie[i - 1] < longStopSerie[i];
            this.Events[5][i] = !float.IsNaN(shortStopSerie[i - 1]) && !float.IsNaN(shortStopSerie[i]) && shortStopSerie[i - 1] > shortStopSerie[i];
            this.Events[6][i] = !float.IsNaN(longStopSerie[i]) && !float.IsNaN(longStopSerie[i - 1]) && lowSerie[i] > longStopSerie[i] && lowSerie[i - 1] <= longStopSerie[i - 1];
            this.Events[7][i] = !float.IsNaN(shortStopSerie[i]) && !float.IsNaN(shortStopSerie[i - 1]) && highSerie[i] < shortStopSerie[i] && highSerie[i - 1] >= shortStopSerie[i - 1];
             }
        }
开发者ID:dadelcarbo,项目名称:StockAnalyzer,代码行数:26,代码来源:StockTrailStop_TRAILHLAVG.cs

示例10: ApplyTo

        public override void ApplyTo(StockSerie stockSerie)
        {
            FloatSerie lowEMASerie = stockSerie.GetIndicator(this.SerieNames[0]).Series[0];
            FloatSerie highEMASerie = stockSerie.GetIndicator(this.SerieNames[1]).Series[0];

            FloatSerie closeSerie = stockSerie.GetSerie(StockDataType.CLOSE);
            FloatSerie highSerie = stockSerie.GetSerie(StockDataType.HIGH);
            FloatSerie lowSerie = stockSerie.GetSerie(StockDataType.LOW);

            this.Series[0] = lowEMASerie;
            this.Series[1] = highEMASerie;

            // Detecting events
            this.CreateEventSeries(stockSerie.Count);

            for (int i = (int)this.parameters[0]; i < stockSerie.Count; i++)
            {
                if (lowSerie[i] > highEMASerie[i])
                {
                    this.Events[0][i] = true;
                    if (!this.Events[0][i-1])
                        this.Events[2][i] = true;
                }
                else if (highSerie[i] < lowEMASerie[i])
                {
                    this.Events[1][i] = true;
                    if (!this.Events[1][i - 1])
                        this.Events[3][i] = true;
                }
                else
                {
                    this.Events[4][i] = true;
                }
            }
        }
开发者ID:dadelcarbo,项目名称:StockAnalyzer,代码行数:35,代码来源:StockIndicator_EMAHL.cs

示例11: ApplyTo

        public override void ApplyTo(StockSerie stockSerie)
        {
            FloatSerie closeSerie = stockSerie.GetSerie(StockDataType.CLOSE);
             FloatSerie highSerie = stockSerie.GetSerie(StockDataType.HIGH);
             FloatSerie lowSerie = stockSerie.GetSerie(StockDataType.LOW);
             int fastPeriod = (int)this.parameters[0];
             int slowPeriod = (int)this.parameters[1];
             FloatSerie maSerie = closeSerie.CalculateKEMA(fastPeriod, slowPeriod);
             this.series[0] = maSerie;
             this.series[0].Name = this.Name;

             // Detecting events
             this.CreateEventSeries(stockSerie.Count);
             for (int i = 2; i < maSerie.Count; i++)
             {
            this.eventSeries[0][i] = (maSerie[i - 2] > maSerie[i - 1] && maSerie[i - 1] < maSerie[i]);
            this.eventSeries[1][i] = (maSerie[i - 2] < maSerie[i - 1] && maSerie[i - 1] > maSerie[i]);
            this.eventSeries[2][i] = closeSerie[i-1] < maSerie[i-1] && closeSerie[i] > maSerie[i];
            this.eventSeries[3][i] = closeSerie[i-1] > maSerie[i-1] && closeSerie[i] < maSerie[i];
            this.eventSeries[4][i] = lowSerie[i] > maSerie[i] && lowSerie[i - 1] < maSerie[i - 1];
            this.eventSeries[5][i] = highSerie[i] < maSerie[i] && highSerie[i - 1] > maSerie[i - 1];
            this.eventSeries[6][i] = lowSerie[i] > maSerie[i] && closeSerie[i - 1] < closeSerie[i];
            this.eventSeries[7][i] = highSerie[i] < maSerie[i] && closeSerie[i - 1] > closeSerie[i];
             }
        }
开发者ID:dadelcarbo,项目名称:StockAnalyzer,代码行数:25,代码来源:StockIndicator_KEMA.cs

示例12: AddStock

        public void AddStock(int index, StockSerie stockSerie)
        {
            StockDailyValue dailyValue = stockSerie.ValueArray[index];
             StockDailyValue futureValue = null;
             float dailyVariationClose = 0.0f;
             float dailyVariationLow = 0.0f;
             float dailyVariationHigh = 0.0f;

             for (int i = 0; i < NB_VALUES; i++)
             {
            futureValue = stockSerie.Values.ElementAt(index + i + 1);

            dailyVariationClose = (futureValue.CLOSE - dailyValue.CLOSE) / dailyValue.CLOSE;
            dailyVariationLow = (futureValue.LOW - dailyValue.CLOSE) / dailyValue.CLOSE;
            dailyVariationHigh = (futureValue.HIGH - dailyValue.CLOSE) / dailyValue.CLOSE;

            variationClose[i] += dailyVariationClose;
            variationLow[i] += dailyVariationLow;
            variationHigh[i] += dailyVariationHigh;

            minVariationClose = Math.Min(minVariationClose, dailyVariationClose);
            minVariationLow = Math.Min(minVariationLow, dailyVariationLow);
            minVariationHigh = Math.Min(minVariationHigh, dailyVariationHigh);

            maxVariationClose = Math.Max(minVariationClose, dailyVariationClose);
            maxVariationLow = Math.Max(minVariationLow, dailyVariationLow);
            maxVariationHigh = Math.Max(minVariationHigh, dailyVariationHigh);
             }
             nbVariationValue++;
        }
开发者ID:dadelcarbo,项目名称:StockAnalyzer,代码行数:30,代码来源:StockStatistics.cs

示例13: LoadData

        public override bool LoadData(string rootFolder, StockSerie stockSerie)
        {
            string[] row = stockSerie.StockName.Split('/');
             string serieName = row[0] + "/" + row[1];
             if (!StockDictionary.StockDictionarySingleton.ContainsKey(row[0]))
             {
            throw new Exception("Stock " + row[0] + " Not found, cannot calculate ratio");
             }
             StockSerie s1 = StockDictionary.StockDictionarySingleton[row[0]];
             if (!StockDictionary.StockDictionarySingleton.ContainsKey(row[1]))
             {
            throw new Exception("Stock " + row[1] + " Not found, cannot calculate ratio");
             }
             StockSerie s2 = StockDictionary.StockDictionarySingleton[row[1]];

             // Generate ratio serie
             StockSerie s3 = s1.GenerateRelativeStrenthStockSerie(s2);

             // Copy Into current serie
             stockSerie.IsInitialised = false;
             foreach (var pair in s3)
             {
            stockSerie.Add(pair.Key, pair.Value);
             }
             return true;
        }
开发者ID:dadelcarbo,项目名称:StockAnalyzer,代码行数:26,代码来源:RatioDataProvider.cs

示例14: ApplyTo

        public override void ApplyTo(StockSerie stockSerie)
        {
            FloatSerie fastSerie = stockSerie.GetIndicator(this.SerieNames[0]).Series[0].ShiftForward((int)this.parameters[3]);
            FloatSerie mediumSerie = stockSerie.GetIndicator(this.SerieNames[1]).Series[0].ShiftForward((int)this.parameters[4]);
            FloatSerie slowSerie = stockSerie.GetIndicator(this.SerieNames[2]).Series[0].ShiftForward((int)this.parameters[5]);

            this.Series[0] = fastSerie;
            this.Series[1] = mediumSerie;
            this.Series[2] = slowSerie;

            // Detecting events
            this.CreateEventSeries(stockSerie.Count);

            for (int i = 2; i < stockSerie.Count; i++)
            {
                if (fastSerie[i] > mediumSerie[i] && mediumSerie[i] > slowSerie[i])
                {
                    this.Events[0][i] = true;
                }
                else if (fastSerie[i] < mediumSerie[i] && mediumSerie[i] < slowSerie[i])
                {
                    this.Events[1][i] = true;
                }
            }
        }
开发者ID:dadelcarbo,项目名称:StockAnalyzer,代码行数:25,代码来源:StockIndicator_EMA3Lines.cs

示例15: Initialise

 public void Initialise(StockSerie serie)
 {
     this.stockSerie = serie;
     this.lowSerie = stockSerie.GetSerie(StockDataType.LOW);
     this.highSerie = stockSerie.GetSerie(StockDataType.HIGH);
     this.closeSerie = stockSerie.GetSerie(StockDataType.CLOSE);
 }
开发者ID:dadelcarbo,项目名称:StockAnalyzer,代码行数:7,代码来源:StockMoneyManagementBase.cs


注:本文中的StockSerie类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。