﻿<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type='text/css' href='https://stocksharp.com/css/style.css'?>
<?xml-stylesheet type='text/css' href='https://stocksharp.com/css/bbeditor.css'?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title type="html">Вчерашние свечи в CandleManager</title>
  <id>~/topic/1375/vcherashnie-svechi-v-candlemanager/</id>
  <rights type="text">Copyright @ StockSharp Platform LLC 2010 - 2025</rights>
  <updated>2026-06-04T14:20:47Z</updated>
  <logo>https://stocksharp.com/images/logo.png</logo>
  <link href="https://stocksharp.com/handlers/atom.ashx?category=topic&amp;id=1375" rel="self" type="application/rss+xml" />
  <entry>
    <id>https://stocksharp.com/posts/m/6033/</id>
    <title type="text">Вчера интересовался тем как в candleManager получить вчерашние свечки. ([url=http://stocksharp.com/p...</title>
    <published>2011-02-17T11:13:26Z</published>
    <updated>2016-08-15T23:46:54Z</updated>
    <author>
      <name>KAX</name>
      <uri>https://stocksharp.com/users/3408/</uri>
      <email>info@stocksharp.com</email>
    </author>
    <content type="html">&lt;p&gt;Вчера интересовался тем как в candleManager получить вчерашние свечки. ([url=http://stocksharp.com/posts/m/6010/#post5294]Вопросы новичка[/url])&lt;/p&gt;
&lt;p&gt;Вариант экспорта портфеля на купайле, не понравился, поэтому вот мой велосипед:
[code]
using Ecng.Trading.Algo.Candles;
using Ecng.Trading.BusinessEntities;
using Ecng.Trading.Quik;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;public class CandleHistoryManager : CandleManager
{
    private CultureInfo _culture;
    private IEnumerable&amp;lt;TimeFrameCandle&amp;gt; _history;
    public CandleHistoryManager(QuikTrader Quik)
        : base(Quik)
    {
        _culture = new CultureInfo(System.Threading.Thread.CurrentThread.CurrentCulture.Name) { NumberFormat = { NumberDecimalSeparator = &amp;quot;.&amp;quot; } };

    }

    public IEnumerable&amp;lt;TimeFrameCandle&amp;gt; GetTimeFrameCandlesHistory(Security security, TimeSpan timeframe, int candleCount)
    {
        var candleList = base.GetTimeFrameCandles(security, timeframe, candleCount).ToList&amp;lt;TimeFrameCandle&amp;gt;();             
        if (candleList.Count &amp;lt; candleCount)
        {
            int diff = candleCount - candleList.Count;
            string fileName = String.Format(&amp;quot;{0}.txt&amp;quot;, security.Id);
            if (!File.Exists(fileName)) 
            {
                return candleList;
            }
            if (_history == null)
            {
                _history = File.ReadAllLines(fileName).Select(line =&amp;gt;
                    {
                        var parts = line.Split(',');
                        var time = DateTime.ParseExact(parts[0] + parts[1], &amp;quot;yyyyMMddHHmmss&amp;quot;, _culture);
                        return new TimeFrameCandle
                        {
                            OpenPrice = double.Parse(parts[2], _culture),
                            HighPrice = double.Parse(parts[3], _culture),
                            LowPrice = double.Parse(parts[4], _culture),
                            ClosePrice = double.Parse(parts[5], _culture),
                            TimeFrame = timeframe,
                            Time = time,
                            TotalVolume = int.Parse(parts[6], _culture),
                            Security = security
                        };
                    });
            }
            var neededRange = _history.OrderBy(key =&amp;gt; key.Time).ToList&amp;lt;TimeFrameCandle&amp;gt;().GetRange((_history.Count() - diff), diff);
            candleList.InsertRange(0, neededRange);
        }
        return candleList;
    } 
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;[/code]&lt;/p&gt;
&lt;p&gt;Собственно алгоритм простой, если количество запрашиваемых свечек больше чем есть, читаем данные из файла.
Файл можно получить на финаме. Формат простой: Дата (ГГГГММДД), Время(ЧЧММСС), Open, High, Low, Close, Volume&lt;/p&gt;
&lt;p&gt;скриншоты и немного воды тут: [url=http://tradecommunity.ru/blog/stocksharp/41.html]http://tradecommunity.ru/blog/stocksharp/41.html[/url]&lt;/p&gt;
</content>
    <rights type="html">Copyright @ StockSharp Platform LLC 2010 - 2025</rights>
  </entry>
</feed>