コード例 #1
0
        internal static ChartSettings MakeDefault()
        {
            ChartSettings result = new ChartSettings();

            result.ResetToDefault();
            return(result);
        }
コード例 #2
0
 internal void Refresh(ChartSettings settings)
 {
     CalculateGraphs(settings);
     CalculateArea();
     CalcualteXPhysicalDashes();
     CalcualteYPhysicalDashes();
 }
コード例 #3
0
        internal static void Save(string symbol, ChartSettings newSettings)
        {
            m_symbolToSettings[symbol] = newSettings;
            Configuration config = new Configuration(m_symbolToSettings);

            Configuration.Save(m_path, config);
        }
コード例 #4
0
        internal static ChartSettings GetSettings(string symbol)
        {
            ChartSettings result = null;

            if (!m_symbolToSettings.TryGetValue(symbol, out result))
            {
                result = ChartSettings.MakeDefault();
            }
            return(result);
        }
コード例 #5
0
        internal Dictionary <string, ChartSettings> ToSettings()
        {
            Dictionary <string, ChartSettings> result = new Dictionary <string, ChartSettings>();

            foreach (var element in this.Settings0.Charts)
            {
                string        key      = element.Symbol;
                ChartSettings settings = CreateChart(element);
                result[key] = settings;
            }
            return(result);
        }
コード例 #6
0
        internal void Update(Parameters parameters, ChartSettings settings, Quotes quotes)
        {
            if (m_grid.BackgroundColor != settings.BackgroundColor)
            {
                m_grid.BackgroundColor = settings.BackgroundColor;
            }
            Quote quote = quotes.Last.Quote;

            int count = (null == quote) ? 0 : settings.Lines.Count;
            Update(count);

            for (int index = 0; index < count; ++index )
            {
                LineSettings line = settings.Lines[index];
                Color volumeColor = CalculateColor(line.BidColor, line.AskColor, settings.ForegroundColor);
                Update(settings, index, 0, (float)line.Volume, volumeColor);

                double volume = line.Volume * parameters.LotSize;
                float? bid = MathEx.CalculateWAVP(volume, quote.Bids);
                float? ask = MathEx.CalculateWAVP(volume, quote.Asks);
                if (bid.HasValue)
                {
                    bid = (float)MathEx.RoundDown(bid.Value, parameters.PricePip);
                }
                if (ask.HasValue)
                {
                    ask = (float)MathEx.RoundUp(ask.Value, parameters.PricePip);
                }
                Update(settings, index, 1, bid, line.BidColor);
                Update(settings, index, 2, ask, line.AskColor);

                float? spread = null;
                if (bid.HasValue && ask.HasValue)
                {
                    spread = (float)Math.Round(parameters.PriceFactor * (ask.Value - bid.Value));
                }
                Color spreadColor = CalculateColor(line.BidColor, line.AskColor, settings.ForegroundColor);
                Update(settings, index, 3, spread, spreadColor);
            }
            Size size = m_grid.PreferredSize;
            if (this.Size != size)
            {
                this.Size = size;
            }
            //if (!this.Visible)
            //{
            //	this.Visible = true;
            //}
        }
コード例 #7
0
        public void Construct(Parameters parameters)
        {
            m_parameters = parameters;
            m_realTimeState = new ChartState(m_parameters, m_realTimeQuotes);

            m_currentState = m_realTimeState;
            m_settings = ChartSettingsManager.GetSettings(parameters.Symbol);
            m_realTimeQuotes.Interval = m_settings.Duration;

            m_parameters.SetHeight(m_settings.Height);
            m_spreads.Height = (int)(m_settings.Height - cTopOffset - cBottomOffset);
            m_timer.Interval = m_settings.UpdateInterval;
            m_proxy = new DataFeed(parameters.This, parameters.Func2);
            m_proxy.Tick += OnTick;
        }
コード例 #8
0
        private static ChartSettings CreateChart(ChartSettings0 settings)
        {
            ChartSettings result = new ChartSettings();

            result.Mode            = (RenderingMode)settings.Mode;
            result.Type            = (LineType)settings.Type;
            result.Grid            = settings.Grid;
            result.BackgroundColor = ColorSerializer.ColorFromString(settings.BackgroundColor);
            result.ForegroundColor = ColorSerializer.ColorFromString(settings.ForegroundColor);
            result.Duration        = settings.Duration;
            result.Height          = settings.Height;
            result.UpdateInterval  = settings.UpdateInterval;
            CreateLines(settings.Lines, result.Lines);
            return(result);
        }
コード例 #9
0
        private static ChartSettings0 CreateChart(string symbol, ChartSettings settings)
        {
            ChartSettings0 result = new ChartSettings0();
            result.Symbol = symbol;
            result.Mode = (Mode0)settings.Mode;
            result.Type = (LineType0)settings.Type;
            result.Grid = settings.Grid;
            result.BackgroundColor = ColorSerializer.StringFromColor(settings.BackgroundColor);
            result.ForegroundColor = ColorSerializer.StringFromColor(settings.ForegroundColor);
            result.Duration = settings.Duration;
            result.Height = settings.Height;
            result.UpdateInterval = settings.UpdateInterval;

            result.Lines = CreateLines(settings.Lines);

            return result;
        }
コード例 #10
0
        private static ChartSettings0 CreateChart(string symbol, ChartSettings settings)
        {
            ChartSettings0 result = new ChartSettings0();

            result.Symbol          = symbol;
            result.Mode            = (Mode0)settings.Mode;
            result.Type            = (LineType0)settings.Type;
            result.Grid            = settings.Grid;
            result.BackgroundColor = ColorSerializer.StringFromColor(settings.BackgroundColor);
            result.ForegroundColor = ColorSerializer.StringFromColor(settings.ForegroundColor);
            result.Duration        = settings.Duration;
            result.Height          = settings.Height;
            result.UpdateInterval  = settings.UpdateInterval;

            result.Lines = CreateLines(settings.Lines);

            return(result);
        }
コード例 #11
0
        internal ChartSettings(ChartSettings settings)
        {
            if (null == settings)
            {
                throw new ArgumentNullException("settings");
            }
            this.m_backgroundColor = settings.m_backgroundColor;
            this.m_foregoundColor  = settings.m_foregoundColor;
            this.Mode             = settings.Mode;
            this.Type             = settings.Type;
            this.m_duration       = settings.m_duration;
            this.m_height         = settings.m_height;
            this.m_updateInterval = settings.m_updateInterval;
            this.Grid             = settings.Grid;

            this.Lines          = new List <LineSettings>();
            this.Lines.Capacity = settings.Lines.Count;

            foreach (var element in settings.Lines)
            {
                LineSettings line = new LineSettings(element);
                this.Lines.Add(line);
            }
        }
コード例 #12
0
        internal ChartSettings(ChartSettings settings)
        {
            if (null == settings)
            {
                throw new ArgumentNullException("settings");
            }
            this.m_backgroundColor = settings.m_backgroundColor;
            this.m_foregoundColor = settings.m_foregoundColor;
            this.Mode = settings.Mode;
            this.Type = settings.Type;
            this.m_duration = settings.m_duration;
            this.m_height = settings.m_height;
            this.m_updateInterval = settings.m_updateInterval;
            this.Grid = settings.Grid;

            this.Lines = new List<LineSettings>();
            this.Lines.Capacity = settings.Lines.Count;

            foreach (var element in settings.Lines)
            {
                LineSettings line = new LineSettings(element);
                this.Lines.Add(line);
            }
        }
コード例 #13
0
        private void Update(ChartSettings settings, int row, int column, float? value, Color color)
        {
            DataGridViewCell cell = m_grid.Rows[row].Cells[column];

            if (settings.BackgroundColor != cell.Style.BackColor)
            {
                cell.Style.BackColor = settings.BackgroundColor;
            }
            LineSettings line = settings.Lines[row];
            if (cell.Style.ForeColor != color)
            {
                cell.Style.ForeColor = color;
            }
            string st = cell.Value as string;
            string text = value.HasValue ? value.Value.ToString(CultureInfo.InvariantCulture) : cNA;
            if (st != text)
            {
                cell.Value = text;
            }
        }
コード例 #14
0
 internal static void Save(string symbol, ChartSettings newSettings)
 {
     m_symbolToSettings[symbol] = newSettings;
     Configuration config = new Configuration(m_symbolToSettings);
     Configuration.Save(m_path, config);
 }
コード例 #15
0
 internal static ChartSettings MakeDefault()
 {
     ChartSettings result = new ChartSettings();
     result.ResetToDefault();
     return result;
 }
コード例 #16
0
        private void CalculateGraphs(ChartSettings settings)
        {
            Graphs.Clear();
            foreach (var element in settings.Lines)
            {
                double volume = element.Volume * m_parameters.LotSize;

                Graph graph = new Graph(volume, m_quotes);
                Graphs.Add(graph);
            }
        }
コード例 #17
0
 private static ChartSettings CreateChart(ChartSettings0 settings)
 {
     ChartSettings result = new ChartSettings();
     result.Mode = (RenderingMode)settings.Mode;
     result.Type = (LineType)settings.Type;
     result.Grid = settings.Grid;
     result.BackgroundColor = ColorSerializer.ColorFromString(settings.BackgroundColor);
     result.ForegroundColor = ColorSerializer.ColorFromString(settings.ForegroundColor);
     result.Duration = settings.Duration;
     result.Height = settings.Height;
     result.UpdateInterval = settings.UpdateInterval;
     CreateLines(settings.Lines, result.Lines);
     return result;
 }
コード例 #18
0
 private void OnOptions(object sender, EventArgs e)
 {
     try
     {
         ChartSettings oldSettings = new ChartSettings(m_settings);
         ChartSettingsDialog dialog = new ChartSettingsDialog(this);
         DialogResult result = dialog.ShowDialog();
         if (DialogResult.Cancel == result)
         {
             m_settings = oldSettings;
         }
         else if (DialogResult.Yes == result)
         {
             ChartSettingsManager.Save(m_parameters.Symbol, m_settings);
         }
     }
     catch (System.Exception ex)
     {
         MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }