Esempio n. 1
0
        public virtual void AddStyle(PlotStyle style)
        {
            if (style == null)
            {
                throw new ArgumentNullException("style");
            }

            if (PlotStyles.Contains(style))
            {
                throw new ArgumentException(string.Format("Style '{0}' already exists.", style.Name));
            }

            var styleNode = this["plot_style"];

            if (styleNode == null)
            {
                throw new NotImplementedException("Create style node if it doesn't exist!");
            }

            style.NodeName = _nextStyleNode.ToString();
            styleNode.ChildNodes.Add(style);
        }
Esempio n. 2
0
        /* Usage: run in Execute:
         * public override void Execute(BarHistory bars, int idx)
         * {
         *  Color col = new Color();
         *  if (idx >= bars.Count-100)
         *  {
         *                      if ( bars.Close[idx] > bars.Close[idx - 50])
         *                              col = Color.Green;
         *                      else col = Color.Red;
         *
         *                      DrawLinRegChannel(idx, bars.AveragePriceHL, 45, 2, Color.FromArgb(30, col), PlotStyles.Line, 2);
         *  }
         * }
         */

        public static void DrawLinRegChannel(this UserStrategyBase obj, int bar, TimeSeries series, int period, double width, Color color, PlotStyles style, int line)
        {
            double Slope     = (period - 1) * LRSlope.Series(series, period)[bar];
            double Intercept = LR.Series(series, period)[bar];

            width *= StdError.Series(series, period)[bar];
            obj.DrawLine(bar - (period - 1), Intercept - Slope - width, bar, Intercept - width, color, 1);
            obj.DrawLine(bar - (period - 1), Intercept - Slope + width, bar, Intercept + width, color, 1);
        }