Ejemplo n.º 1
0
        //Convert Meta.OutputInfo to string and vice versa
        public static Meta.OutputInfo[] String2OutputInfo(string str)
        {
            Meta.OutputInfo[] outputInfoList = new Meta.OutputInfo[0];
            string[]          items          = common.system.String2List(str);
            for (int idx = 0; idx < items.Length; idx++)
            {
                string[] parts = common.system.String2List(items[idx], ":");
                Color    color = Data.sysDefaultLineColor;
                if (parts.Length > 0)
                {
                    color = ColorTranslator.FromHtml(parts[0]);
                }
                int weight = 1;
                if (parts.Length > 1)
                {
                    int.TryParse(parts[1], out weight);
                }

                AppTypes.ChartTypes chartType = AppTypes.ChartTypes.Line;
                if (parts.Length > 2)
                {
                    chartType = AppTypes.Text2ChartType(parts[2]);
                }
                Array.Resize(ref outputInfoList, outputInfoList.Length + 1);
                outputInfoList[outputInfoList.Length - 1] = new Meta.OutputInfo(color, weight, chartType);
            }
            return(outputInfoList);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Create parametter grid from meta.ParameterDefaultValues
        /// </summary>
        /// <param name="meta"></param>
        protected void SetPara(Indicators.Meta meta)
        {
            this.Text = meta.Name;
            paramGrid.Rows.Clear();
            string[] keys   = meta.ParameterList.Keys;
            object[] values = meta.ParameterList.Values;
            for (int idx = 0; idx < keys.Length; idx++)
            {
                paramGrid.Rows.Add(keys[idx], values[idx]);
            }
            valueColumn.DefaultCellStyle.Format = "N" + meta.ParameterPrecision.ToString();

            inNewPaneChk.Checked = meta.DrawInNewWindow;
            keys   = meta.OutputInfoList.Keys;
            values = meta.OutputInfoList.Values;
            for (int idx = 0; idx < keys.Length; idx++)
            {
                Color color  = (meta.Output.Length > idx ? meta.Output[idx].Color : Color.Red);
                int   weight = (meta.Output.Length > idx ? meta.Output[idx].Weight : 1);
                AppTypes.ChartTypes chartType = (meta.Output.Length > idx ? meta.Output[idx].ChartType :  AppTypes.ChartTypes.Line);
                outputGrid.Rows.Add(keys[idx], color, weight, chartType);
            }
            paraDescEd.Text = common.system.ToString(meta.ParameterDescriptions);
            hintTextEd.Text = meta.Description + common.Consts.constCRLF + meta.URL;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Set Output property from a formated string.
        /// </summary>
        /// <param name="str"> In the format ([key]=[Color]:[Weight*]:[ChartType*])  </param>
        /// <returns></returns>
        private static common.DictionaryList String2OutputList(string str)
        {
            common.DictionaryList   list      = new common.DictionaryList();
            common.myKeyValueItem[] keyValues = common.system.String2KeyValueList(str, ",", "=");
            Color color  = Data.sysDefaultLineColor;
            int   weight = 1;

            AppTypes.ChartTypes chartType = Data.sysDefaultLineChartType;
            for (int idx = 0; idx < keyValues.Length; idx++)
            {
                string[] parts = common.system.String2List(keyValues[idx].Value, ":", StringSplitOptions.None);
                color  = (parts.Length > 0 ? ColorTranslator.FromHtml(parts[0]) : Data.sysDefaultLineColor);
                weight = Data.sysDefaultLineWeight;
                if (parts.Length > 1)
                {
                    int.TryParse(parts[1], out weight);
                }
                chartType = (parts.Length > 2 ? AppTypes.Text2ChartType(parts[2]) : Data.sysDefaultLineChartType);
                list.Add(keyValues[idx].Key, new Meta.OutputInfo(color, weight, chartType));
            }
            return(list);
        }
Ejemplo n.º 4
0
        //Swicth language. Note that the order of items must be preserved
        public static void SetLanguage(ComboBox.ObjectCollection items, Type type)
        {
            StringCollection saveKeys = new StringCollection();

            for (int idx = 0; idx < items.Count; idx++)
            {
                common.myComboBoxItem item = (common.myComboBoxItem)items[idx];
                saveKeys.Add(item.Value);
            }
            if (type == typeof(AppTypes.TimeScale))
            {
                items.Clear();
                for (int idx = 0; idx < saveKeys.Count; idx++)
                {
                    object obj = FindTimeScaleByCode(saveKeys[idx]);
                    if (obj == null)
                    {
                        continue;
                    }
                    AppTypes.TimeScale item = (AppTypes.TimeScale)obj;
                    items.Add(new common.myComboBoxItem(item.Description, item.Code));
                }
                return;
            }

            if (type == typeof(AppTypes.TradeActions))
            {
                items.Clear();
                for (int idx = 0; idx < saveKeys.Count; idx++)
                {
                    object obj = FindCodeInEnum(saveKeys[idx], typeof(AppTypes.TradeActions));
                    if (obj == null)
                    {
                        continue;
                    }
                    AppTypes.TradeActions item = (AppTypes.TradeActions)obj;
                    items.Add(new common.myComboBoxItem(AppTypes.Type2Text(item), item.ToString()));
                }
                return;
            }


            if (type == typeof(AppTypes.TimeRanges))
            {
                items.Clear();
                for (int idx = 0; idx < saveKeys.Count; idx++)
                {
                    object obj = FindCodeInEnum(saveKeys[idx], typeof(AppTypes.TimeRanges));
                    if (obj == null)
                    {
                        continue;
                    }
                    AppTypes.TimeRanges item = (AppTypes.TimeRanges)obj;
                    items.Add(new common.myComboBoxItem(AppTypes.Type2Text(item), item.ToString()));
                }
                return;
            }
            if (type == typeof(AppTypes.StrategyTypes))
            {
                items.Clear();
                for (int idx = 0; idx < saveKeys.Count; idx++)
                {
                    object obj = FindCodeInEnum(saveKeys[idx], typeof(AppTypes.StrategyTypes));
                    if (obj == null)
                    {
                        continue;
                    }
                    AppTypes.StrategyTypes item = (AppTypes.StrategyTypes)obj;
                    items.Add(new common.myComboBoxItem(AppTypes.Type2Text(item), item.ToString()));
                }
                return;
            }
            if (type == typeof(AppTypes.Sex))
            {
                items.Clear();
                for (int idx = 0; idx < saveKeys.Count; idx++)
                {
                    object obj = FindCodeInEnum(saveKeys[idx], typeof(AppTypes.Sex));
                    if (obj == null)
                    {
                        continue;
                    }
                    AppTypes.Sex item = (AppTypes.Sex)obj;
                    items.Add(new common.myComboBoxItem(AppTypes.Type2Text(item), item.ToString()));
                }
                return;
            }
            if (type == typeof(AppTypes.CommonStatus))
            {
                items.Clear();
                for (int idx = 0; idx < saveKeys.Count; idx++)
                {
                    object obj = FindCodeInEnum(saveKeys[idx], typeof(AppTypes.CommonStatus));
                    if (obj == null)
                    {
                        continue;
                    }
                    AppTypes.CommonStatus item = (AppTypes.CommonStatus)obj;
                    items.Add(new common.myComboBoxItem(AppTypes.Type2Text(item), item.ToString()));
                }
                return;
            }
            if (type == typeof(AppTypes.ChartTypes))
            {
                items.Clear();
                for (int idx = 0; idx < saveKeys.Count; idx++)
                {
                    object obj = FindCodeInEnum(saveKeys[idx], typeof(AppTypes.ChartTypes));
                    if (obj == null)
                    {
                        continue;
                    }
                    AppTypes.ChartTypes item = (AppTypes.ChartTypes)obj;
                    items.Add(new common.myComboBoxItem(AppTypes.Type2Text(item), item.ToString()));
                }
                return;
            }
            if (type == typeof(AppTypes.BizSectorTypes))
            {
                items.Clear();
                for (int idx = 0; idx < saveKeys.Count; idx++)
                {
                    object obj = FindCodeInEnum(saveKeys[idx], typeof(AppTypes.BizSectorTypes));
                    if (obj == null)
                    {
                        continue;
                    }
                    AppTypes.BizSectorTypes item = (AppTypes.BizSectorTypes)obj;
                    items.Add(new common.myComboBoxItem(AppTypes.Type2Text(item), item.ToString()));
                }
                return;
            }
        }
Ejemplo n.º 5
0
 public OutputInfo(Color cl, int w, AppTypes.ChartTypes chartType)
 {
     Color     = cl;
     Weight    = w;
     ChartType = chartType;
 }
Ejemplo n.º 6
0
 private void ChartTypeMenu_Click(object sender, EventArgs e)
 {
     this.ChartType = (AppTypes.ChartTypes)((ToolStripMenuItem)sender).Tag;
     Tools.Forms.tradeAnalysis activeForm = GetActiveStockForm();
     UpdateActiveForm(FormOptions.ChartType);
 }
Ejemplo n.º 7
0
 private void ChartTypeButton_Click(object sender, EventArgs e)
 {
     this.ChartType = (AppTypes.ChartTypes)((ToolStripButton)sender).Tag;
     UpdateActiveForm(FormOptions.ChartType);
 }
Ejemplo n.º 8
0
        private void tradeAnalysisActivatedHandler(object sender, EventArgs e)
        {
            try
            {
                Tools.Forms.tradeAnalysis activeForm = (Tools.Forms.tradeAnalysis)sender;
                if (activeForm == null) return;
                this.ChartType = activeForm.ChartPriceType;
                this.ChartTimeScale = activeForm.ChartTimeScale;
                this.ChartHaveGrid = activeForm.ChartHaveGrid;

                activeForm.RestoreChart();
            }
            catch (Exception er)
            {
                this.ShowError(er);
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Create ,enu and toolbars item
        /// </summary>
        private void SetFormAppearance()
        {
            standardStrip.BringToFront();
            chartStrip.BringToFront();
            toolsStrip.BringToFront();
            autoCreateStrip.BringToFront();

            //Assign chart type to each button
            lineChartBtn.Tag = AppTypes.ChartTypes.Line;
            barChartBtn.Tag = AppTypes.ChartTypes.Bar;
            candleSticksBtn.Tag = AppTypes.ChartTypes.CandleStick;

            lineChartMenuItem.Tag = AppTypes.ChartTypes.Line;
            barChartMenuItem.Tag = AppTypes.ChartTypes.Bar;
            candleSticksMenuItem.Tag = AppTypes.ChartTypes.CandleStick;

            //Create period button strips : M5,H1,H2,W1,D1,...
            autoCreateStrip.Items.Clear();
            periodicityMenuItem.DropDownItems.Clear();
            CreatePeriodicityStrip(autoCreateStrip, periodicityMenuItem);

            strategyCbStrip.SelectedIndexChanged += new EventHandler(PlotTradepointHandler);

            this.ChartType = AppTypes.ChartTypes.CandleStick;
            this.ChartTimeScale = AppTypes.TimeScaleFromCode(Settings.sysGlobal.DefaultTimeScaleCode);

            //dockPanel
            dockPanel.Parent = this;
            dockPanel.DockLeftPortion = (double)constPaneLeft/100;
            dockPanel.DockRightPortion = (double)constPaneRight / 100;

            dockPanel.DockTopPortion = (double)constPaneTop / 100;
            dockPanel.DockBottomPortion = (double)constPaneBottom / 100;

            dockPanel.AllowDrop = true;
            dockPanel.ActiveAutoHideContent = null;

            //Default language from global settings
            //SetCulture(Settings.sysGlobal.DefautLanguage);
        }