コード例 #1
0
ファイル: Arc.cs プロジェクト: gerryzhou/targetrichtrades
 /// <summary>
 /// Draws an arc.
 /// </summary>
 /// <param name="owner">The hosting NinjaScript object which is calling the draw method</param>
 /// <param name="tag">A user defined unique id used to reference the draw object</param>
 /// <param name="isAutoScale">Determines if the draw object will be included in the y-axis scale</param>
 /// <param name="startBarsAgo">The starting bar (x axis coordinate) where the draw object will be drawn. For example, a value of 10 would paint the draw object 10 bars back.</param>
 /// <param name="startY">The starting y value coordinate where the draw object will be drawn</param>
 /// <param name="endBarsAgo">The end bar (x axis coordinate) where the draw object will terminate</param>
 /// <param name="endY">The end y value coordinate where the draw object will terminate</param>
 /// <param name="brush">The brush used to color draw object</param>
 /// <param name="dashStyle">The dash style used for the lines of the object.</param>
 /// <param name="width">The width of the draw object</param>
 /// <param name="drawOnPricePanel">Determines if the draw-object should be on the price panel or a separate panel</param>
 /// <returns></returns>
 public static Arc Arc(NinjaScriptBase owner, string tag, bool isAutoScale, int startBarsAgo, double startY, int endBarsAgo,
                       double endY, Brush brush, DashStyleHelper dashStyle, int width, bool drawOnPricePanel)
 {
     return(DrawingTool.DrawToggledPricePanel(owner, drawOnPricePanel, () =>
                                              ArcCore(owner, isAutoScale, tag, startBarsAgo,
                                                      Core.Globals.MinDate, startY, endBarsAgo, Core.Globals.MinDate, endY, brush, dashStyle, width, false, null)));
 }
コード例 #2
0
 public static void DrawZigZag(NinjaScriptBase owner, DrawingProperties drawingProperties, Point pointOne, Point pointTwo)
 {
     DrawWrapper.DrawLine(owner, drawingProperties,
                          pointTwo.Index,
                          pointTwo.BarIndex, pointTwo.Price,
                          pointOne.BarIndex, pointOne.Price);
 }
コード例 #3
0
 public void PrintError(NinjaScriptBase owner, object text)
 {
     if (!IsInvisible(owner))
     {
         Draw.TextFixed(owner, "Error", text.ToString(), TextPosition.BottomRight);
     }
 }
コード例 #4
0
 /// <summary>
 /// Draws a region on a chart.
 /// </summary>
 /// <param name="owner">The hosting NinjaScript object which is calling the draw method</param>
 /// <param name="tag">A user defined unique id used to reference the draw object</param>
 /// <param name="startBarsAgo">The starting bar (x axis co-ordinate) where the draw object will be drawn. For example, a value of 10 would paint the draw object 10 bars back.</param>
 /// <param name="endBarsAgo">The end bar (x axis co-ordinate) where the draw object will terminate</param>
 /// <param name="series1">Any Series double type object such as an indicator, Close, High, Low etc.. The value of the object will represent a y value.</param>
 /// <param name="series2">Any Series double type object such as an indicator, Close, High, Low etc.. The value of the object will represent a y value.</param>
 /// <param name="outlineBrush">The brush used to color the region outline of draw object</param>
 /// <param name="areaBrush">The brush used to color the fill region area of the draw object</param>
 /// <param name="areaOpacity"> Sets the level of transparency for the fill color. Valid values between 0 - 100. (0 = completely transparent, 100 = no opacity)</param>
 /// <param name="displacement">An optional parameter which will offset the barsAgo value for the Series double value used to match the desired Displacement.  Default value is 0</param>
 /// <returns></returns>
 public static Region Region(NinjaScriptBase owner, string tag, int startBarsAgo,
                             int endBarsAgo, ISeries <double> series1, ISeries <double> series2, Brush outlineBrush,
                             Brush areaBrush, int areaOpacity, int displacement = 0)
 {
     return(Region(owner, tag, startBarsAgo, Core.Globals.MinDate, endBarsAgo, Core.Globals.MinDate,
                   series1, series2, 0, outlineBrush, areaBrush, areaOpacity, displacement));
 }
コード例 #5
0
 public PivotCalculation(NinjaScriptBase owner,
                         double maxPercentOfPivotRetraction,
                         double minPercentOfPivotRetraction) : base(owner)
 {
     this.maxPercentOfPivotRetraction = maxPercentOfPivotRetraction;
     this.minPercentOfPivotRetraction = minPercentOfPivotRetraction;
 }
コード例 #6
0
ファイル: Arc.cs プロジェクト: gerryzhou/targetrichtrades
 /// <summary>
 /// Draws an arc.
 /// </summary>
 /// <param name="owner">The hosting NinjaScript object which is calling the draw method</param>
 /// <param name="tag">A user defined unique id used to reference the draw object</param>
 /// <param name="isAutoScale">Determines if the draw object will be included in the y-axis scale</param>
 /// <param name="startTime">The starting time where the draw object will be drawn.</param>
 /// <param name="startY">The starting y value coordinate where the draw object will be drawn</param>
 /// <param name="endTime">The end time where the draw object will terminate</param>
 /// <param name="endY">The end y value coordinate where the draw object will terminate</param>
 /// <param name="brush">The brush used to color draw object</param>
 /// <param name="dashStyle">The dash style used for the lines of the object.</param>
 /// <param name="width">The width of the draw object</param>
 /// <param name="drawOnPricePanel">Determines if the draw-object should be on the price panel or a separate panel</param>
 /// <returns></returns>
 public static Arc Arc(NinjaScriptBase owner, string tag, bool isAutoScale, DateTime startTime, double startY, DateTime endTime,
                       double endY, Brush brush, DashStyleHelper dashStyle, int width, bool drawOnPricePanel)
 {
     return(DrawingTool.DrawToggledPricePanel(owner, drawOnPricePanel, () =>
                                              ArcCore(owner, isAutoScale, tag, int.MinValue,
                                                      startTime, startY, int.MinValue, endTime, endY, brush, dashStyle, width, false, null)));
 }
コード例 #7
0
        // Initialization

        protected Calculation(NinjaScriptBase owner, PriceActionSwingClass priceActionSwingClass)
        {
            this.owner = owner;
            this.priceActionSwingClass = priceActionSwingClass;

            highs = new Series <double>(owner);
            lows  = new Series <double>(owner);
        }
コード例 #8
0
        public static void DrawPivot(NinjaScriptBase owner, DrawingProperties drawingProperties, MatrixPoints matrixPoints)
        {
            switch (matrixPoints.TrendSideSignal)
            {
            case MatrixPoints.WhichTrendSideSignal.Bullish:
                DrawWrapper.DrawPathLine(owner, drawingProperties,
                                         matrixPoints.PointsList[3].Index,
                                         matrixPoints.PointsList[3].BarIndex,
                                         matrixPoints.PointsList[3].Price,
                                         matrixPoints.PointsList[2].BarIndex,
                                         matrixPoints.PointsList[2].Price,
                                         System.Windows.Media.Brushes.Green);

                DrawWrapper.DrawPathLine(owner, drawingProperties,
                                         matrixPoints.PointsList[2].Index,
                                         matrixPoints.PointsList[2].BarIndex,
                                         matrixPoints.PointsList[2].Price,
                                         matrixPoints.PointsList[1].BarIndex,
                                         matrixPoints.PointsList[1].Price,
                                         System.Windows.Media.Brushes.Green);

                DrawWrapper.DrawPathLine(owner, drawingProperties,
                                         matrixPoints.PointsList[1].Index,
                                         matrixPoints.PointsList[1].BarIndex,
                                         matrixPoints.PointsList[1].Price,
                                         matrixPoints.PointsList[0].BarIndex,
                                         matrixPoints.PointsList[0].Price,
                                         System.Windows.Media.Brushes.Green);
                break;

            case MatrixPoints.WhichTrendSideSignal.Bearish:
                DrawWrapper.DrawPathLine(owner, drawingProperties,
                                         matrixPoints.PointsList[3].Index,
                                         matrixPoints.PointsList[3].BarIndex,
                                         matrixPoints.PointsList[3].Price,
                                         matrixPoints.PointsList[2].BarIndex,
                                         matrixPoints.PointsList[2].Price,
                                         System.Windows.Media.Brushes.Red);

                DrawWrapper.DrawPathLine(owner, drawingProperties,
                                         matrixPoints.PointsList[2].Index,
                                         matrixPoints.PointsList[2].BarIndex,
                                         matrixPoints.PointsList[2].Price,
                                         matrixPoints.PointsList[1].BarIndex,
                                         matrixPoints.PointsList[1].Price,
                                         System.Windows.Media.Brushes.Red);

                DrawWrapper.DrawPathLine(owner, drawingProperties,
                                         matrixPoints.PointsList[1].Index,
                                         matrixPoints.PointsList[1].BarIndex,
                                         matrixPoints.PointsList[1].Price,
                                         matrixPoints.PointsList[0].BarIndex,
                                         matrixPoints.PointsList[0].Price,
                                         System.Windows.Media.Brushes.Red);
                break;
            }
        }
コード例 #9
0
ファイル: AndrewsPitchfork.cs プロジェクト: theprofe8/nt8
 /// <summary>
 /// Draws an Andrew's Pitchfork.
 /// </summary>
 /// <param name="owner">The owner.</param>
 /// <param name="tag">The tag.</param>
 /// <param name="isAutoScale">if set to <c>true</c> [is automatic scale].</param>
 /// <param name="anchor1Time">The time of the 1st anchor point</param>
 /// <param name="anchor1Y">The y value of the 1st anchor point</param>
 /// <param name="anchor2Time">The time of the 2nd anchor point</param>
 /// <param name="anchor2Y">The y value of the 2nd anchor point</param>
 /// <param name="anchor3Time">The time of the 3rd anchor point</param>
 /// <param name="anchor3Y">The y value of the 3rd anchor point</param>
 /// <param name="isGlobal">if set to <c>true</c> [is global].</param>
 /// <param name="templateName">Name of the template.</param>
 /// <returns></returns>
 public static AndrewsPitchfork AndrewsPitchfork(NinjaScriptBase owner, string tag, bool isAutoScale,
                                                 DateTime anchor1Time, double anchor1Y,
                                                 DateTime anchor2Time, double anchor2Y,
                                                 DateTime anchor3Time, double anchor3Y,
                                                 bool isGlobal, string templateName)
 {
     return(AndrewsPitchforkCore(owner, tag, isAutoScale,
                                 int.MinValue, anchor1Time, anchor1Y,
                                 int.MinValue, anchor2Time, anchor2Y,
                                 int.MinValue, anchor3Time, anchor3Y, null, DashStyleHelper.Solid, 0, isGlobal, templateName));
 }
コード例 #10
0
ファイル: AndrewsPitchfork.cs プロジェクト: theprofe8/nt8
 /// <summary>
 /// Draws an Andrew's Pitchfork.
 /// </summary>
 /// <param name="owner">The hosting NinjaScript object which is calling the draw method</param>
 /// <param name="tag">A user defined unique id used to reference the draw object</param>
 /// <param name="isAutoScale">Determines if the draw object will be included in the y-axis scale</param>
 /// <param name="anchor1BarsAgo">The number of bars ago (x value) of the 1st anchor point</param>
 /// <param name="anchor1Y">The y value of the 1st anchor point</param>
 /// <param name="anchor2BarsAgo">The number of bars ago (x value) of the 2nd anchor point</param>
 /// <param name="anchor2Y">The y value of the 2nd anchor point</param>
 /// <param name="anchor3BarsAgo">The number of bars ago (x value) of the 3rd anchor point</param>
 /// <param name="anchor3Y">The y value of the 3rd anchor point</param>
 /// <param name="isGlobal">Determines if the draw object will be global across all charts which match the instrument</param>
 /// <param name="templateName">The name of the drawing tool template the object will use to determine various visual properties</param>
 /// <returns></returns>
 public static AndrewsPitchfork AndrewsPitchfork(NinjaScriptBase owner, string tag, bool isAutoScale,
                                                 int anchor1BarsAgo, double anchor1Y,
                                                 int anchor2BarsAgo, double anchor2Y,
                                                 int anchor3BarsAgo, double anchor3Y,
                                                 bool isGlobal, string templateName)
 {
     return(AndrewsPitchforkCore(owner, tag, isAutoScale,
                                 anchor1BarsAgo, Core.Globals.MinDate, anchor1Y,
                                 anchor2BarsAgo, Core.Globals.MinDate, anchor2Y,
                                 anchor3BarsAgo, Core.Globals.MinDate, anchor3Y, null, DashStyleHelper.Solid, 0, isGlobal, templateName));
 }
コード例 #11
0
        private static Arc ArcCore(NinjaScriptBase owner, bool isAutoScale, string tag,
                                   int startBarsAgo, DateTime startTime, double startY, int endBarsAgo, DateTime endTime, double endY,
                                   Brush brush, DashStyleHelper dashStyle, int width, bool isGlobal, string templateName)
        {
            if (owner == null)
            {
                throw new ArgumentException("owner");
            }

            if (startTime == Core.Globals.MinDate && endTime == Core.Globals.MinDate && startBarsAgo == int.MinValue && endBarsAgo == int.MinValue)
            {
                throw new ArgumentException("bad start/end date/time");
            }

            if (string.IsNullOrWhiteSpace(tag))
            {
                throw new ArgumentException("tag cant be null or empty", "tag");
            }

            if (isGlobal && tag[0] != GlobalDrawingToolManager.GlobalDrawingToolTagPrefix)
            {
                tag = GlobalDrawingToolManager.GlobalDrawingToolTagPrefix + tag;
            }

            Arc newArc = DrawingTool.GetByTagOrNew(owner, typeof(Arc), tag, templateName) as Arc;

            if (newArc == null)
            {
                return(null);
            }

            DrawingTool.SetDrawingToolCommonValues(newArc, tag, isAutoScale, owner, isGlobal);

            // dont nuke existing anchor refs on the instance
            ChartAnchor startAnchor = DrawingTool.CreateChartAnchor(owner, startBarsAgo, startTime, startY);
            ChartAnchor endAnchor   = DrawingTool.CreateChartAnchor(owner, endBarsAgo, endTime, endY);

            startAnchor.CopyDataValues(newArc.StartAnchor);
            endAnchor.CopyDataValues(newArc.EndAnchor);

            if (brush != null)
            {
                newArc.Stroke = new Stroke(brush, dashStyle, width, 50)
                {
                    RenderTarget = newArc.Stroke.RenderTarget
                };
                newArc.ArcStroke = new Stroke(brush, dashStyle, width)
                {
                    RenderTarget = newArc.ArcStroke.RenderTarget
                };
            }
            newArc.SetState(State.Active);
            return(newArc);
        }
コード例 #12
0
ファイル: AndrewsPitchfork.cs プロジェクト: theprofe8/nt8
 /// <summary>
 /// Draws an Andrew's Pitchfork.
 /// </summary>
 /// <param name="owner">The hosting NinjaScript object which is calling the draw method</param>
 /// <param name="tag">A user defined unique id used to reference the draw object</param>
 /// <param name="isAutoScale">Determines if the draw object will be included in the y-axis scale</param>
 /// <param name="anchor1Time">The time of the 1st anchor point</param>
 /// <param name="anchor1Y">The y value of the 1st anchor point</param>
 /// <param name="anchor2Time">The time of the 2nd anchor point</param>
 /// <param name="anchor2Y">The y value of the 2nd anchor point</param>
 /// <param name="anchor3Time">The time of the 3rd anchor point</param>
 /// <param name="anchor3Y">The y value of the 3rd anchor point</param>
 /// <param name="brush">The brush used to color draw object</param>
 /// <param name="dashStyle">The dash style used for the lines of the object</param>
 /// <param name="width">The width of the draw object</param>
 /// <returns></returns>
 public static AndrewsPitchfork AndrewsPitchfork(NinjaScriptBase owner, string tag, bool isAutoScale,
                                                 DateTime anchor1Time, double anchor1Y,
                                                 DateTime anchor2Time, double anchor2Y,
                                                 DateTime anchor3Time, double anchor3Y,
                                                 Brush brush, DashStyleHelper dashStyle, int width)
 {
     return(AndrewsPitchforkCore(owner, tag, isAutoScale,
                                 int.MinValue, anchor1Time, anchor1Y,
                                 int.MinValue, anchor2Time, anchor2Y,
                                 int.MinValue, anchor3Time, anchor3Y, brush, dashStyle, width, false, null));
 }
コード例 #13
0
ファイル: AndrewsPitchfork.cs プロジェクト: theprofe8/nt8
 /// <summary>
 /// Draws an Andrew's Pitchfork.
 /// </summary>
 /// <param name="owner">The hosting NinjaScript object which is calling the draw method</param>
 /// <param name="tag">A user defined unique id used to reference the draw object</param>
 /// <param name="isAutoScale">Determines if the draw object will be included in the y-axis scale</param>
 /// <param name="anchor1BarsAgo">The number of bars ago (x value) of the 1st anchor point</param>
 /// <param name="anchor1Y">The y value of the 1st anchor point</param>
 /// <param name="anchor2BarsAgo">The number of bars ago (x value) of the 2nd anchor point</param>
 /// <param name="anchor2Y">The y value of the 2nd anchor point</param>
 /// <param name="anchor3BarsAgo">The number of bars ago (x value) of the 3rd anchor point</param>
 /// <param name="anchor3Y">The y value of the 3rd anchor point</param>
 /// <param name="brush">The brush used to color draw object</param>
 /// <param name="dashStyle">The dash style used for the lines of the object.</param>
 /// <param name="width">The width of the draw object</param>
 /// <returns></returns>
 public static AndrewsPitchfork AndrewsPitchfork(NinjaScriptBase owner, string tag, bool isAutoScale,
                                                 int anchor1BarsAgo, double anchor1Y,
                                                 int anchor2BarsAgo, double anchor2Y,
                                                 int anchor3BarsAgo, double anchor3Y,
                                                 Brush brush, DashStyleHelper dashStyle, int width)
 {
     return(AndrewsPitchforkCore(owner, tag, isAutoScale,
                                 anchor1BarsAgo, Core.Globals.MinDate, anchor1Y,
                                 anchor2BarsAgo, Core.Globals.MinDate, anchor2Y,
                                 anchor3BarsAgo, Core.Globals.MinDate, anchor3Y, brush, dashStyle, width, false, null));
 }
コード例 #14
0
        // draw text fixed  //get rid of isOutlineVisible
        /// <summary>
        /// Texts the fixed core.
        /// </summary>
        /// <param name="owner">The hosting NinjaScript object which is calling the draw method</param>
        /// <param name="tag">A user defined unique id used to reference the draw object</param>
        /// <param name="text">The text you wish to draw</param>
        /// <param name="textPosition">The TextPosition of the text</param>
        /// <param name="textBrush">The brush used to color the text of the draw object</param>
        /// <param name="font">A SimpleFont object</param>
        /// <param name="outlineBrush">The brush used to color the region outline of draw object</param>
        /// <param name="areaBrush">The brush used to color the fill region area of the draw object</param>
        /// <param name="areaOpacity"> Sets the level of transparency for the fill color. Valid values between 0 - 100. (0 = completely transparent, 100 = no opacity)</param>
        /// <param name="isGlobal">Determines if the draw object will be global across all charts which match the instrument</param>
        /// <param name="templateName">The name of the drawing tool template the object will use to determine various visual properties</param>
        /// <param name="outlineDashStyle">The outline dash style.</param>
        /// <param name="outlineWidth">Width of the outline.</param>
        /// <returns></returns>
        private static TextFixed TextFixedCore(NinjaScriptBase owner, string tag, string text,
                                               TextPosition textPosition, Brush textBrush, Gui.Tools.SimpleFont font, Brush outlineBrush,
                                               Brush areaBrush, int?areaOpacity, bool isGlobal, string templateName, DashStyleHelper outlineDashStyle, int outlineWidth)
        {
            TextFixed txtFixed = DrawingTool.GetByTagOrNew(owner, typeof(TextFixed), tag, templateName) as TextFixed;

            if (txtFixed == null)
            {
                return(null);
            }

            DrawingTool.SetDrawingToolCommonValues(txtFixed, tag, false, owner, isGlobal);

            // set defaults, then apply ns properties so they dont get trampled
            txtFixed.SetState(State.Active);

            txtFixed.DisplayText  = text;
            txtFixed.TextPosition = textPosition;
            if (textBrush != null)
            {
                txtFixed.TextBrush = textBrush;
            }

            if (txtFixed.TextBrush == null)
            {
                txtFixed.UseChartTextBrush = true;
            }

            if (outlineBrush != null)
            {
                txtFixed.OutlineStroke = new Stroke(outlineBrush, outlineDashStyle, outlineWidth)
                {
                    RenderTarget = txtFixed.OutlineStroke.RenderTarget
                }
            }
            ;

            if (areaBrush != null)
            {
                txtFixed.AreaBrush = areaBrush;
            }

            if (areaOpacity != null)
            {
                txtFixed.AreaOpacity = areaOpacity.Value;
            }

            if (font != null)
            {
                txtFixed.Font = font;
            }

            return(txtFixed);
        }
コード例 #15
0
 public static void DrawDot(NinjaScriptBase owner,
                            DrawingProperties drawingProperties,
                            int pointIndex,
                            int barIndex,
                            double price,
                            Brush dotColor)
 {
     Draw.Dot(owner, ("Dot " + pointIndex), drawingProperties.IsDotAutoScale,
              ConvertBarIndexToBarsAgo(owner, barIndex), price,
              dotColor).OutlineBrush = drawingProperties.UpDotOutlineColor;
 }
コード例 #16
0
 public static void DrawText(NinjaScriptBase owner,
                             DrawingProperties drawingProperties,
                             int pointIndex,
                             int barIndex,
                             double price,
                             int yPixelOffSet)
 {
     Draw.Text(owner, ("Text " + pointIndex), drawingProperties.IsTextAutoScale, pointIndex.ToString(),
               ConvertBarIndexToBarsAgo(owner, barIndex), price, yPixelOffSet, drawingProperties.TextColor,
               drawingProperties.TextSimpleFont, drawingProperties.TextAligmentPropertie,
               drawingProperties.TextOutlineBrush, drawingProperties.TextAreaBrush, drawingProperties.TextAreaOpacity);
 }
コード例 #17
0
ファイル: AndrewsPitchfork.cs プロジェクト: theprofe8/nt8
        private static AndrewsPitchfork AndrewsPitchforkCore(NinjaScriptBase owner,
                                                             string tag, bool isAutoScale,
                                                             int anchor1BarsAgo, DateTime anchor1Time, double anchor1Y,
                                                             int anchor2BarsAgo, DateTime anchor2Time, double anchor2Y,
                                                             int anchor3BarsAgo, DateTime anchor3Time, double anchor3Y,
                                                             Brush brush, DashStyleHelper dashStyle, int width,
                                                             bool isGlobal, string templateName)
        {
            if (owner == null)
            {
                throw new ArgumentException("owner");
            }

            if (string.IsNullOrWhiteSpace(tag))
            {
                throw new ArgumentException(@"tag cant be null or empty", "tag");
            }

            if (isGlobal && tag[0] != GlobalDrawingToolManager.GlobalDrawingToolTagPrefix)
            {
                tag = GlobalDrawingToolManager.GlobalDrawingToolTagPrefix + tag;
            }

            AndrewsPitchfork pitchfork = DrawingTool.GetByTagOrNew(owner, typeof(AndrewsPitchfork), tag, templateName) as AndrewsPitchfork;

            if (pitchfork == null)
            {
                return(null);
            }

            DrawingTool.SetDrawingToolCommonValues(pitchfork, tag, isAutoScale, owner, isGlobal);

            ChartAnchor startAnchor = DrawingTool.CreateChartAnchor(owner, anchor1BarsAgo, anchor1Time, anchor1Y);
            ChartAnchor endAnchor   = DrawingTool.CreateChartAnchor(owner, anchor2BarsAgo, anchor2Time, anchor2Y);
            ChartAnchor extAnchor   = DrawingTool.CreateChartAnchor(owner, anchor3BarsAgo, anchor3Time, anchor3Y);

            startAnchor.CopyDataValues(pitchfork.StartAnchor);
            endAnchor.CopyDataValues(pitchfork.EndAnchor);
            extAnchor.CopyDataValues(pitchfork.ExtensionAnchor);

            if (string.IsNullOrEmpty(templateName) || brush != null)
            {
                pitchfork.AnchorLineStroke.Width = width;
                pitchfork.RetracementLineStroke  = new Stroke(brush, dashStyle, width)
                {
                    RenderTarget = pitchfork.RetracementLineStroke.RenderTarget
                };
            }

            pitchfork.SetState(State.Active);
            return(pitchfork);
        }
コード例 #18
0
        private static T DrawRangeProfileTypeCore <T>(NinjaScriptBase owner, bool isAutoScale, string tag,
                                                      int startBarsAgo, DateTime startTime, double startY, int endBarsAgo, DateTime endTime, double endY,
                                                      Brush brush, DashStyleHelper dashStyle, int width, bool isGlobal, string templateName, Model model) where T : RangeProfile
        {
            if (owner == null)
            {
                throw new ArgumentException("owner");
            }

            if (string.IsNullOrWhiteSpace(tag))
            {
                throw new ArgumentException(@"tag cant be null or empty", "tag");
            }

            if (isGlobal && tag[0] != GlobalDrawingToolManager.GlobalDrawingToolTagPrefix)
            {
                tag = string.Format("{0}{1}", GlobalDrawingToolManager.GlobalDrawingToolTagPrefix, tag);
            }

            T lineT = DrawingTool.GetByTagOrNew(owner, typeof(T), tag, templateName) as T;

            lineT.model = model;


            if (lineT == null)
            {
                return(null);
            }

            if (startTime == Core.Globals.MinDate && endTime == Core.Globals.MinDate && startBarsAgo == int.MinValue && endBarsAgo == int.MinValue)
            {
                throw new ArgumentException("bad start/end date/time");
            }

            DrawingTool.SetDrawingToolCommonValues(lineT, tag, isAutoScale, owner, isGlobal);


            // dont nuke existing anchor refs on the instance
            ChartAnchor startAnchor;

            startAnchor = DrawingTool.CreateChartAnchor(owner, startBarsAgo, startTime, startY);
            ChartAnchor endAnchor = DrawingTool.CreateChartAnchor(owner, endBarsAgo, endTime, endY);

            startAnchor.CopyDataValues(lineT.StartAnchor);
            endAnchor.CopyDataValues(lineT.EndAnchor);

            /*if (brush != null)
             *                  lineT.LineStroke = new Stroke(brush, dashStyle, width);*/

            lineT.SetState(State.Active);
            return(lineT);
        }
コード例 #19
0
        private bool IsInvisible(NinjaScriptBase owner)
        {
            foreach (NinjaScriptBase nsb in invisibleIndicator)
            {
                if (nsb == owner)
                {
                    return(true);
                }
                break;
            }

            return(false);
        }
コード例 #20
0
 public static void DrawLine(NinjaScriptBase owner,
                             DrawingProperties drawingProperties,
                             int pointIndex,
                             int barIndex1,
                             double price1,
                             int barIndex0,
                             double price0)
 {
     Draw.Line(owner, "Line type 1" + pointIndex, false,
               ConvertBarIndexToBarsAgo(owner, barIndex1), price1,
               ConvertBarIndexToBarsAgo(owner, barIndex0), price0,
               drawingProperties.LineColor, drawingProperties.LineDashStyle, drawingProperties.LineWidth);
 }
コード例 #21
0
 public static void DrawLineForTest(NinjaScriptBase owner,
                                    string text,
                                    Brush color,
                                    int barIndex1,
                                    double price1,
                                    int barIndex0,
                                    double price0)
 {
     Draw.Line(owner, text, false,
               ConvertBarIndexToBarsAgo(owner, barIndex1), price1,
               ConvertBarIndexToBarsAgo(owner, barIndex0), price0,
               color, Gui.DashStyleHelper.Solid, 5);
 }
コード例 #22
0
ファイル: Polygon.cs プロジェクト: theprofe8/nt8
        private static Polygon PolygonCore(NinjaScriptBase owner, string tag, bool isAutoScale, List <ChartAnchor> chartAnchors, Brush brush,
                                           DashStyleHelper dashStyle, Brush areaBrush, int areaOpacity, bool isGlobal, string templateName)
        {
            if (owner == null)
            {
                throw new ArgumentException("owner");
            }

            if (string.IsNullOrWhiteSpace(tag))
            {
                throw new ArgumentException(@"tag cant be null or empty", "tag");
            }

            if (isGlobal && tag[0] != GlobalDrawingToolManager.GlobalDrawingToolTagPrefix)
            {
                tag = GlobalDrawingToolManager.GlobalDrawingToolTagPrefix + tag;
            }

            Polygon polygon = DrawingTool.GetByTagOrNew(owner, typeof(Polygon), tag, templateName) as Polygon;

            if (polygon == null)
            {
                return(null);
            }

            DrawingTool.SetDrawingToolCommonValues(polygon, tag, isAutoScale, owner, isGlobal);

            if (chartAnchors != null)
            {
                polygon.ChartAnchors = chartAnchors;
            }

            if (brush != null)
            {
                polygon.OutlineStroke = new Stroke(brush, dashStyle, 2);
            }

            if (areaBrush != null)
            {
                polygon.AreaBrush = areaBrush;
            }

            if (areaOpacity > -1)
            {
                polygon.AreaOpacity = areaOpacity;
            }

            polygon.SetState(State.Active);
            return(polygon);
        }
コード例 #23
0
        // Initialization

        public PriceActionSwingClass(NinjaScriptBase owner, DrawingProperties drawingProperties, CalculationTypeList calculationType,
                                     double strength, bool useHighLow, bool showPoints, bool showLines)
        {
            this.owner                 = owner;
            this.drawingProperties     = drawingProperties;
            tickCalculation            = new TickCalculation(owner, this);
            swingForwardCalculation    = new SwingForwardCalculation(owner, this);
            swingForwardCalculationOld = new SwingForwardCalculationOld(owner, this);

            CalculationType = calculationType;
            Strength        = strength;
            UseHighLow      = useHighLow;
            ShowPoints      = showPoints;
            ShowLines       = showLines;
        }
コード例 #24
0
        public void Print(NinjaScriptBase owner, object text)
        {
            if (!IsInvisible(owner))
            {
                if (owner.CurrentBar != lastBarIndex || owner.CurrentBar == 0)
                {
                    Code.Output.Process(owner.CurrentBar + " " + owner.ToString(), PrintTo.OutputTab1);
                    Code.Output.Process(GetStringSpace(owner.CurrentBar) + " " + text, PrintTo.OutputTab1);
                }
                else
                {
                    Code.Output.Process(GetStringSpace(owner.CurrentBar) + " " + text, PrintTo.OutputTab1);
                }

                lastBarIndex = owner.CurrentBar;
            }
        }
コード例 #25
0
        private static PathTool PathCore(NinjaScriptBase owner, string tag, bool isAutoScale, List <ChartAnchor> chartAnchors, Brush brush, DashStyleHelper dashStyle, bool isGlobal, string templateName)
        {
            if (owner == null)
            {
                throw new ArgumentException("owner");
            }

            if (string.IsNullOrWhiteSpace(tag))
            {
                throw new ArgumentException(@"tag cant be null or empty", "tag");
            }

            if (isGlobal && tag[0] != GlobalDrawingToolManager.GlobalDrawingToolTagPrefix)
            {
                tag = GlobalDrawingToolManager.GlobalDrawingToolTagPrefix + tag;
            }

            PathTool path = DrawingTool.GetByTagOrNew(owner, typeof(PathTool), tag, templateName) as PathTool;

            if (path == null)
            {
                return(null);
            }

            DrawingTool.SetDrawingToolCommonValues(path, tag, isAutoScale, owner, isGlobal);

            if (chartAnchors != null)
            {
                path.ChartAnchors = chartAnchors;

                for (int i = 1; i < chartAnchors.Count; i++)
                {
                    path.PathToolSegments.Add(new PathToolSegment(chartAnchors[i - 1], chartAnchors[i], string.Format("{0} {1}", Custom.Resource.NinjaScriptDrawingToolPathSegment, i)));
                }
            }

            if (brush != null)
            {
                path.OutlineStroke = new Stroke(brush, dashStyle, 2);
            }

            path.SetState(State.Active);
            return(path);
        }
コード例 #26
0
        // Initialization

        public DowTheoryClass(NinjaScriptBase owner, DrawingProperties drawingProperties, CalculationTypeListDowTheory calculationTypeListDT,
                              CalculationTypeList calculationTypeListPCW, double strength, bool useHighLow, bool showPoints, bool showLines,
                              double maxPercentOfPivotRetraction, double minPercentOfPivotRetraction)
        {
            this.owner             = owner;
            this.drawingProperties = drawingProperties;
            CalculationType        = calculationTypeListDT;

            priceActionSwingClass = new PriceActionSwingClass(owner, drawingProperties, calculationTypeListPCW, strength,
                                                              useHighLow, showPoints, showLines);
            trendCalculation = new TrendCalculation(owner);
            pivotCalculation = new PivotCalculation(owner, maxPercentOfPivotRetraction, minPercentOfPivotRetraction);

            /*
             * if (!ShowLog)
             * {
             *  logPrinter.SetIndicatorAsInvisible(owner);
             * }
             */
        }
コード例 #27
0
        private static Ruler RulerCore(NinjaScriptBase owner, string tag, bool isAutoScale, int startBarsAgo, DateTime startTime, double startY,
                                       int endBarsAgo, DateTime endTime, double endY, int textBarsAgo, DateTime textTime, double textY, bool isGlobal, string templateName)
        {
            if (owner == null)
            {
                throw new ArgumentException("owner");
            }
            if (startTime == Core.Globals.MinDate && endTime == Core.Globals.MinDate && startBarsAgo == int.MinValue && endBarsAgo == int.MinValue)
            {
                throw new ArgumentException("bad start/end date/time");
            }

            if (string.IsNullOrWhiteSpace(tag))
            {
                throw new ArgumentException(@"tag cant be null or empty", "tag");
            }

            if (isGlobal && tag[0] != GlobalDrawingToolManager.GlobalDrawingToolTagPrefix)
            {
                tag = GlobalDrawingToolManager.GlobalDrawingToolTagPrefix + tag;
            }

            Ruler ruler = DrawingTool.GetByTagOrNew(owner, typeof(Ruler), tag, templateName) as Ruler;

            if (ruler == null)
            {
                return(null);
            }

            DrawingTool.SetDrawingToolCommonValues(ruler, tag, isAutoScale, owner, isGlobal);

            ChartAnchor startAnchor = DrawingTool.CreateChartAnchor(owner, startBarsAgo, startTime, startY);
            ChartAnchor endAnchor   = DrawingTool.CreateChartAnchor(owner, endBarsAgo, endTime, endY);
            ChartAnchor txtAnchor   = DrawingTool.CreateChartAnchor(owner, textBarsAgo, textTime, textY);

            startAnchor.CopyDataValues(ruler.StartAnchor);
            endAnchor.CopyDataValues(ruler.EndAnchor);
            txtAnchor.CopyDataValues(ruler.TextAnchor);
            ruler.SetState(State.Active);
            return(ruler);
        }
コード例 #28
0
        private static Region Region(NinjaScriptBase owner, string tag,
                                     int startBarsAgo, DateTime startTime, int endBarsAgo, DateTime endTime,
                                     ISeries <double> series1, ISeries <double> series2, double price,
                                     Brush outlineBrush, Brush areaBrush, int areaOpacity, int displacement)
        {
            Region region = DrawingTool.GetByTagOrNew(owner, typeof(Region), tag, null) as Region;

            if (region == null)
            {
                return(null);
            }

            DrawingTool.SetDrawingToolCommonValues(region, tag, false, owner, false);

            ChartAnchor startAnchor = DrawingTool.CreateChartAnchor(owner, startBarsAgo, startTime, 0);
            ChartAnchor endAnchor   = DrawingTool.CreateChartAnchor(owner, endBarsAgo, endTime, 0);

            startAnchor.CopyDataValues(region.StartAnchor);
            endAnchor.CopyDataValues(region.EndAnchor);

            if (series1 == null && series2 == null)
            {
                throw new ArgumentException("At least one series is required");
            }

            region.Series1      = series1;
            region.Series2      = series2;
            region.Price        = price;
            region.Displacement = displacement;

            region.AreaBrush   = areaBrush;
            region.AreaOpacity = areaOpacity;

            region.OutlineStroke = outlineBrush != null ? new Stroke(outlineBrush) : null;

            region.SetState(State.Active);
            region.DrawingState = DrawingState.Normal;
            region.IsSelected   = false;
            return(region);
        }
コード例 #29
0
        private static PathTool PathBasic(NinjaScriptBase owner, string tag, bool isAutoScale,
                                          int anchor1BarsAgo, DateTime anchor1Time, double anchor1Y, int anchor2BarsAgo, DateTime anchor2Time, double anchor2Y,
                                          int anchor3BarsAgo, DateTime anchor3Time, double anchor3Y, int anchor4BarsAgo, DateTime anchor4Time, double anchor4Y,
                                          int anchor5BarsAgo, DateTime anchor5Time, double anchor5Y)
        {
            List <ChartAnchor> chartAnchors = new List <ChartAnchor>();

            chartAnchors.Add(DrawingTool.CreateChartAnchor(owner, anchor1BarsAgo, anchor1Time, anchor1Y));
            chartAnchors.Add(DrawingTool.CreateChartAnchor(owner, anchor2BarsAgo, anchor2Time, anchor2Y));
            chartAnchors.Add(DrawingTool.CreateChartAnchor(owner, anchor3BarsAgo, anchor3Time, anchor3Y));

            if (anchor4BarsAgo != int.MinValue || anchor4Time != DateTime.MinValue)
            {
                chartAnchors.Add(DrawingTool.CreateChartAnchor(owner, anchor4BarsAgo, anchor4Time, anchor4Y));
            }

            if (anchor5BarsAgo != int.MinValue || anchor5Time != DateTime.MinValue)
            {
                chartAnchors.Add(DrawingTool.CreateChartAnchor(owner, anchor5BarsAgo, anchor5Time, anchor5Y));
            }

            return(PathCore(owner, tag, isAutoScale, chartAnchors, null, DashStyleHelper.Solid, false, string.Empty));
        }
コード例 #30
0
        private static GannFan GannFanCore(NinjaScriptBase owner, bool isAutoScale, string tag, int barsAgo, DateTime time, double y, bool isGlobal, string templateName)
        {
            if (owner == null)
            {
                throw new ArgumentException("owner");
            }
            if (time == Core.Globals.MinDate && barsAgo == int.MinValue)
            {
                throw new ArgumentException("bad start/end date/time");
            }

            if (string.IsNullOrWhiteSpace(tag))
            {
                throw new ArgumentException("tag cant be null or empty");
            }

            if (isGlobal && tag[0] != '@')
            {
                tag = "@" + tag;
            }

            GannFan gannFan = DrawingTool.GetByTagOrNew(owner, typeof(GannFan), tag, templateName) as GannFan;

            if (gannFan == null)
            {
                return(null);
            }

            DrawingTool.SetDrawingToolCommonValues(gannFan, tag, isAutoScale, owner, isGlobal);

            ChartAnchor anchor = DrawingTool.CreateChartAnchor(owner, barsAgo, time, y);

            anchor.CopyDataValues(gannFan.Anchor);

            gannFan.SetState(State.Active);
            return(gannFan);
        }