コード例 #1
0
        private void btnAddCustomIndicator_Click(object sender, RoutedEventArgs e)
        {
            //count indicator, just to give an unique name for a new indicator
            _indicatorCount = _stockChartX.GetIndicatorCountByType(IndicatorType.CustomIndicator);
            //create inidcator name
            string indicatorName = "Custom Indicator";

            if (_indicatorCount > 0)
            {
                indicatorName += _indicatorCount;
            }
            //get a reference to the custom indicator
            CustomIndicator indicator = (CustomIndicator)_stockChartX.AddIndicator(IndicatorType.CustomIndicator,
                                                                                   indicatorName, _stockChartX.AddChartPanel(),
                                                                                   true);

            //Add some parameters to the custom indicator, these parameters willl apear in indicator's dialog
            //where user will be able to set them manually
            indicator.AddParameter("My Param1", ParameterType.ptPeriods, 10, typeof(int));
            indicator.AddParameter("My Param2", ParameterType.ptPointsOrPercent, 12, typeof(int));
            indicator.AddParameter("My Param3", ParameterType.ptSymbol, "", typeof(string));
            indicator.AddParameter(null, ParameterType.ptLimitMoveValue, 16, typeof(int));

            indicator.SetParameterValue(0, 10);
            indicator.SetParameterValue(1, 12);
            indicator.SetParameterValue(2, "MSFT.CLOSE");
            indicator.SetParameterValue(3, 2);

            //after we set parameters call Update, this will raise the event OnCustomIndicatorNeedsData
            //where you use your own formulas to calculate the indicator values
            _stockChartX.Update();
        }