protected override void OnStart()
        {
            // Add event listener
            if (Chart != null)
            {
                Chart.ChartPanelMouseDown += OnChartPanelMouseDown;
            }

            if (this.Instrument != null)
            {
                if (!String.IsNullOrEmpty(Name_of_list))
                {
                    this.Root.Core.InstrumentManager.GetInstrumentLists();
                    _list = this.Root.Core.InstrumentManager.GetInstrumentsListStatic(this.Name_of_list);
                    //if (_list == null)
                    //{
                    //    _list = this.Root.Core.InstrumentManager.GetInstrumentsListDynamic(this.Name_of_list);
                    //}
                    if (_list == null || _list.Count == 0)
                    {
                        Log(this.DisplayName + ": The list " + this.Name_of_list + " does not exist.", InfoLogLevel.Warning);
                    }
                }
                else
                {
                    Log(this.DisplayName + ": You need to specify a name for the list.", InfoLogLevel.Warning);
                }
            }
        }
示例#2
0
        protected override void OnCalculate()
        {
            if (this.IsProcessingBarIndexLast && this.Instrument != null)
            {
                if (!String.IsNullOrEmpty(Instrumentlist))
                {
                    this.Root.Core.InstrumentManager.GetInstrumentLists();
                    _list = this.Root.Core.InstrumentManager.GetInstrumentsListStatic(this.Instrumentlist);

                    //if (_list == null)
                    //{
                    //    _list = this.Root.Core.InstrumentManager.GetInstrumentsListDynamic(this.Name_of_list);
                    //}
                    if (_list == null)
                    {
                        Log(this.DisplayName + ": The list " + this.Instrumentlist + " does not exist.", InfoLogLevel.Warning);
                        MyPlot1.Set(-1);
                    }

                    //We have found a list
                    if (_list.Contains((Instrument)this.Instrument))
                    {
                        MyPlot1.Set(1);
                    }
                    else
                    {
                        MyPlot1.Set(0);
                    }
                }
                else
                {
                    Log(this.DisplayName + ": You need to specify a name for the list.", InfoLogLevel.Warning);
                    MyPlot1.Set(-1);
                }
            }


            //MyPlot1.Set(InSeries[0]);
        }
        private void CheckForNewInstruments()
        {
            if (_lastupdate.AddSeconds(this._seconds) < DateTime.Now)
            {
                if (!String.IsNullOrEmpty(Name_of_list))
                {
                    this.Root.Core.InstrumentManager.GetInstrumentLists();
                    _list = this.Root.Core.InstrumentManager.GetInstrumentsListStatic(this.Name_of_list);
                    if (_list == null || _list.Count == 0)
                    {
                        Log(this.DisplayName + ": The list " + this.Name_of_list + " does not exist.", InfoLogLevel.Warning);
                    }
                }
                else
                {
                    Log(this.DisplayName + ": You need to specify a name for the list.", InfoLogLevel.Warning);
                }

                if (_list != null)
                {
                    //this.Root.Core.InstrumentManager.ClearInstrumentList(this.Name_of_list);
                    Core.GuiManager.BeginInvoke((Action)(() => this.Root.Core.InstrumentManager.ClearInstrumentList(this.Name_of_list)));
                }


                if (!String.IsNullOrWhiteSpace(this.Instrumentlists))
                {
                    string[] arr_Instrumentlists = this.Instrumentlists.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                    if (arr_Instrumentlists != null && arr_Instrumentlists.Count() > 0)
                    {
                        foreach (string item in arr_Instrumentlists)
                        {
                            IInstrumentsList instlist = this.Root.Core.InstrumentManager.GetInstrumentsListStatic(item);

                            if (instlist != null && instlist.Count() > 0)
                            {
                                if (UseMarketHours)
                                {
                                    ITimePeriod timper = this.Root.Core.MarketplaceManager.GetExchangeDescription(instlist.First().Exchange).TradingHours;

                                    if ((DateTime.Now.TimeOfDay > timper.StartTime) && (DateTime.Now.TimeOfDay < timper.EndTime))
                                    {
                                        foreach (IInstrument inst in instlist)
                                        {
                                            if (!_list.Contains(inst))
                                            {
                                                //this.Root.Core.InstrumentManager.AddInstrument2List(inst, this.Name_of_list);
                                                Core.GuiManager.BeginInvoke((Action)(() => Core.InstrumentManager.AddInstrument2List(inst, this.Name_of_list)));
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    foreach (IInstrument inst in instlist)
                                    {
                                        if (!_list.Contains(inst))
                                        {
                                            //this.Root.Core.InstrumentManager.AddInstrument2List(inst, this.Name_of_list);
                                            Core.GuiManager.BeginInvoke((Action)(() => Core.InstrumentManager.AddInstrument2List(inst, this.Name_of_list)));
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                _lastupdate = DateTime.Now;
            }
        }
示例#4
0
        private void CheckForNewInstruments()
        {
            if (_lastupdate.AddSeconds(this._seconds) < DateTime.Now)
            {
                if (!String.IsNullOrEmpty(Name_of_list))
                {
                    this.Root.Core.InstrumentManager.GetInstrumentLists();
                    _list = this.Root.Core.InstrumentManager.GetInstrumentsListStatic(this.Name_of_list);
                    if (_list == null || _list.Count == 0)
                    {
                        Log(this.DisplayName + ": The list " + this.Name_of_list + " does not exist.", InfoLogLevel.Warning);
                    }
                }
                else
                {
                    Log(this.DisplayName + ": You need to specify a name for the list.", InfoLogLevel.Warning);
                }

                if (_list != null)
                {
                    //this.Root.Core.InstrumentManager.ClearInstrumentList(this.Name_of_list);
                    Core.GuiManager.BeginInvoke((Action)(() => this.Root.Core.InstrumentManager.ClearInstrumentList(this.Name_of_list)));
                }

                if (this.ShowProposals)
                {
                    _regorders = this.Root.Core.TradingManager.ActiveRegisteredOrders;
                    if (_regorders != null)
                    {
                        foreach (IInstrument item in _regorders.Select(x => x.Instrument).Distinct())
                        {
                            if (!_list.Contains(item))
                            {
                                //this.Root.Core.InstrumentManager.AddInstrument2List(item, this.Name_of_list);
                                Core.GuiManager.BeginInvoke((Action)(() => Core.InstrumentManager.AddInstrument2List(item, this.Name_of_list)));
                            }
                        }
                    }
                }

                if (this.ShowTrades)
                {
                    _openedtrades = this.Root.Core.TradingManager.GetOpenedTrades();
                    if (_openedtrades != null)
                    {
                        foreach (ITradingTrade item in _openedtrades)
                        {
                            if (!_list.Contains((IInstrument)item.Instrument))
                            {
                                //this.Root.Core.InstrumentManager.AddInstrument2List((IInstrument)item.Instrument, this.Name_of_list);
                                Core.GuiManager.BeginInvoke((Action)(() => Core.InstrumentManager.AddInstrument2List((IInstrument)item.Instrument, this.Name_of_list)));
                            }
                        }
                    }
                }

                if (this.ShowPriceAlert)
                {
                    pricealerts = this.Root.Core.AlertManager.PriceAlerts;
                    if (pricealerts != null)
                    {
                        foreach (IPriceAlert item in pricealerts)
                        {
                            if (!_list.Contains((IInstrument)item.Instrument))
                            {
                                //this.Root.Core.InstrumentManager.AddInstrument2List((IInstrument)item.Instrument, this.Name_of_list);
                                Core.GuiManager.BeginInvoke((Action)(() => Core.InstrumentManager.AddInstrument2List((IInstrument)item.Instrument, this.Name_of_list)));
                            }
                        }
                    }
                }

                _lastupdate = DateTime.Now;
            }
        }