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

C# Candles.Candle类代码示例

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

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



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

示例1: AddCandle

			public void AddCandle(int securityIndex, Candle candle)
			{
				if (candle == null)
					throw new ArgumentNullException(nameof(candle));

				if (Candles[securityIndex] != null)
				{
					if (_isSparseBuffer)
						return;
					
					throw new ArgumentException(LocalizedStrings.Str654Params.Put(candle.OpenTime), nameof(candle));
				}

				Candles[securityIndex] = candle;

				_counter--;

				if (_isSparseBuffer)
				{
					if (candle.OpenTime < OpenTime)
					{
						OpenTime = candle.OpenTime;
						OpenTime = Candles.Where(c => c != null).Min(c => c.OpenTime);
					}

					if (candle.CloseTime > CloseTime)
					{
						CloseTime = candle.CloseTime;
						CloseTime = Candles.Where(c => c != null).Max(c => c.CloseTime);
					}
				}
			}
开发者ID:vikewoods,项目名称:StockSharp,代码行数:32,代码来源:IndexSeriesBuilder.cs


示例2: GetValue

		/// <summary>
		/// To get the part value.
		/// </summary>
		/// <param name="current">The current candle.</param>
		/// <param name="prev">The previous candle.</param>
		/// <returns>Value.</returns>
		protected override decimal GetValue(Candle current, Candle prev)
		{
			if (current.LowPrice < prev.LowPrice && current.HighPrice - prev.HighPrice < prev.LowPrice - current.LowPrice)
				return prev.LowPrice - current.LowPrice;
			else
				return 0;
		}
开发者ID:hbwjz,项目名称:StockSharp,代码行数:13,代码来源:DiMinus.cs


示例3: CandleBuffer

			public CandleBuffer(DateTimeOffset openTime, DateTimeOffset closeTime, int maxCandleCount, bool isSparseBuffer)
			{
				OpenTime = openTime;
				CloseTime = closeTime;
				Candles = new Candle[maxCandleCount];
				_counter = maxCandleCount;
				_isSparseBuffer = isSparseBuffer;
			}
开发者ID:vikewoods,项目名称:StockSharp,代码行数:8,代码来源:IndexSeriesBuilder.cs


示例4: GetPriceMovements

		/// <summary>
		/// To get price components to select the maximal value.
		/// </summary>
		/// <param name="currentCandle">The current candle.</param>
		/// <param name="prevCandle">The previous candle.</param>
		/// <returns>Price components.</returns>
		protected virtual decimal[] GetPriceMovements(Candle currentCandle, Candle prevCandle)
		{
			return new[]
			{
				Math.Abs(currentCandle.HighPrice - currentCandle.LowPrice),
				Math.Abs(prevCandle.ClosePrice - currentCandle.HighPrice),
				Math.Abs(prevCandle.ClosePrice - currentCandle.LowPrice)
			};
		}
开发者ID:zjxbetter,项目名称:StockSharp,代码行数:15,代码来源:TrueRange.cs


示例5: ProcessCandle

        protected void ProcessCandle(Candle candle)
        {
            if (Trade.GetPnL() <= -StopLossUnit)
            {
                OrderDirections direction = this.Trade.Order.Direction.Invert();
                decimal price = Security.LastTrade.Price;
                Order order = this.CreateOrder(direction, price, this.Trade.Order.Volume);

                RegisterOrder(order);
            }
        }
开发者ID:akramarev,项目名称:SampleSMA,代码行数:11,代码来源:StopLossCandleStrategy.cs


示例6: AddCandle

			public bool AddCandle(Candle candle)
			{
				if (candle == null)
					throw new ArgumentNullException(nameof(candle));

				if (!_byTime.SafeAdd(candle.OpenTime).TryAdd(candle))
					return false;

				_allCandles.AddLast(candle);
				_candleStat.Add(candle);

				_lastCandleTime = candle.OpenTime.UtcTicks;

				RecycleCandles();

				return true;
			}
开发者ID:vikewoods,项目名称:StockSharp,代码行数:17,代码来源:CandleManagerContainer.cs


示例7: OnProcess

		/// <summary>
		/// To handle the input value.
		/// </summary>
		/// <param name="input">The input value.</param>
		/// <returns>The resulting value.</returns>
		protected override IIndicatorValue OnProcess(IIndicatorValue input)
		{
			var candle = input.GetValue<Candle>();

			if (_prevCandle != null)
			{
				if (input.IsFinal)
					IsFormed = true;

				var priceMovements = GetPriceMovements(candle, _prevCandle);

				if (input.IsFinal)
					_prevCandle = candle;

				return new DecimalIndicatorValue(this, priceMovements.Max());
			}

			if (input.IsFinal)
				_prevCandle = candle;

			return new DecimalIndicatorValue(this, candle.HighPrice - candle.LowPrice);
		}
开发者ID:zjxbetter,项目名称:StockSharp,代码行数:27,代码来源:TrueRange.cs


示例8: ProcessCandle

		private void ProcessCandle(Candle candle)
		{
			// если наша стратегия в процессе остановки
			if (ProcessState == ProcessStates.Stopping)
			{
				// отменяем активные заявки
				CancelActiveOrders();
				return;
			}

			// добавляем новую свечу
			LongSma.Process(candle);
			ShortSma.Process(candle);

			// вычисляем новое положение относительно друг друга
			var isShortLessThenLong = ShortSma.GetCurrentValue() < LongSma.GetCurrentValue();

			// если произошло пересечение
			if (_isShortLessThenLong != isShortLessThenLong)
			{
				// если короткая меньше чем длинная, то продажа, иначе, покупка.
				var direction = isShortLessThenLong ? Sides.Sell : Sides.Buy;

				// вычисляем размер для открытия или переворота позы
				var volume = Position == 0 ? Volume : Position.Abs() * 2;

				// регистрируем заявку (обычным способом - лимитированной заявкой)
				//RegisterOrder(this.CreateOrder(direction, (decimal)Security.GetCurrentPrice(direction), volume));

				// переворачиваем позицию через котирование
				var strategy = new MarketQuotingStrategy(direction, volume);
				ChildStrategies.Add(strategy);

				// запоминаем текущее положение относительно друг друга
				_isShortLessThenLong = isShortLessThenLong;
			}
		}
开发者ID:reddream,项目名称:StockSharp,代码行数:37,代码来源:SmaStrategy.cs


示例9: ProcessCandle

		private void ProcessCandle(Candle candle)
		{
			// strategy are stopping
			if (ProcessState == ProcessStates.Stopping)
			{
				CancelActiveOrders();
				return;
			}

			// process new candle
			LongSma.Process(candle);
			ShortSma.Process(candle);

			// calc new values for short and long
			var isShortLessThenLong = ShortSma.GetCurrentValue() < LongSma.GetCurrentValue();

			// crossing happened
			if (_isShortLessThenLong != isShortLessThenLong)
			{
				// if short less than long, the sale, otherwise buy
				var direction = isShortLessThenLong ? Sides.Sell : Sides.Buy;

				// calc size for open position or revert
				var volume = Position == 0 ? Volume : Position.Abs() * 2;

				// register order (limit order)
				RegisterOrder(this.CreateOrder(direction, (decimal)(Security.GetCurrentPrice(this, direction) ?? 0), volume));

				// or revert position via market quoting
				//var strategy = new MarketQuotingStrategy(direction, volume);
				//ChildStrategies.Add(strategy);

				// store current values for short and long
				_isShortLessThenLong = isShortLessThenLong;
			}
		}
开发者ID:reddream,项目名称:StockSharp,代码行数:36,代码来源:SmaStrategy.cs


示例10: ProcessCandle

		private void ProcessCandle(CandleSeries series, Candle candle)
		{
			// возможно была задержка в получении данных и обработаны еще не все данные
			if (!_isStarted)
				this.GuiAsync(() => IsStarted = true);

			_timer.Activate();

			_candlesCount++;

			// ограничиваем кол-во передаваемых свечек, чтобы не фризился интерфейс
			if (_candlesCount % 100 == 0)
				System.Threading.Thread.Sleep(200);

			var candleSeries = (CandleSeries)_bufferedChart.GetSource(_candleElement);

			if (series == candleSeries)
			{
				var values = new Dictionary<IChartElement, object>();

				lock (_syncRoot)
				{
					foreach (var element in _bufferedChart.Elements.Where(e => _bufferedChart.GetSource(e) == series))
					{
						if (_skipElements.Contains(element))
							continue;

						element.DoIf<IChartElement, ChartCandleElement>(e => values.Add(e, candle));
						element.DoIf<IChartElement, ChartIndicatorElement>(e => values.Add(e, CreateIndicatorValue(e, candle)));
					}
				}

				_bufferedChart.Draw(candle.OpenTime, values);

				if (series.Security is ContinuousSecurity)
				{
					// для непрерывных инструментов всегда приходят данные по одной серии
					// но инструмент у свечки будет равен текущему инструменту
					ProcessContinuousSourceElements(candle);
				}
			}
			else
			{
				// для индексов будут приходить отдельные свечки для каждого инструмента
				ProcessIndexSourceElements(candle);
			}
		}
开发者ID:kknet,项目名称:StockSharp,代码行数:47,代码来源:CompositeSecurityPanel.xaml.cs


示例11: ProcessCandle

		public IEnumerable<Candle> ProcessCandle(Candle candle)
		{
			return GetFormedBuffers(candle)
				.Select(buffer =>
				{
					var openPrice = TryCalculate(buffer, c => c.OpenPrice);

					if (openPrice == null)
						return null;

					var indexCandle = candle.GetType().CreateInstance<Candle>();

					indexCandle.Security = _security;
					indexCandle.Arg = CloneArg(candle.Arg, _security);
					indexCandle.OpenTime = buffer.OpenTime;
					indexCandle.CloseTime = buffer.CloseTime;

					indexCandle.TotalVolume = Calculate(buffer, c => c.TotalVolume);
					indexCandle.TotalPrice = Calculate(buffer, c => c.TotalPrice);
					indexCandle.OpenPrice = (decimal)openPrice;
					indexCandle.OpenVolume = Calculate(buffer, c => c.OpenVolume ?? 0);
					indexCandle.ClosePrice = Calculate(buffer, c => c.ClosePrice);
					indexCandle.CloseVolume = Calculate(buffer, c => c.CloseVolume ?? 0);
					indexCandle.HighPrice = Calculate(buffer, c => c.HighPrice);
					indexCandle.HighVolume = Calculate(buffer, c => c.HighVolume ?? 0);
					indexCandle.LowPrice = Calculate(buffer, c => c.LowPrice);
					indexCandle.LowVolume = Calculate(buffer, c => c.LowVolume ?? 0);

					// если некоторые свечи имеют неполные данные, то и индекс будет таким же неполным
					if (indexCandle.OpenPrice == 0 || indexCandle.HighPrice == 0 || indexCandle.LowPrice == 0 || indexCandle.ClosePrice == 0)
					{
						var nonZeroPrice = indexCandle.OpenPrice;

						if (nonZeroPrice == 0)
							nonZeroPrice = indexCandle.HighPrice;

						if (nonZeroPrice == 0)
							nonZeroPrice = indexCandle.LowPrice;

						if (nonZeroPrice == 0)
							nonZeroPrice = indexCandle.LowPrice;

						if (nonZeroPrice != 0)
						{
							if (indexCandle.OpenPrice == 0)
								indexCandle.OpenPrice = nonZeroPrice;

							if (indexCandle.HighPrice == 0)
								indexCandle.HighPrice = nonZeroPrice;

							if (indexCandle.LowPrice == 0)
								indexCandle.LowPrice = nonZeroPrice;

							if (indexCandle.ClosePrice == 0)
								indexCandle.ClosePrice = nonZeroPrice;
						}
					}

					if (indexCandle.HighPrice < indexCandle.LowPrice)
					{
						var high = indexCandle.HighPrice;

						indexCandle.HighPrice = indexCandle.LowPrice;
						indexCandle.LowPrice = high;
					}

					if (indexCandle.OpenPrice > indexCandle.HighPrice)
						indexCandle.HighPrice = indexCandle.OpenPrice;
					else if (indexCandle.OpenPrice < indexCandle.LowPrice)
						indexCandle.LowPrice = indexCandle.OpenPrice;

					if (indexCandle.ClosePrice > indexCandle.HighPrice)
						indexCandle.HighPrice = indexCandle.ClosePrice;
					else if (indexCandle.ClosePrice < indexCandle.LowPrice)
						indexCandle.LowPrice = indexCandle.ClosePrice;

					indexCandle.State = CandleStates.Finished;

					return indexCandle;
				})
				.Where(c => c != null);
		}
开发者ID:vikewoods,项目名称:StockSharp,代码行数:82,代码来源:IndexSeriesBuilder.cs


示例12: AddCandle

				public void AddCandle(Candle candle)
				{
					if (_firstTime == null)
						_firstTime = candle.OpenTime;

					lock (_candles.SyncRoot)
					{
						if ((candle.OpenTime.Date - _firstTime.Value.Date).TotalDays >= 3)
						{
							_firstTime = candle.OpenTime;
							FlushCandles(_candles.CopyAndClear());
						}

						_candles.Add(candle);
					}
				}
开发者ID:jsonbao,项目名称:StockSharp,代码行数:16,代码来源:StrategyService.cs


示例13: CreateIndicatorValue

		private IIndicatorValue CreateIndicatorValue(ChartIndicatorElement element, Candle candle)
		{
			var indicator = _indicators.TryGetValue(element);

			if (indicator == null)
				throw new InvalidOperationException(LocalizedStrings.IndicatorNotFound.Put(element));

			return indicator.Process(candle);
		}
开发者ID:reddream,项目名称:StockSharp,代码行数:9,代码来源:TerminalStrategy.cs


示例14: ProcessCandles

		public void ProcessCandles(Candle candle)
		{
			Chart.Draw(_candleElement, candle);
		}
开发者ID:reddream,项目名称:StockSharp,代码行数:4,代码来源:CandlesWindow.xaml.cs


示例15: OnProcessCandle

		private void OnProcessCandle(Candle candle)
		{
			if (candle.State == CandleStates.Finished)
				NewCandle(candle);
		}
开发者ID:RakotVT,项目名称:StockSharp,代码行数:5,代码来源:CandleSeriesIndicatorSource.cs


示例16: CandleManagerProcessing

		private void CandleManagerProcessing(CandleSeries series, Candle candle)
		{
			if (series == this)
				ProcessCandle.SafeInvoke(candle);
		}
开发者ID:hbwjz,项目名称:StockSharp,代码行数:5,代码来源:CandleSeries.cs


示例17: GetCandles

        private static void GetCandles(CandleSeries series, Candle candle)
        {
            if (candle.State == CandleStates.Finished)
            {
                LisfStreamWriters[series.ToString()].WriteLine(candle.OpenTime.Date.ToString("d") + " " + candle.OpenTime.DateTime.ToString("T") +
                                       " " + candle.OpenPrice.ToString()+ " "+ candle.HighPrice.ToString() +" "+
                                       candle.LowPrice.ToString() +" "+candle.ClosePrice.ToString() +" "+candle.TotalVolume.ToString());

                Console.Write(".");
            }
        }
开发者ID:draco777,项目名称:GetHydraData,代码行数:11,代码来源:Program.cs


示例18: ProcessCandle

        protected void ProcessCandle(Candle candle)
        {
            if (candle == null || candle.State != CandleStates.Finished)
            {
                return;
            }

            LongMA.Process(candle);
            ShortMA.Process(candle);
            FilterMA.Process(candle);

            if (candle.CloseTime > this._strategyStartTime
                && LongMA.IsFormed
                && ShortMA.IsFormed
                && FilterMA.IsFormed)
            {
                this.AnalyseAndTrade();
            }

            this.OnCandleProcessed(candle);
        }
开发者ID:akramarev,项目名称:SampleSMA,代码行数:21,代码来源:EMAEventModelStrategy.cs


示例19: OnCandleProcessed

 protected void OnCandleProcessed(Candle candle)
 {
     if (CandleProcessed != null)
     {
         CandleProcessed(candle);
     }
 }
开发者ID:akramarev,项目名称:SampleSMA,代码行数:7,代码来源:EMAEventModelStrategy.cs


示例20: CreateFilledCandle

			private Candle CreateFilledCandle(Candle candle)
			{
				if (candle == null)
					throw new ArgumentNullException(nameof(candle));

				var filledCandle = candle.GetType().CreateInstance<Candle>();

				//filledCandle.Series = candle.Series;
				filledCandle.Security = candle.Security;
				filledCandle.Arg = CloneArg(candle.Arg, candle.Security);
				filledCandle.OpenTime = candle.OpenTime;
				filledCandle.CloseTime = candle.CloseTime;

				//filledCandle.TotalVolume = candle.TotalVolume;
				//filledCandle.TotalPrice = candle.TotalPrice;
				filledCandle.OpenPrice = candle.ClosePrice;
				//filledCandle.OpenVolume = candle.CloseVolume;
				filledCandle.ClosePrice = candle.ClosePrice;
				//filledCandle.CloseVolume = candle.CloseVolume;
				filledCandle.HighPrice = candle.ClosePrice;
				//filledCandle.HighVolume = candle.CloseVolume;
				filledCandle.LowPrice = candle.ClosePrice;
				//filledCandle.LowVolume = candle.CloseVolume;

				filledCandle.State = CandleStates.Finished;

				return filledCandle;
			}
开发者ID:vikewoods,项目名称:StockSharp,代码行数:28,代码来源:IndexSeriesBuilder.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Candles.CandleSeries类代码示例发布时间:2022-05-26
下一篇:
C# Stetic.ObjectWrapper类代码示例发布时间: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