Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to draw a line using the PlotStyle from a Plot?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #46
    Code:
    ​
    #regionUsing declarations
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Xml.Serialization;
    using NinjaTrader.Cbi;
    using NinjaTrader.Gui;
    using NinjaTrader.Gui.Chart;
    using NinjaTrader.Gui.SuperDom;
    using NinjaTrader.Gui.Tools;
    using NinjaTrader.Data;
    using NinjaTrader.NinjaScript;
    using NinjaTrader.Core.FloatingPoint;
    using NinjaTrader.NinjaScript.DrawingTools;
    
    
    using SharpDX;
    using SharpDX.Direct2D1;
    //using SharpDX.DirectWrite;
    #endregion
    
    //This namespace holds Indicators in this folder and is required. Do not change it.
    namespace NinjaTrader.NinjaScript.Indicators
    {
    public class _OnRenderPlot : Indicator
    {
    private int cBar, cBar1;
    private double cHigh;
    
    // Defines the Series object
    private Series<double> myDoubleSeries;
    
    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = @"Enter the description for your new custom Indicator here.";
    Name = "_OnRenderPlot";
    Calculate = Calculate.OnEachTick;
    IsOverlay = true;
    DisplayInDataBox = true;
    DrawOnPricePanel = true;
    DrawHorizontalGridLines = true;
    DrawVerticalGridLines = true;
    PaintPriceMarkers = true;
    ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
    //Disable this property if your indicator requires custom values that cumulate with each new market data event.
    //See Help Guide for additional information.
    IsSuspendedWhileInactive = true;
    
    // Adds a blue Dash-Line style plot with 5pixel width and 70% opacity
    AddPlot(new Stroke(Brushes.Cyan, DashStyleHelper.Dash, 5, 70), PlotStyle.Hash, "MyPlot1");
    }
    else if (State == State.Configure)
    {
    }
    
    else if (State == State.DataLoaded)
    {
    myDoubleSeries = new Series<double>(this);
    }
    }
    
    protected override void OnBarUpdate()
    {
    if (CurrentBar <21) return;
    
    if (Open[0] < Close[0])
    {
    cBar = CurrentBar;
    cHigh = High[0];
    MyPlot1[0] = cHigh;
    
    //myDoubleSeries[0] = cHigh;
    }
    else
    {
    //MyPlot1[0] = double.NaN;
    }
    
    if ((CurrentBar - cBar) < 4)
    {
    cBar1 = CurrentBar;
    MyPlot1[0] = cHigh;
    
    // Print(" ");
    // Print("cBar1 " + cBar1 + " " + Time[0]);
    
    myDoubleSeries[0] = cHigh;
    }
    
    }
    
    protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
    {
    
    base.OnRender(chartControl, chartScale);
    
    SharpDX.Direct2D1.StrokeStyleProperties ssPropsWick = new SharpDX.Direct2D1.StrokeStyleProperties();
    ssPropsWick.DashStyle = DashStyleSolidLine;
    SharpDX.Direct2D1.StrokeStyle solidLine = new SharpDX.Direct2D1.StrokeStyle(RenderTarget.Factory , ssPropsWick);
    
    SharpDX.Direct2D1.AntialiasMode oldAntialiasMode = RenderTarget.AntialiasMode;
    RenderTarget.AntialiasMode = SharpDX.Direct2D1.AntialiasMode.PerPrimitive;
    
    Vector2 point0 = new Vector2();
    Vector2 point1 = new Vector2();
    
    Vector2 point2 = new Vector2();
    Vector2 point3 = new Vector2();
    
    for (int barIndex = ChartBars.FromIndex; barIndex <= ChartBars.ToIndex; barIndex++)
    {
    
    double plotValue0 = 0, plotValue1 = 0;
    float valY0, xHeight0, x0, barWidth0, xWidth0,
    valY1, xHeight1, x1, barWidth1, xWidth1;
    
    plotValue0 = myDoubleSeries.GetValueAt(barIndex);
    valY0 = chartScale.GetYByValue(plotValue0);
    
    Print(" ");
    Print("plotValue0 " + plotValue0);
    
    x0 = chartControl.GetXByBarIndex(ChartBars, barIndex);
    barWidth0 = (float)chartControl.BarWidth;
    
    point0.X = x0 - barWidth0;
    point0.Y = valY0;
    point1.X = x0 + barWidth0;
    point1.Y = valY0;
    
    xHeight0 = 10.0f;
    xWidth0 = (point1.X - point0.X);
    
    bool Cond0 = ( plotValue1 != double.NaN && plotValue0 != double.NaN
    && ( plotValue1 != plotValue0 ) || (plotValue1 == plotValue0 ));
    
    if ( Cond0 )
    {
    RenderTarget.DrawLine(point0, point1, Plots[0].BrushDX, Plots[0].Width, solidLine);
    }
    
    
    plotValue1 = myDoubleSeries.GetValueAt(barIndex-1);
    valY1 = chartScale.GetYByValue(plotValue1);
    
    Print(" ");
    Print("plotValue1 " + plotValue1);
    
    x1 = chartControl.GetXByBarIndex(ChartBars, barIndex-1);
    
    point2.X = x1 + barWidth0;
    point2.Y = valY1;
    point3.X = x0 - barWidth0;
    point3.Y = valY1;
    
    xHeight1 = 10.0f;
    xWidth1 = (point3.X - point2.X);
    
    bool Cond1 = ( plotValue1 != double.NaN && plotValue0 != double.NaN
    && plotValue1 == plotValue0 && !( plotValue1 != plotValue0 ));
    
    if ( Cond1 )
    {
    RenderTarget.DrawLine(point2, point3, Plots[0].BrushDX, Plots[0].Width, solidLine);
    }
    }
    
    RenderTarget.AntialiasMode = oldAntialiasMode;
    solidLine.Dispose();
    }
    
    #region Properties
    
    [Browsable(false)]
    [XmlIgnore]
    public Series<double> MyPlot1
    {
    get { return Values[0]; }
    }
    
    [NinjaScriptProperty]
    [Display(Name="DashStyle Solid Line", Description="DashStyle Solid Line.", Order=0, GroupName="Plots Lines")]
    public SharpDX.Direct2D1.DashStyle DashStyleSolidLine
    { get; set; }
    
    #endregion
    }
    }
    
    #region NinjaScript generated code. Neither change nor remove.
    
    namespace NinjaTrader.NinjaScript.Indicators
    {
    public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
    {
    private _OnRenderPlot[] cache_OnRenderPlot;
    public _OnRenderPlot _OnRenderPlot(SharpDX.Direct2D1.DashStyle dashStyleSolidLine)
    {
    return _OnRenderPlot(Input, dashStyleSolidLine);
    }
    
    public _OnRenderPlot _OnRenderPlot(ISeries<double> input, SharpDX.Direct2D1.DashStyle dashStyleSolidLine)
    {
    if (cache_OnRenderPlot != null)
    for (int idx = 0; idx < cache_OnRenderPlot.Length; idx++)
    if (cache_OnRenderPlot[idx] != null && cache_OnRenderPlot[idx].DashStyleSolidLine == dashStyleSolidLine && cache_OnRenderPlot[idx].EqualsInput(input))
    return cache_OnRenderPlot[idx];
    return CacheIndicator<_OnRenderPlot>(new _OnRenderPlot(){ DashStyleSolidLine = dashStyleSolidLine }, input, ref cache_OnRenderPlot);
    }
    }
    }
    
    namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
    {
    public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase
    {
    public Indicators._OnRenderPlot _OnRenderPlot(SharpDX.Direct2D1.DashStyle dashStyleSolidLine)
    {
    return indicator._OnRenderPlot(Input, dashStyleSolidLine);
    }
    
    public Indicators._OnRenderPlot _OnRenderPlot(ISeries<double> input , SharpDX.Direct2D1.DashStyle dashStyleSolidLine)
    {
    return indicator._OnRenderPlot(input, dashStyleSolidLine);
    }
    }
    }
    
    namespace NinjaTrader.NinjaScript.Strategies
    {
    public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase
    {
    public Indicators._OnRenderPlot _OnRenderPlot(SharpDX.Direct2D1.DashStyle dashStyleSolidLine)
    {
    return indicator._OnRenderPlot(Input, dashStyleSolidLine);
    }
    
    public Indicators._OnRenderPlot _OnRenderPlot(ISeries<double> input , SharpDX.Direct2D1.DashStyle dashStyleSolidLine)
    {
    return indicator._OnRenderPlot(input, dashStyleSolidLine);
    }
    }
    }
    
    #endregion
    Last edited by PaulMohn; 08-15-2024, 01:11 PM.

    Comment


      #47
      Hello PaulMohn,

      Below is a link to a support article on how to write an informative print that includes the time of the bar so we know what bar the print output is for.


      With the output, which value is incorrect in relation to the bar on the chart?
      Chelsea B.NinjaTrader Customer Service

      Comment


        #48
        The time is not printed correctly. Why? I'm using Simulated data feed.

        Print(" ");
        Print("plotValue0 " + plotValue0 + " " + Time[0]);​
        Print(" ");
        Print("plotValue1 " + plotValue1 + " " + Time[0]);​



        plotValue0 19576.75 31/07/2024 00:00:00

        plotValue1 19576 31/07/2024 00:00:00

        plotValue0 19576.75 31/07/2024 00:00:00

        plotValue1 19576.75 31/07/2024 00:00:00

        plotValue0 19576.75 31/07/2024 00:00:00

        plotValue1 19576.75 31/07/2024 00:00:00

        plotValue0 19576.75 31/07/2024 00:00:00

        plotValue1 19576.75 31/07/2024 00:00:00

        plotValue0 19177.75 31/07/2024 00:00:00

        plotValue1 19576.75 31/07/2024 00:00:00​
        Attached Files
        Last edited by PaulMohn; 08-15-2024, 01:27 PM.

        Comment


          #49
          Hello PaulMohn,

          As you are looping through a series from a non-data-driven method, to get the time of the bar you would use.

          <Bars>.GetTime(barIndex)

          Chelsea B.NinjaTrader Customer Service

          Comment


            #50
            Those among others are wrong
            plotValue0 19575 15/08/2024 15:10:18

            plotValue0 19576 15/08/2024 15:10:26​

            Click image for larger version

Name:	xxa.png
Views:	127
Size:	32.4 KB
ID:	1314333



            Code:
            ​
            #region Using declarations
            using System;
            using System.Collections.Generic;
            using System.ComponentModel;
            using System.ComponentModel.DataAnnotations;
            using System.Linq;
            using System.Text;
            using System.Threading.Tasks;
            using System.Windows;
            using System.Windows.Input;
            using System.Windows.Media;
            using System.Xml.Serialization;
            using NinjaTrader.Cbi;
            using NinjaTrader.Gui;
            using NinjaTrader.Gui.Chart;
            using NinjaTrader.Gui.SuperDom;
            using NinjaTrader.Gui.Tools;
            using NinjaTrader.Data;
            using NinjaTrader.NinjaScript;
            using NinjaTrader.Core.FloatingPoint;
            using NinjaTrader.NinjaScript.DrawingTools;
            
            
            using SharpDX;
            using SharpDX.Direct2D1;
            //using SharpDX.DirectWrite;
            #endregion
            
            //This namespace holds Indicators in this folder and is required. Do not change it.
            namespace NinjaTrader.NinjaScript.Indicators
            {
            public class _OnRenderPlot : Indicator
            {
            private int cBar, cBar1;
            private double cHigh;
            
            // Defines the Series object
            private Series<double> myDoubleSeries;
            
            protected override void OnStateChange()
            {
            if (State == State.SetDefaults)
            {
            Description = @"Enter the description for your new custom Indicator here.";
            Name = "_OnRenderPlot";
            Calculate = Calculate.OnEachTick;
            IsOverlay = true;
            DisplayInDataBox = true;
            DrawOnPricePanel = true;
            DrawHorizontalGridLines = true;
            DrawVerticalGridLines = true;
            PaintPriceMarkers = true;
            ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
            //Disable this property if your indicator requires custom values that cumulate with each new market data event.
            //See Help Guide for additional information.
            IsSuspendedWhileInactive = true;
            
            // Adds a blue Dash-Line style plot with 5pixel width and 70% opacity
            AddPlot(new Stroke(Brushes.Cyan, DashStyleHelper.Dash, 5, 70), PlotStyle.Hash, "MyPlot1");
            }
            else if (State == State.Configure)
            {
            }
            
            else if (State == State.DataLoaded)
            {
            myDoubleSeries = new Series<double>(this);
            }
            }
            
            protected override void OnBarUpdate()
            {
            if (CurrentBar <21) return;
            
            if (Open[0] < Close[0])
            {
            cBar = CurrentBar;
            cHigh = High[0];
            MyPlot1[0] = cHigh;
            
            //myDoubleSeries[0] = cHigh;
            }
            else
            {
            //MyPlot1[0] = double.NaN;
            }
            
            if ((CurrentBar - cBar) < 4)
            {
            cBar1 = CurrentBar;
            MyPlot1[0] = cHigh;
            
            // Print(" ");
            // Print("cBar1 " + cBar1 + " " + Time[0]);
            
            myDoubleSeries[0] = cHigh;
            }
            
            }
            
            protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
            {
            
            base.OnRender(chartControl, chartScale);
            
            SharpDX.Direct2D1.StrokeStyleProperties ssPropsWick = new SharpDX.Direct2D1.StrokeStyleProperties();
            ssPropsWick.DashStyle = DashStyleSolidLine;
            SharpDX.Direct2D1.StrokeStyle solidLine = new SharpDX.Direct2D1.StrokeStyle(RenderTarget.Factory , ssPropsWick);
            
            SharpDX.Direct2D1.AntialiasMode oldAntialiasMode = RenderTarget.AntialiasMode;
            RenderTarget.AntialiasMode = SharpDX.Direct2D1.AntialiasMode.PerPrimitive;
            
            Vector2 point0 = new Vector2();
            Vector2 point1 = new Vector2();
            
            Vector2 point2 = new Vector2();
            Vector2 point3 = new Vector2();
            
            for (int barIndex = ChartBars.FromIndex; barIndex <= ChartBars.ToIndex; barIndex++)
            {
            
            double plotValue0 = 0, plotValue1 = 0;
            float valY0, xHeight0, x0, barWidth0, xWidth0,
            valY1, xHeight1, x1, barWidth1, xWidth1;
            
            plotValue0 = myDoubleSeries.GetValueAt(barIndex);
            valY0 = chartScale.GetYByValue(plotValue0);
            
            // Print(" ");
            // Print("plotValue0 " + plotValue0 + " " + Time[0]);
            
            x0 = chartControl.GetXByBarIndex(ChartBars, barIndex);
            barWidth0 = (float)chartControl.BarWidth;
            
            point0.X = x0 - barWidth0;
            point0.Y = valY0;
            point1.X = x0 + barWidth0;
            point1.Y = valY0;
            
            xHeight0 = 10.0f;
            xWidth0 = (point1.X - point0.X);
            
            bool Cond0 = ( plotValue1 != double.NaN && plotValue0 != double.NaN
            && ( plotValue1 != plotValue0 ) || (plotValue1 == plotValue0 ));
            
            if ( Cond0 )
            {
            
            Print(" ");
            Print("plotValue0 " + plotValue0 + " " + Bars.GetTime(barIndex));
            RenderTarget.DrawLine(point0, point1, Plots[0].BrushDX, Plots[0].Width, solidLine);
            }
            
            
            plotValue1 = myDoubleSeries.GetValueAt(barIndex-1);
            valY1 = chartScale.GetYByValue(plotValue1);
            
            // Print(" ");
            // Print("plotValue1 " + plotValue1 + " " + Time[0]);
            
            x1 = chartControl.GetXByBarIndex(ChartBars, barIndex-1);
            
            point2.X = x1 + barWidth0;
            point2.Y = valY1;
            point3.X = x0 - barWidth0;
            point3.Y = valY1;
            
            xHeight1 = 10.0f;
            xWidth1 = (point3.X - point2.X);
            
            bool Cond1 = ( plotValue1 != double.NaN && plotValue0 != double.NaN
            && plotValue1 == plotValue0 && !( plotValue1 != plotValue0 ));
            
            if ( Cond1 )
            {
            
            Print(" ");
            Print("plotValue1 " + plotValue1 + " " + Bars.GetTime(barIndex));
            RenderTarget.DrawLine(point2, point3, Plots[0].BrushDX, Plots[0].Width, solidLine);
            }
            }
            
            RenderTarget.AntialiasMode = oldAntialiasMode;
            solidLine.Dispose();
            }
            
            [HASHTAG="t3322"]region[/HASHTAG] Properties
            
            [Browsable(false)]
            [XmlIgnore]
            public Series<double> MyPlot1
            {
            get { return Values[0]; }
            }
            
            [NinjaScriptProperty]
            [Display(Name="DashStyle Solid Line", Description="DashStyle Solid Line.", Order=0, GroupName="Plots Lines")]
            public SharpDX.Direct2D1.DashStyle DashStyleSolidLine
            { get; set; }
            
            #endregion
            }
            }
            
            [HASHTAG="t3322"]region[/HASHTAG] NinjaScript generated code. Neither change nor remove.
            
            namespace NinjaTrader.NinjaScript.Indicators
            {
            public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
            {
            private _OnRenderPlot[] cache_OnRenderPlot;
            public _OnRenderPlot _OnRenderPlot(SharpDX.Direct2D1.DashStyle dashStyleSolidLine)
            {
            return _OnRenderPlot(Input, dashStyleSolidLine);
            }
            
            public _OnRenderPlot _OnRenderPlot(ISeries<double> input, SharpDX.Direct2D1.DashStyle dashStyleSolidLine)
            {
            if (cache_OnRenderPlot != null)
            for (int idx = 0; idx < cache_OnRenderPlot.Length; idx++)
            if (cache_OnRenderPlot[idx] != null && cache_OnRenderPlot[idx].DashStyleSolidLine == dashStyleSolidLine && cache_OnRenderPlot[idx].EqualsInput(input))
            return cache_OnRenderPlot[idx];
            return CacheIndicator<_OnRenderPlot>(new _OnRenderPlot(){ DashStyleSolidLine = dashStyleSolidLine }, input, ref cache_OnRenderPlot);
            }
            }
            }
            
            namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
            {
            public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase
            {
            public Indicators._OnRenderPlot _OnRenderPlot(SharpDX.Direct2D1.DashStyle dashStyleSolidLine)
            {
            return indicator._OnRenderPlot(Input, dashStyleSolidLine);
            }
            
            public Indicators._OnRenderPlot _OnRenderPlot(ISeries<double> input , SharpDX.Direct2D1.DashStyle dashStyleSolidLine)
            {
            return indicator._OnRenderPlot(input, dashStyleSolidLine);
            }
            }
            }
            
            namespace NinjaTrader.NinjaScript.Strategies
            {
            public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase
            {
            public Indicators._OnRenderPlot _OnRenderPlot(SharpDX.Direct2D1.DashStyle dashStyleSolidLine)
            {
            return indicator._OnRenderPlot(Input, dashStyleSolidLine);
            }
            
            public Indicators._OnRenderPlot _OnRenderPlot(ISeries<double> input , SharpDX.Direct2D1.DashStyle dashStyleSolidLine)
            {
            return indicator._OnRenderPlot(input, dashStyleSolidLine);
            }
            }
            }
            
            #endregion
            Last edited by PaulMohn; 08-15-2024, 01:51 PM.

            Comment


              #51
              Hello PaulMohn,

              This would indicate the values you are saving to the series are incorrect.

              Try printing the values one line before they are assigned to the myDoubleSeries series.

              Is the calculated value what you expect?
              On a specific bar where the value is not what you expect, what is the value that was assigned to the series and what value are you expecting?
              Chelsea B.NinjaTrader Customer Service

              Comment


                #52
                I expect no plotting on these wrong timestamps/values.
                At 15:10:18 it returns plotValue0b 19575​ and plotValue0a 0.

                plotValue1a 0 15/08/2024 15:09:06

                plotValue0a 0 15/08/2024 15:10:18

                plotValue0b 19591 15/08/2024 15:10:18

                plotValue1a 0 15/08/2024 15:10:18

                plotValue1b 19591 15/08/2024 15:10:18

                plotValue0a 0 15/08/2024 15:10:18

                plotValue0b 19591 15/08/2024 15:10:18

                plotValue1a 0 15/08/2024 15:10:18

                plotValue1b 19591 15/08/2024 15:10:18

                plotValue0a 0 15/08/2024 15:10:18

                plotValue0b 19591 15/08/2024 15:10:18

                plotValue1a 0 15/08/2024 15:10:18

                plotValue1b 19591 15/08/2024 15:10:18

                plotValue0a 0 15/08/2024 15:10:18

                plotValue0b 19575 15/08/2024 15:10:18

                plotValue1a 0 15/08/2024 15:10:18

                plotValue0a 0 15/08/2024 15:10:26​




                Code:
                ​
                #region Using declarations
                using System;
                using System.Collections.Generic;
                using System.ComponentModel;
                using System.ComponentModel.DataAnnotations;
                using System.Linq;
                using System.Text;
                using System.Threading.Tasks;
                using System.Windows;
                using System.Windows.Input;
                using System.Windows.Media;
                using System.Xml.Serialization;
                using NinjaTrader.Cbi;
                using NinjaTrader.Gui;
                using NinjaTrader.Gui.Chart;
                using NinjaTrader.Gui.SuperDom;
                using NinjaTrader.Gui.Tools;
                using NinjaTrader.Data;
                using NinjaTrader.NinjaScript;
                using NinjaTrader.Core.FloatingPoint;
                using NinjaTrader.NinjaScript.DrawingTools;
                
                
                using SharpDX;
                using SharpDX.Direct2D1;
                //using SharpDX.DirectWrite;
                #endregion
                
                //This namespace holds Indicators in this folder and is required. Do not change it.
                namespace NinjaTrader.NinjaScript.Indicators
                {
                public class _OnRenderPlot : Indicator
                {
                private int cBar, cBar1;
                private double cHigh;
                
                // Defines the Series object
                private Series<double> myDoubleSeries;
                
                protected override void OnStateChange()
                {
                if (State == State.SetDefaults)
                {
                Description = @"Enter the description for your new custom Indicator here.";
                Name = "_OnRenderPlot";
                Calculate = Calculate.OnEachTick;
                IsOverlay = true;
                DisplayInDataBox = true;
                DrawOnPricePanel = true;
                DrawHorizontalGridLines = true;
                DrawVerticalGridLines = true;
                PaintPriceMarkers = true;
                ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
                //Disable this property if your indicator requires custom values that cumulate with each new market data event.
                //See Help Guide for additional information.
                IsSuspendedWhileInactive = true;
                
                // Adds a blue Dash-Line style plot with 5pixel width and 70% opacity
                AddPlot(new Stroke(Brushes.Cyan, DashStyleHelper.Dash, 5, 70), PlotStyle.Hash, "MyPlot1");
                }
                else if (State == State.Configure)
                {
                }
                
                else if (State == State.DataLoaded)
                {
                myDoubleSeries = new Series<double>(this);
                }
                }
                
                protected override void OnBarUpdate()
                {
                if (CurrentBar <21) return;
                
                if (Open[0] < Close[0])
                {
                cBar = CurrentBar;
                cHigh = High[0];
                MyPlot1[0] = cHigh;
                
                //myDoubleSeries[0] = cHigh;
                }
                else
                {
                //MyPlot1[0] = double.NaN;
                }
                
                if ((CurrentBar - cBar) < 4)
                {
                cBar1 = CurrentBar;
                MyPlot1[0] = cHigh;
                
                // Print(" ");
                // Print("cBar1 " + cBar1 + " " + Time[0]);
                
                myDoubleSeries[0] = cHigh;
                }
                
                }
                
                protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
                {
                
                base.OnRender(chartControl, chartScale);
                
                SharpDX.Direct2D1.StrokeStyleProperties ssPropsWick = new SharpDX.Direct2D1.StrokeStyleProperties();
                ssPropsWick.DashStyle = DashStyleSolidLine;
                SharpDX.Direct2D1.StrokeStyle solidLine = new SharpDX.Direct2D1.StrokeStyle(RenderTarget.Factory , ssPropsWick);
                
                SharpDX.Direct2D1.AntialiasMode oldAntialiasMode = RenderTarget.AntialiasMode;
                RenderTarget.AntialiasMode = SharpDX.Direct2D1.AntialiasMode.PerPrimitive;
                
                Vector2 point0 = new Vector2();
                Vector2 point1 = new Vector2();
                
                Vector2 point2 = new Vector2();
                Vector2 point3 = new Vector2();
                
                for (int barIndex = ChartBars.FromIndex; barIndex <= ChartBars.ToIndex; barIndex++)
                {
                
                double plotValue0 = 0, plotValue1 = 0;
                float valY0, xHeight0, x0, barWidth0, xWidth0,
                valY1, xHeight1, x1, barWidth1, xWidth1;
                Print(" ");
                Print("plotValue0a " + plotValue0 + " " + Bars.GetTime(barIndex));
                
                plotValue0 = myDoubleSeries.GetValueAt(barIndex);
                valY0 = chartScale.GetYByValue(plotValue0);
                
                // Print(" ");
                // Print("plotValue0 " + plotValue0 + " " + Time[0]);
                
                x0 = chartControl.GetXByBarIndex(ChartBars, barIndex);
                barWidth0 = (float)chartControl.BarWidth;
                
                point0.X = x0 - barWidth0;
                point0.Y = valY0;
                point1.X = x0 + barWidth0;
                point1.Y = valY0;
                
                xHeight0 = 10.0f;
                xWidth0 = (point1.X - point0.X);
                
                bool Cond0 = ( plotValue1 != double.NaN && plotValue0 != double.NaN
                && ( plotValue1 != plotValue0 ) || (plotValue1 == plotValue0 ));
                
                if ( Cond0 )
                {
                
                Print(" ");
                Print("plotValue0b " + plotValue0 + " " + Bars.GetTime(barIndex));
                RenderTarget.DrawLine(point0, point1, Plots[0].BrushDX, Plots[0].Width, solidLine);
                }
                
                Print(" ");
                Print("plotValue1a " + plotValue1 + " " + Bars.GetTime(barIndex));
                
                
                plotValue1 = myDoubleSeries.GetValueAt(barIndex-1);
                valY1 = chartScale.GetYByValue(plotValue1);
                
                // Print(" ");
                // Print("plotValue1 " + plotValue1 + " " + Time[0]);
                
                x1 = chartControl.GetXByBarIndex(ChartBars, barIndex-1);
                
                point2.X = x1 + barWidth0;
                point2.Y = valY1;
                point3.X = x0 - barWidth0;
                point3.Y = valY1;
                
                xHeight1 = 10.0f;
                xWidth1 = (point3.X - point2.X);
                
                bool Cond1 = ( plotValue1 != double.NaN && plotValue0 != double.NaN
                && plotValue1 == plotValue0 && !( plotValue1 != plotValue0 ));
                
                if ( Cond1 )
                {
                
                Print(" ");
                Print("plotValue1b " + plotValue1 + " " + Bars.GetTime(barIndex));
                RenderTarget.DrawLine(point2, point3, Plots[0].BrushDX, Plots[0].Width, solidLine);
                }
                }
                
                RenderTarget.AntialiasMode = oldAntialiasMode;
                solidLine.Dispose();
                }
                
                #region Properties
                
                [Browsable(false)]
                [XmlIgnore]
                public Series<double> MyPlot1
                {
                get { return Values[0]; }
                }
                
                [NinjaScriptProperty]
                [Display(Name="DashStyle Solid Line", Description="DashStyle Solid Line.", Order=0, GroupName="Plots Lines")]
                public SharpDX.Direct2D1.DashStyle DashStyleSolidLine
                { get; set; }
                
                #endregion
                }
                }
                
                #region NinjaScript generated code. Neither change nor remove.
                
                namespace NinjaTrader.NinjaScript.Indicators
                {
                public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
                {
                private _OnRenderPlot[] cache_OnRenderPlot;
                public _OnRenderPlot _OnRenderPlot(SharpDX.Direct2D1.DashStyle dashStyleSolidLine)
                {
                return _OnRenderPlot(Input, dashStyleSolidLine);
                }
                
                public _OnRenderPlot _OnRenderPlot(ISeries<double> input, SharpDX.Direct2D1.DashStyle dashStyleSolidLine)
                {
                if (cache_OnRenderPlot != null)
                for (int idx = 0; idx < cache_OnRenderPlot.Length; idx++)
                if (cache_OnRenderPlot[idx] != null && cache_OnRenderPlot[idx].DashStyleSolidLine == dashStyleSolidLine && cache_OnRenderPlot[idx].EqualsInput(input))
                return cache_OnRenderPlot[idx];
                return CacheIndicator<_OnRenderPlot>(new _OnRenderPlot(){ DashStyleSolidLine = dashStyleSolidLine }, input, ref cache_OnRenderPlot);
                }
                }
                }
                
                namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
                {
                public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase
                {
                public Indicators._OnRenderPlot _OnRenderPlot(SharpDX.Direct2D1.DashStyle dashStyleSolidLine)
                {
                return indicator._OnRenderPlot(Input, dashStyleSolidLine);
                }
                
                public Indicators._OnRenderPlot _OnRenderPlot(ISeries<double> input , SharpDX.Direct2D1.DashStyle dashStyleSolidLine)
                {
                return indicator._OnRenderPlot(input, dashStyleSolidLine);
                }
                }
                }
                
                namespace NinjaTrader.NinjaScript.Strategies
                {
                public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase
                {
                public Indicators._OnRenderPlot _OnRenderPlot(SharpDX.Direct2D1.DashStyle dashStyleSolidLine)
                {
                return indicator._OnRenderPlot(Input, dashStyleSolidLine);
                }
                
                public Indicators._OnRenderPlot _OnRenderPlot(ISeries<double> input , SharpDX.Direct2D1.DashStyle dashStyleSolidLine)
                {
                return indicator._OnRenderPlot(input, dashStyleSolidLine);
                }
                }
                }
                
                #endregion
                Attached Files
                Last edited by PaulMohn; 08-15-2024, 02:21 PM.

                Comment


                  #53
                  Hello PaulMohn,

                  So at 15:10:18 you are expecting no value to be assigned to the myDoubleSeries in OnBarUpdate(), is this correct?

                  It seems a value is being assigned, so the condition to assign the value evaluated as true.

                  The condition that when true assigns the value is:

                  if ((CurrentBar - cBar) < 4)

                  Why are you expecting this condition to evaluate as false at 15:10:18?

                  Print the values in this condition. Which value is unexpected?
                  Chelsea B.NinjaTrader Customer Service

                  Comment


                    #54


                    if ((CurrentBar - cBar) < 4)
                    {
                    cBar1 = CurrentBar;
                    MyPlot1[0] = cHigh;

                    // Print(" ");
                    // Print("cBar1 " + cBar1 + " " + Time[0]);

                    myDoubleSeries[0] = cHigh;
                    }​

                    MyPlot1[0] = cHigh; does not plot at 15:10:18 while plotValue0b 19575 15/08/2024 15:10:18​ does.



                    https://forum.ninjatrader.com/fileda...3&d=1723751471

                    Why does the rendering differ from the plot it is meant to render?
                    Why 19575? which is not plotted on the plot.

                    It does not print cHigh or myDoubleSeries[0] past the first value:



                    if ((CurrentBar - cBar) < 4)
                    {
                    cBar1 = CurrentBar;
                    MyPlot1[0] = cHigh;

                    // Print(" ");
                    // Print("cBar1 " + cBar1 + " " + Time[0]);
                    Print(" ");
                    Print("cHigh " + cHigh + " " + Time[0]);
                    myDoubleSeries[0] = cHigh;
                    Print(" ");
                    Print("myDoubleSeries[0] " + myDoubleSeries[0] + " " + Time[0]);
                    }​


                    cHigh 19179.5 15/08/2024 17:02:26

                    myDoubleSeries[0] 19179.5 15/08/2024 17:02:26

                    plotValue0a 0 15/08/2024 15:00:32

                    plotValue0b 19587 15/08/2024 15:00:32

                    plotValue1a 0 15/08/2024 15:00:32

                    plotValue1b 19587 15/08/2024 15:00:32

                    plotValue0a 0 15/08/2024 15:00:37

                    plotValue0b 19587 15/08/2024 15:00:37

                    plotValue1a 0 15/08/2024 15:00:37

                    plotValue1b 19587 15/08/2024 15:00:37

                    plotValue0a 0 15/08/2024 15:00:46



                    Code:
                    ​
                    
                    #region Using declarations
                    using System;
                    using System.Collections.Generic;
                    using System.ComponentModel;
                    using System.ComponentModel.DataAnnotations;
                    using System.Linq;
                    using System.Text;
                    using System.Threading.Tasks;
                    using System.Windows;
                    using System.Windows.Input;
                    using System.Windows.Media;
                    using System.Xml.Serialization;
                    using NinjaTrader.Cbi;
                    using NinjaTrader.Gui;
                    using NinjaTrader.Gui.Chart;
                    using NinjaTrader.Gui.SuperDom;
                    using NinjaTrader.Gui.Tools;
                    using NinjaTrader.Data;
                    using NinjaTrader.NinjaScript;
                    using NinjaTrader.Core.FloatingPoint;
                    using NinjaTrader.NinjaScript.DrawingTools;
                    
                    
                    using SharpDX;
                    using SharpDX.Direct2D1;
                    //using SharpDX.DirectWrite;
                    #endregion
                    
                    //This namespace holds Indicators in this folder and is required. Do not change it.
                    namespace NinjaTrader.NinjaScript.Indicators
                    {
                    public class _OnRenderPlot : Indicator
                    {
                    private int cBar, cBar1;
                    private double cHigh;
                    
                    // Defines the Series object
                    private Series<double> myDoubleSeries;
                    
                    protected override void OnStateChange()
                    {
                    if (State == State.SetDefaults)
                    {
                    Description = @"Enter the description for your new custom Indicator here.";
                    Name = "_OnRenderPlot";
                    Calculate = Calculate.OnEachTick;
                    IsOverlay = true;
                    DisplayInDataBox = true;
                    DrawOnPricePanel = true;
                    DrawHorizontalGridLines = true;
                    DrawVerticalGridLines = true;
                    PaintPriceMarkers = true;
                    ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
                    //Disable this property if your indicator requires custom values that cumulate with each new market data event.
                    //See Help Guide for additional information.
                    IsSuspendedWhileInactive = true;
                    
                    // Adds a blue Dash-Line style plot with 5pixel width and 70% opacity
                    AddPlot(new Stroke(Brushes.Cyan, DashStyleHelper.Dash, 5, 70), PlotStyle.Hash, "MyPlot1");
                    }
                    else if (State == State.Configure)
                    {
                    }
                    
                    else if (State == State.DataLoaded)
                    {
                    myDoubleSeries = new Series<double>(this);
                    }
                    }
                    
                    protected override void OnBarUpdate()
                    {
                    if (CurrentBar <21) return;
                    
                    if (Open[0] < Close[0])
                    {
                    cBar = CurrentBar;
                    cHigh = High[0];
                    MyPlot1[0] = cHigh;
                    
                    //myDoubleSeries[0] = cHigh;
                    }
                    else
                    {
                    //MyPlot1[0] = double.NaN;
                    }
                    
                    if ((CurrentBar - cBar) < 4)
                    {
                    cBar1 = CurrentBar;
                    MyPlot1[0] = cHigh;
                    
                    // Print(" ");
                    // Print("cBar1 " + cBar1 + " " + Time[0]);
                    Print(" ");
                    Print("cHigh " + cHigh + " " + Time[0]);
                    myDoubleSeries[0] = cHigh;
                    Print(" ");
                    Print("myDoubleSeries[0] " + myDoubleSeries[0] + " " + Time[0]);
                    }
                    
                    }
                    
                    protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
                    {
                    
                    base.OnRender(chartControl, chartScale);
                    
                    SharpDX.Direct2D1.StrokeStyleProperties ssPropsWick = new SharpDX.Direct2D1.StrokeStyleProperties();
                    ssPropsWick.DashStyle = DashStyleSolidLine;
                    SharpDX.Direct2D1.StrokeStyle solidLine = new SharpDX.Direct2D1.StrokeStyle(RenderTarget.Factory , ssPropsWick);
                    
                    SharpDX.Direct2D1.AntialiasMode oldAntialiasMode = RenderTarget.AntialiasMode;
                    RenderTarget.AntialiasMode = SharpDX.Direct2D1.AntialiasMode.PerPrimitive;
                    
                    Vector2 point0 = new Vector2();
                    Vector2 point1 = new Vector2();
                    
                    Vector2 point2 = new Vector2();
                    Vector2 point3 = new Vector2();
                    
                    for (int barIndex = ChartBars.FromIndex; barIndex <= ChartBars.ToIndex; barIndex++)
                    {
                    
                    double plotValue0 = 0, plotValue1 = 0;
                    float valY0, xHeight0, x0, barWidth0, xWidth0,
                    valY1, xHeight1, x1, barWidth1, xWidth1;
                    Print(" ");
                    Print("plotValue0a " + plotValue0 + " " + Bars.GetTime(barIndex));
                    
                    plotValue0 = myDoubleSeries.GetValueAt(barIndex);
                    valY0 = chartScale.GetYByValue(plotValue0);
                    
                    // Print(" ");
                    // Print("plotValue0 " + plotValue0 + " " + Time[0]);
                    
                    x0 = chartControl.GetXByBarIndex(ChartBars, barIndex);
                    barWidth0 = (float)chartControl.BarWidth;
                    
                    point0.X = x0 - barWidth0;
                    point0.Y = valY0;
                    point1.X = x0 + barWidth0;
                    point1.Y = valY0;
                    
                    xHeight0 = 10.0f;
                    xWidth0 = (point1.X - point0.X);
                    
                    bool Cond0 = ( plotValue1 != double.NaN && plotValue0 != double.NaN
                    && ( plotValue1 != plotValue0 ) || (plotValue1 == plotValue0 ));
                    
                    if ( Cond0 )
                    {
                    
                    Print(" ");
                    Print("plotValue0b " + plotValue0 + " " + Bars.GetTime(barIndex));
                    RenderTarget.DrawLine(point0, point1, Plots[0].BrushDX, Plots[0].Width, solidLine);
                    }
                    
                    Print(" ");
                    Print("plotValue1a " + plotValue1 + " " + Bars.GetTime(barIndex));
                    
                    
                    plotValue1 = myDoubleSeries.GetValueAt(barIndex-1);
                    valY1 = chartScale.GetYByValue(plotValue1);
                    
                    // Print(" ");
                    // Print("plotValue1 " + plotValue1 + " " + Time[0]);
                    
                    x1 = chartControl.GetXByBarIndex(ChartBars, barIndex-1);
                    
                    point2.X = x1 + barWidth0;
                    point2.Y = valY1;
                    point3.X = x0 - barWidth0;
                    point3.Y = valY1;
                    
                    xHeight1 = 10.0f;
                    xWidth1 = (point3.X - point2.X);
                    
                    bool Cond1 = ( plotValue1 != double.NaN && plotValue0 != double.NaN
                    && plotValue1 == plotValue0 && !( plotValue1 != plotValue0 ));
                    
                    if ( Cond1 )
                    {
                    
                    Print(" ");
                    Print("plotValue1b " + plotValue1 + " " + Bars.GetTime(barIndex));
                    RenderTarget.DrawLine(point2, point3, Plots[0].BrushDX, Plots[0].Width, solidLine);
                    }
                    }
                    
                    RenderTarget.AntialiasMode = oldAntialiasMode;
                    solidLine.Dispose();
                    }
                    
                    #region Properties
                    
                    [Browsable(false)]
                    [XmlIgnore]
                    public Series<double> MyPlot1
                    {
                    get { return Values[0]; }
                    }
                    
                    [NinjaScriptProperty]
                    [Display(Name="DashStyle Solid Line", Description="DashStyle Solid Line.", Order=0, GroupName="Plots Lines")]
                    public SharpDX.Direct2D1.DashStyle DashStyleSolidLine
                    { get; set; }
                    
                    #endregion
                    }
                    }
                    
                    #region NinjaScript generated code. Neither change nor remove.
                    
                    namespace NinjaTrader.NinjaScript.Indicators
                    {
                    public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
                    {
                    private _OnRenderPlot[] cache_OnRenderPlot;
                    public _OnRenderPlot _OnRenderPlot(SharpDX.Direct2D1.DashStyle dashStyleSolidLine)
                    {
                    return _OnRenderPlot(Input, dashStyleSolidLine);
                    }
                    
                    public _OnRenderPlot _OnRenderPlot(ISeries<double> input, SharpDX.Direct2D1.DashStyle dashStyleSolidLine)
                    {
                    if (cache_OnRenderPlot != null)
                    for (int idx = 0; idx < cache_OnRenderPlot.Length; idx++)
                    if (cache_OnRenderPlot[idx] != null && cache_OnRenderPlot[idx].DashStyleSolidLine == dashStyleSolidLine && cache_OnRenderPlot[idx].EqualsInput(input))
                    return cache_OnRenderPlot[idx];
                    return CacheIndicator<_OnRenderPlot>(new _OnRenderPlot(){ DashStyleSolidLine = dashStyleSolidLine }, input, ref cache_OnRenderPlot);
                    }
                    }
                    }
                    
                    namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
                    {
                    public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase
                    {
                    public Indicators._OnRenderPlot _OnRenderPlot(SharpDX.Direct2D1.DashStyle dashStyleSolidLine)
                    {
                    return indicator._OnRenderPlot(Input, dashStyleSolidLine);
                    }
                    
                    public Indicators._OnRenderPlot _OnRenderPlot(ISeries<double> input , SharpDX.Direct2D1.DashStyle dashStyleSolidLine)
                    {
                    return indicator._OnRenderPlot(input, dashStyleSolidLine);
                    }
                    }
                    }
                    
                    namespace NinjaTrader.NinjaScript.Strategies
                    {
                    public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase
                    {
                    public Indicators._OnRenderPlot _OnRenderPlot(SharpDX.Direct2D1.DashStyle dashStyleSolidLine)
                    {
                    return indicator._OnRenderPlot(Input, dashStyleSolidLine);
                    }
                    
                    public Indicators._OnRenderPlot _OnRenderPlot(ISeries<double> input , SharpDX.Direct2D1.DashStyle dashStyleSolidLine)
                    {
                    return indicator._OnRenderPlot(input, dashStyleSolidLine);
                    }
                    }
                    }
                    
                    #endregion
                    Attached Files
                    Last edited by PaulMohn; 08-15-2024, 03:13 PM.

                    Comment


                      #55
                      Erratic historical rendred plot

                      Click image for larger version  Name:	xxb.png Views:	0 Size:	34.6 KB ID:	1314365



                      Click image for larger version

Name:	xxc.png
Views:	64
Size:	43.5 KB
ID:	1314368
                      Attached Files
                      Last edited by PaulMohn; 08-15-2024, 03:31 PM.

                      Comment


                        #56
                        Hello PaulMohn,

                        If the MyPlot1 series has the correct values for the object you are rendering, why are you adding myDoubleSeries and duplicating the information?

                        Why not just use MyPlot1 if this already has the values you want?


                        That said, you are printing a label of plotValue0a with the value of plotValue0 in OnRender() which is assigned a value of 0.

                        double plotValue0 = 0, plotValue1 = 0;
                        Print("plotValue0a " + plotValue0 + " " + Bars.GetTime(barIndex));

                        This will always be 0.

                        Then you are assigning the variable a value and printing with the label plotValue0b.

                        plotValue0 = myDoubleSeries.GetValueAt(barIndex);

                        if ( Cond0 )
                        {
                        Print("plotValue0b " + plotValue0 + " " + Bars.GetTime(barIndex));

                        At this point it will have an assigned value.


                        ​There are also places in OnBarUpdate() where MyPlot1 is assigned a value and myDoubleSeries is not.
                        There may be other differences.

                        Temporarily, comment out the prints in OnRender() to focus on the values being assigned from OnBarUpdate().
                        Print the values from MyPlot1[0] and myDoubleSeries[0].
                        Print the values of MyPlot1.IsValidDataPointAt(CurrentBar) and myDoubleSeries.IsValidDataPointAt(CurrentBar).​
                        Chelsea B.NinjaTrader Customer Service

                        Comment


                          #57
                          I got this error
                          Time Category Message
                          16/08/2024 08:53:39 Default Indicator '_OnRenderPlot': Error on calling 'OnBarUpdate' method on bar 21: .IsValidDataPoint cannot be used on a series running with MaximumBarsLookBack.TwoHundredFiftySix.
                          From this version:


                          Code:
                          ​
                          #region Using declarations
                          using System;
                          using System.Collections.Generic;
                          using System.ComponentModel;
                          using System.ComponentModel.DataAnnotations;
                          using System.Linq;
                          using System.Text;
                          using System.Threading.Tasks;
                          using System.Windows;
                          using System.Windows.Input;
                          using System.Windows.Media;
                          using System.Xml.Serialization;
                          using NinjaTrader.Cbi;
                          using NinjaTrader.Gui;
                          using NinjaTrader.Gui.Chart;
                          using NinjaTrader.Gui.SuperDom;
                          using NinjaTrader.Gui.Tools;
                          using NinjaTrader.Data;
                          using NinjaTrader.NinjaScript;
                          using NinjaTrader.Core.FloatingPoint;
                          using NinjaTrader.NinjaScript.DrawingTools;
                          
                          
                          using SharpDX;
                          using SharpDX.Direct2D1;
                          //using SharpDX.DirectWrite;
                          #endregion
                          
                          //This namespace holds Indicators in this folder and is required. Do not change it.
                          namespace NinjaTrader.NinjaScript.Indicators
                          {
                          public class _OnRenderPlot : Indicator
                          {
                          private int cBar, cBar1;
                          private double cHigh;
                          
                          // Defines the Series object
                          private Series<double> myDoubleSeries;
                          
                          protected override void OnStateChange()
                          {
                          if (State == State.SetDefaults)
                          {
                          Description = @"Enter the description for your new custom Indicator here.";
                          Name = "_OnRenderPlot";
                          Calculate = Calculate.OnEachTick;
                          IsOverlay = true;
                          DisplayInDataBox = true;
                          DrawOnPricePanel = true;
                          DrawHorizontalGridLines = true;
                          DrawVerticalGridLines = true;
                          PaintPriceMarkers = true;
                          ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
                          //Disable this property if your indicator requires custom values that cumulate with each new market data event.
                          //See Help Guide for additional information.
                          IsSuspendedWhileInactive = true;
                          
                          // Adds a blue Dash-Line style plot with 5pixel width and 70% opacity
                          AddPlot(new Stroke(Brushes.Cyan, DashStyleHelper.Dash, 5, 70), PlotStyle.Hash, "MyPlot1");
                          }
                          else if (State == State.Configure)
                          {
                          }
                          
                          else if (State == State.DataLoaded)
                          {
                          myDoubleSeries = new Series<double>(this);
                          }
                          }
                          
                          protected override void OnBarUpdate()
                          {
                          if (CurrentBar <21) return;
                          
                          if (Open[0] < Close[0])
                          {
                          cBar = CurrentBar;
                          cHigh = High[0];
                          MyPlot1[0] = cHigh;
                          
                          //myDoubleSeries[0] = cHigh;
                          }
                          else
                          {
                          //MyPlot1[0] = double.NaN;
                          }
                          
                          if ((CurrentBar - cBar) < 4)
                          {
                          cBar1 = CurrentBar;
                          MyPlot1[0] = cHigh;
                          
                          // Print(" ");
                          // Print("cBar1 " + cBar1 + " " + Time[0]);
                          
                          // Print(" ");
                          // Print("cHigh " + cHigh + " " + Time[0]);
                          
                          myDoubleSeries[0] = cHigh;
                          
                          Print(" ");
                          Print("MyPlot1[0] " + MyPlot1[0] + " " + Time[0]);
                          Print("myDoubleSeries[0] " + myDoubleSeries[0] + " " + Time[0]);
                          Print("MyPlot1IsValid " + MyPlot1.IsValidDataPointAt(CurrentBar) + " " + Time[0]);
                          Print("myDoubleSeriesIsValid " + myDoubleSeries.IsValidDataPointAt(CurrentBar) + " " + Time[0]);
                          
                          // Print(" ");
                          // Print("myDoubleSeries[0] " + myDoubleSeries[0] + " " + Time[0]);
                          }
                          
                          }
                          
                          protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
                          {
                          
                          base.OnRender(chartControl, chartScale);
                          
                          SharpDX.Direct2D1.StrokeStyleProperties ssPropsWick = new SharpDX.Direct2D1.StrokeStyleProperties();
                          ssPropsWick.DashStyle = DashStyleSolidLine;
                          SharpDX.Direct2D1.StrokeStyle solidLine = new SharpDX.Direct2D1.StrokeStyle(RenderTarget.Factory , ssPropsWick);
                          
                          SharpDX.Direct2D1.AntialiasMode oldAntialiasMode = RenderTarget.AntialiasMode;
                          RenderTarget.AntialiasMode = SharpDX.Direct2D1.AntialiasMode.PerPrimitive;
                          
                          Vector2 point0 = new Vector2();
                          Vector2 point1 = new Vector2();
                          
                          Vector2 point2 = new Vector2();
                          Vector2 point3 = new Vector2();
                          
                          for (int barIndex = ChartBars.FromIndex; barIndex <= ChartBars.ToIndex; barIndex++)
                          {
                          
                          double plotValue0 = 0, plotValue1 = 0;
                          float valY0, xHeight0, x0, barWidth0, xWidth0,
                          valY1, xHeight1, x1, barWidth1, xWidth1;
                          // Print(" ");
                          // Print("plotValue0a " + plotValue0 + " " + Bars.GetTime(barIndex));
                          
                          plotValue0 = myDoubleSeries.GetValueAt(barIndex);
                          valY0 = chartScale.GetYByValue(plotValue0);
                          
                          // Print(" ");
                          // Print("plotValue0 " + plotValue0 + " " + Time[0]);
                          
                          x0 = chartControl.GetXByBarIndex(ChartBars, barIndex);
                          barWidth0 = (float)chartControl.BarWidth;
                          
                          point0.X = x0 - barWidth0;
                          point0.Y = valY0;
                          point1.X = x0 + barWidth0;
                          point1.Y = valY0;
                          
                          xHeight0 = 10.0f;
                          xWidth0 = (point1.X - point0.X);
                          
                          bool Cond0 = ( plotValue1 != double.NaN && plotValue0 != double.NaN
                          && ( plotValue1 != plotValue0 ) || (plotValue1 == plotValue0 ));
                          
                          if ( Cond0 )
                          {
                          
                          // Print(" ");
                          // Print("plotValue0b " + plotValue0 + " " + Bars.GetTime(barIndex));
                          RenderTarget.DrawLine(point0, point1, Plots[0].BrushDX, Plots[0].Width, solidLine);
                          }
                          
                          // Print(" ");
                          // Print("plotValue1a " + plotValue1 + " " + Bars.GetTime(barIndex));
                          
                          
                          plotValue1 = myDoubleSeries.GetValueAt(barIndex-1);
                          valY1 = chartScale.GetYByValue(plotValue1);
                          
                          // Print(" ");
                          // Print("plotValue1 " + plotValue1 + " " + Time[0]);
                          
                          x1 = chartControl.GetXByBarIndex(ChartBars, barIndex-1);
                          
                          point2.X = x1 + barWidth0;
                          point2.Y = valY1;
                          point3.X = x0 - barWidth0;
                          point3.Y = valY1;
                          
                          xHeight1 = 10.0f;
                          xWidth1 = (point3.X - point2.X);
                          
                          bool Cond1 = ( plotValue1 != double.NaN && plotValue0 != double.NaN
                          && plotValue1 == plotValue0 && !( plotValue1 != plotValue0 ));
                          
                          if ( Cond1 )
                          {
                          
                          // Print(" ");
                          // Print("plotValue1b " + plotValue1 + " " + Bars.GetTime(barIndex));
                          RenderTarget.DrawLine(point2, point3, Plots[0].BrushDX, Plots[0].Width, solidLine);
                          }
                          }
                          
                          RenderTarget.AntialiasMode = oldAntialiasMode;
                          solidLine.Dispose();
                          }
                          
                          #region Properties
                          
                          [Browsable(false)]
                          [XmlIgnore]
                          public Series<double> MyPlot1
                          {
                          get { return Values[0]; }
                          }
                          
                          [NinjaScriptProperty]
                          [Display(Name="DashStyle Solid Line", Description="DashStyle Solid Line.", Order=0, GroupName="Plots Lines")]
                          public SharpDX.Direct2D1.DashStyle DashStyleSolidLine
                          { get; set; }
                          
                          #endregion
                          }
                          }
                          
                          #region NinjaScript generated code. Neither change nor remove.
                          
                          namespace NinjaTrader.NinjaScript.Indicators
                          {
                          public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
                          {
                          private _OnRenderPlot[] cache_OnRenderPlot;
                          public _OnRenderPlot _OnRenderPlot(SharpDX.Direct2D1.DashStyle dashStyleSolidLine)
                          {
                          return _OnRenderPlot(Input, dashStyleSolidLine);
                          }
                          
                          public _OnRenderPlot _OnRenderPlot(ISeries<double> input, SharpDX.Direct2D1.DashStyle dashStyleSolidLine)
                          {
                          if (cache_OnRenderPlot != null)
                          for (int idx = 0; idx < cache_OnRenderPlot.Length; idx++)
                          if (cache_OnRenderPlot[idx] != null && cache_OnRenderPlot[idx].DashStyleSolidLine == dashStyleSolidLine && cache_OnRenderPlot[idx].EqualsInput(input))
                          return cache_OnRenderPlot[idx];
                          return CacheIndicator<_OnRenderPlot>(new _OnRenderPlot(){ DashStyleSolidLine = dashStyleSolidLine }, input, ref cache_OnRenderPlot);
                          }
                          }
                          }
                          
                          namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
                          {
                          public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase
                          {
                          public Indicators._OnRenderPlot _OnRenderPlot(SharpDX.Direct2D1.DashStyle dashStyleSolidLine)
                          {
                          return indicator._OnRenderPlot(Input, dashStyleSolidLine);
                          }
                          
                          public Indicators._OnRenderPlot _OnRenderPlot(ISeries<double> input , SharpDX.Direct2D1.DashStyle dashStyleSolidLine)
                          {
                          return indicator._OnRenderPlot(input, dashStyleSolidLine);
                          }
                          }
                          }
                          
                          namespace NinjaTrader.NinjaScript.Strategies
                          {
                          public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase
                          {
                          public Indicators._OnRenderPlot _OnRenderPlot(SharpDX.Direct2D1.DashStyle dashStyleSolidLine)
                          {
                          return indicator._OnRenderPlot(Input, dashStyleSolidLine);
                          }
                          
                          public Indicators._OnRenderPlot _OnRenderPlot(ISeries<double> input , SharpDX.Direct2D1.DashStyle dashStyleSolidLine)
                          {
                          return indicator._OnRenderPlot(input, dashStyleSolidLine);
                          }
                          }
                          }
                          
                          #endregion

                          Comment


                            #58
                            Then added this

                            MaximumBarsLookBack = MaximumBarsLookBack.Infinite;​

                            From this insight


                            to this new version


                            Code:
                            ​
                            #region Using declarations
                            using System;
                            using System.Collections.Generic;
                            using System.ComponentModel;
                            using System.ComponentModel.DataAnnotations;
                            using System.Linq;
                            using System.Text;
                            using System.Threading.Tasks;
                            using System.Windows;
                            using System.Windows.Input;
                            using System.Windows.Media;
                            using System.Xml.Serialization;
                            using NinjaTrader.Cbi;
                            using NinjaTrader.Gui;
                            using NinjaTrader.Gui.Chart;
                            using NinjaTrader.Gui.SuperDom;
                            using NinjaTrader.Gui.Tools;
                            using NinjaTrader.Data;
                            using NinjaTrader.NinjaScript;
                            using NinjaTrader.Core.FloatingPoint;
                            using NinjaTrader.NinjaScript.DrawingTools;
                            
                            
                            using SharpDX;
                            using SharpDX.Direct2D1;
                            //using SharpDX.DirectWrite;
                            #endregion
                            
                            //This namespace holds Indicators in this folder and is required. Do not change it.
                            namespace NinjaTrader.NinjaScript.Indicators
                            {
                            public class _OnRenderPlot : Indicator
                            {
                            private int cBar, cBar1;
                            private double cHigh;
                            
                            // Defines the Series object
                            private Series<double> myDoubleSeries;
                            
                            protected override void OnStateChange()
                            {
                            if (State == State.SetDefaults)
                            {
                            Description = @"Enter the description for your new custom Indicator here.";
                            Name = "_OnRenderPlot";
                            Calculate = Calculate.OnEachTick;
                            IsOverlay = true;
                            DisplayInDataBox = true;
                            DrawOnPricePanel = true;
                            DrawHorizontalGridLines = true;
                            DrawVerticalGridLines = true;
                            PaintPriceMarkers = true;
                            ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
                            //Disable this property if your indicator requires custom values that cumulate with each new market data event.
                            //See Help Guide for additional information.
                            IsSuspendedWhileInactive = true;
                            MaximumBarsLookBack = MaximumBarsLookBack.Infinite;
                            
                            // Adds a blue Dash-Line style plot with 5pixel width and 70% opacity
                            AddPlot(new Stroke(Brushes.Cyan, DashStyleHelper.Dash, 5, 70), PlotStyle.Hash, "MyPlot1");
                            }
                            else if (State == State.Configure)
                            {
                            }
                            
                            else if (State == State.DataLoaded)
                            {
                            myDoubleSeries = new Series<double>(this);
                            }
                            }
                            
                            protected override void OnBarUpdate()
                            {
                            if (CurrentBar <21) return;
                            
                            if (Open[0] < Close[0])
                            {
                            cBar = CurrentBar;
                            cHigh = High[0];
                            MyPlot1[0] = cHigh;
                            
                            //myDoubleSeries[0] = cHigh;
                            }
                            else
                            {
                            //MyPlot1[0] = double.NaN;
                            }
                            
                            if ((CurrentBar - cBar) < 4)
                            {
                            cBar1 = CurrentBar;
                            MyPlot1[0] = cHigh;
                            
                            // Print(" ");
                            // Print("cBar1 " + cBar1 + " " + Time[0]);
                            
                            // Print(" ");
                            // Print("cHigh " + cHigh + " " + Time[0]);
                            
                            myDoubleSeries[0] = cHigh;
                            
                            Print(" ");
                            Print("MyPlot1[0] " + MyPlot1[0] + " " + Time[0]);
                            Print("myDoubleSeries[0] " + myDoubleSeries[0] + " " + Time[0]);
                            Print("MyPlot1IsValid " + MyPlot1.IsValidDataPointAt(CurrentBar) + " " + Time[0]);
                            Print("myDoubleSeriesIsValid " + myDoubleSeries.IsValidDataPointAt(CurrentBar) + " " + Time[0]);
                            
                            // Print(" ");
                            // Print("myDoubleSeries[0] " + myDoubleSeries[0] + " " + Time[0]);
                            }
                            
                            }
                            
                            protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
                            {
                            
                            base.OnRender(chartControl, chartScale);
                            
                            SharpDX.Direct2D1.StrokeStyleProperties ssPropsWick = new SharpDX.Direct2D1.StrokeStyleProperties();
                            ssPropsWick.DashStyle = DashStyleSolidLine;
                            SharpDX.Direct2D1.StrokeStyle solidLine = new SharpDX.Direct2D1.StrokeStyle(RenderTarget.Factory , ssPropsWick);
                            
                            SharpDX.Direct2D1.AntialiasMode oldAntialiasMode = RenderTarget.AntialiasMode;
                            RenderTarget.AntialiasMode = SharpDX.Direct2D1.AntialiasMode.PerPrimitive;
                            
                            Vector2 point0 = new Vector2();
                            Vector2 point1 = new Vector2();
                            
                            Vector2 point2 = new Vector2();
                            Vector2 point3 = new Vector2();
                            
                            for (int barIndex = ChartBars.FromIndex; barIndex <= ChartBars.ToIndex; barIndex++)
                            {
                            
                            double plotValue0 = 0, plotValue1 = 0;
                            float valY0, xHeight0, x0, barWidth0, xWidth0,
                            valY1, xHeight1, x1, barWidth1, xWidth1;
                            // Print(" ");
                            // Print("plotValue0a " + plotValue0 + " " + Bars.GetTime(barIndex));
                            
                            plotValue0 = myDoubleSeries.GetValueAt(barIndex);
                            valY0 = chartScale.GetYByValue(plotValue0);
                            
                            // Print(" ");
                            // Print("plotValue0 " + plotValue0 + " " + Time[0]);
                            
                            x0 = chartControl.GetXByBarIndex(ChartBars, barIndex);
                            barWidth0 = (float)chartControl.BarWidth;
                            
                            point0.X = x0 - barWidth0;
                            point0.Y = valY0;
                            point1.X = x0 + barWidth0;
                            point1.Y = valY0;
                            
                            xHeight0 = 10.0f;
                            xWidth0 = (point1.X - point0.X);
                            
                            bool Cond0 = ( plotValue1 != double.NaN && plotValue0 != double.NaN
                            && ( plotValue1 != plotValue0 ) || (plotValue1 == plotValue0 ));
                            
                            if ( Cond0 )
                            {
                            
                            // Print(" ");
                            // Print("plotValue0b " + plotValue0 + " " + Bars.GetTime(barIndex));
                            RenderTarget.DrawLine(point0, point1, Plots[0].BrushDX, Plots[0].Width, solidLine);
                            }
                            
                            // Print(" ");
                            // Print("plotValue1a " + plotValue1 + " " + Bars.GetTime(barIndex));
                            
                            
                            plotValue1 = myDoubleSeries.GetValueAt(barIndex-1);
                            valY1 = chartScale.GetYByValue(plotValue1);
                            
                            // Print(" ");
                            // Print("plotValue1 " + plotValue1 + " " + Time[0]);
                            
                            x1 = chartControl.GetXByBarIndex(ChartBars, barIndex-1);
                            
                            point2.X = x1 + barWidth0;
                            point2.Y = valY1;
                            point3.X = x0 - barWidth0;
                            point3.Y = valY1;
                            
                            xHeight1 = 10.0f;
                            xWidth1 = (point3.X - point2.X);
                            
                            bool Cond1 = ( plotValue1 != double.NaN && plotValue0 != double.NaN
                            && plotValue1 == plotValue0 && !( plotValue1 != plotValue0 ));
                            
                            if ( Cond1 )
                            {
                            
                            // Print(" ");
                            // Print("plotValue1b " + plotValue1 + " " + Bars.GetTime(barIndex));
                            RenderTarget.DrawLine(point2, point3, Plots[0].BrushDX, Plots[0].Width, solidLine);
                            }
                            }
                            
                            RenderTarget.AntialiasMode = oldAntialiasMode;
                            solidLine.Dispose();
                            }
                            
                            #region Properties
                            
                            [Browsable(false)]
                            [XmlIgnore]
                            public Series<double> MyPlot1
                            {
                            get { return Values[0]; }
                            }
                            
                            [NinjaScriptProperty]
                            [Display(Name="DashStyle Solid Line", Description="DashStyle Solid Line.", Order=0, GroupName="Plots Lines")]
                            public SharpDX.Direct2D1.DashStyle DashStyleSolidLine
                            { get; set; }
                            
                            #endregion
                            }
                            }
                            
                            #region NinjaScript generated code. Neither change nor remove.
                            
                            namespace NinjaTrader.NinjaScript.Indicators
                            {
                            public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
                            {
                            private _OnRenderPlot[] cache_OnRenderPlot;
                            public _OnRenderPlot _OnRenderPlot(SharpDX.Direct2D1.DashStyle dashStyleSolidLine)
                            {
                            return _OnRenderPlot(Input, dashStyleSolidLine);
                            }
                            
                            public _OnRenderPlot _OnRenderPlot(ISeries<double> input, SharpDX.Direct2D1.DashStyle dashStyleSolidLine)
                            {
                            if (cache_OnRenderPlot != null)
                            for (int idx = 0; idx < cache_OnRenderPlot.Length; idx++)
                            if (cache_OnRenderPlot[idx] != null && cache_OnRenderPlot[idx].DashStyleSolidLine == dashStyleSolidLine && cache_OnRenderPlot[idx].EqualsInput(input))
                            return cache_OnRenderPlot[idx];
                            return CacheIndicator<_OnRenderPlot>(new _OnRenderPlot(){ DashStyleSolidLine = dashStyleSolidLine }, input, ref cache_OnRenderPlot);
                            }
                            }
                            }
                            
                            namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
                            {
                            public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase
                            {
                            public Indicators._OnRenderPlot _OnRenderPlot(SharpDX.Direct2D1.DashStyle dashStyleSolidLine)
                            {
                            return indicator._OnRenderPlot(Input, dashStyleSolidLine);
                            }
                            
                            public Indicators._OnRenderPlot _OnRenderPlot(ISeries<double> input , SharpDX.Direct2D1.DashStyle dashStyleSolidLine)
                            {
                            return indicator._OnRenderPlot(input, dashStyleSolidLine);
                            }
                            }
                            }
                            
                            namespace NinjaTrader.NinjaScript.Strategies
                            {
                            public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase
                            {
                            public Indicators._OnRenderPlot _OnRenderPlot(SharpDX.Direct2D1.DashStyle dashStyleSolidLine)
                            {
                            return indicator._OnRenderPlot(Input, dashStyleSolidLine);
                            }
                            
                            public Indicators._OnRenderPlot _OnRenderPlot(ISeries<double> input , SharpDX.Direct2D1.DashStyle dashStyleSolidLine)
                            {
                            return indicator._OnRenderPlot(input, dashStyleSolidLine);
                            }
                            }
                            }
                            
                            #endregion
                            Now the error is fixed.

                            It seems the erratic extra rendering got also fixed:



                            Any insight on what fixed this?
                            is it this statement?
                            MaximumBarsLookBack = MaximumBarsLookBack.Infinite;​

                            If so what's that fix?

                            Comment


                              #59
                              Hello PaulMohn,

                              MaximumBarsLookBack.Infinite allows indexes of larger than 256 to be used with a series.


                              "Warning: Calling IsValidDataPointAt() will only work a MaximumBarsLookBackInfinite series. Attempting to check IsValidDataPointAt() MaximumBarsLookBack256 series throw an error. Please check the Log tab of the Control Center"
                              Chelsea B.NinjaTrader Customer Service

                              Comment


                                #60
                                Code:
                                #region Using declarations
                                using System;
                                using System.Collections.Generic;
                                using System.ComponentModel;
                                using System.ComponentModel.DataAnnotations;
                                using System.Linq;
                                using System.Text;
                                using System.Threading.Tasks;
                                using System.Windows;
                                using System.Windows.Input;
                                using System.Windows.Media;
                                using System.Xml.Serialization;
                                using NinjaTrader.Cbi;
                                using NinjaTrader.Gui;
                                using NinjaTrader.Gui.Chart;
                                using NinjaTrader.Gui.SuperDom;
                                using NinjaTrader.Gui.Tools;
                                using NinjaTrader.Data;
                                using NinjaTrader.NinjaScript;
                                using NinjaTrader.Core.FloatingPoint;
                                using NinjaTrader.NinjaScript.DrawingTools;
                                
                                
                                using SharpDX;
                                using SharpDX.Direct2D1;
                                #endregion
                                
                                //This namespace holds Indicators in this folder and is required. Do not change it.
                                namespace NinjaTrader.NinjaScript.Indicators
                                {
                                    public class _OnRenderPlot : Indicator
                                    {
                                        private int cBar;
                                        private double cHigh;
                                        
                                        protected override void OnStateChange()
                                        {
                                            if (State == State.SetDefaults)
                                            {
                                                Description                                 = @"Enter the description for your new custom Indicator here.";
                                                Name                                        = "_OnRenderPlot";
                                                Calculate                                   = Calculate.OnEachTick;
                                                IsOverlay                                   = true;
                                                DisplayInDataBox                            = true;
                                                DrawOnPricePanel                            = true;
                                                DrawHorizontalGridLines                     = true;
                                                DrawVerticalGridLines                       = true;
                                                PaintPriceMarkers                           = true;
                                                ScaleJustification                          = NinjaTrader.Gui.Chart.ScaleJustification.Right;
                                                //Disable this property if your indicator requires custom values that cumulate with each new market data event.
                                                //See Help Guide for additional information.
                                                IsSuspendedWhileInactive                    = true;
                                                MaximumBarsLookBack                            = MaximumBarsLookBack.Infinite;
                                        
                                                
                                                ShowTransparentPlotsInDataBox = true;
                                                
                                                
                                                plot1Brush = Brushes.ForestGreen;
                                                
                                                 // Adds a Cyan Dash-Line style plot with 5pixel width and 3% opacity to hide the plot
                                                AddPlot(new Stroke(Brushes.Transparent, DashStyleHelper.Dash, 5, 3), PlotStyle.Hash, "MyPlot1");
                                            }
                                            else if (State == State.Configure)
                                            {
                                            }
                                        }
                                
                                        protected override void OnBarUpdate()
                                        {    
                                            if (CurrentBar <21) return;
                                            
                                            if (Open[0] < Close[0])
                                            {
                                                cBar = CurrentBar;
                                                cHigh = High[0];
                                                MyPlot1[0] = cHigh;
                                            }
                                                
                                            if ((CurrentBar - cBar) < 4)
                                            {
                                                MyPlot1[0] = cHigh;
                                            }
                                            
                                        }
                                        
                                        protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
                                        {
                                            
                                            base.OnRender(chartControl, chartScale);
                                                
                                            SharpDX.Direct2D1.Brush plot1BrushDx;
                                            plot1BrushDx = plot1Brush.ToDxBrush(RenderTarget);
                                            
                                            SharpDX.Direct2D1.AntialiasMode oldAntialiasMode = RenderTarget.AntialiasMode;
                                            RenderTarget.AntialiasMode = SharpDX.Direct2D1.AntialiasMode.PerPrimitive;
                                            
                                            Vector2            point0            = new Vector2();
                                            Vector2            point1            = new Vector2();
                                            
                                            Vector2            point2            = new Vector2();
                                            Vector2            point3            = new Vector2();
                                
                                            for (int barIndex = ChartBars.FromIndex; barIndex <= ChartBars.ToIndex; barIndex++)
                                            {
                                                
                                                double    plotValue0 = 0, plotValue1 = 0;
                                                float    valY0, xHeight0, x0, barWidth0, xWidth0,
                                                        valY1, xHeight1, x1, barWidth1, xWidth1,
                                                        outlineWidth;
                                                
                                                plotValue0        = MyPlot1.GetValueAt(barIndex);
                                                valY0             = chartScale.GetYByValue(plotValue0);
                                                
                                                x0                = chartControl.GetXByBarIndex(ChartBars, barIndex);
                                                  barWidth0         = (float)chartControl.BarWidth;
                                                
                                                outlineWidth    = ChartBars.Properties.ChartStyle.Stroke2.Width; // 1.0f;
                                                
                                                point0.X         = x0 - barWidth0 - outlineWidth;
                                                point0.Y         = valY0;
                                                point1.X         = x0 + barWidth0 + outlineWidth;
                                                point1.Y         = valY0;
                                                
                                                xHeight0        = 10.0f;
                                                xWidth0            = (point1.X - point0.X);
                                                
                                                bool Cond0 =  ( plotValue1 != double.NaN && plotValue0 != double.NaN
                                                                && ( plotValue1 != plotValue0 ) || (plotValue1 == plotValue0 ));
                                                
                                                if ( Cond0 )
                                                {
                                                    RenderTarget.DrawLine(point0, point1, plot1BrushDx, 4);
                                                }
                                                
                                                
                                                plotValue1        = MyPlot1.GetValueAt(barIndex-1);
                                                valY1             = chartScale.GetYByValue(plotValue1);
                                                
                                                x1                = chartControl.GetXByBarIndex(ChartBars, barIndex-1);
                                                
                                                point2.X         = x1 + barWidth0 - outlineWidth;
                                                point2.Y         = valY1;
                                                point3.X         = x0 - barWidth0 + outlineWidth;
                                                point3.Y         = valY1;
                                                
                                                xHeight1        = 10.0f;
                                                xWidth1            = (point3.X - point2.X);
                                                
                                                bool Cond1 =  ( plotValue1 != double.NaN && plotValue0 != double.NaN
                                                                && plotValue1 == plotValue0 && !( plotValue1 != plotValue0 ));
                                                
                                                if ( Cond1 )
                                                {
                                                    RenderTarget.DrawLine(point2, point3, plot1BrushDx, 4);
                                                }
                                            }
                                            
                                            RenderTarget.AntialiasMode = oldAntialiasMode;
                                        }
                                              
                                        #region Properties
                                        
                                            [Browsable(false)]
                                            [XmlIgnore]
                                            public Series<double> MyPlot1
                                            {
                                              get { return Values[0]; }
                                            }
                                            
                                            
                                            [NinjaScriptProperty]
                                            [XmlIgnore]
                                            [Display(Name="Plot Brush", Order=1, GroupName="Parameters")]
                                            public System.Windows.Media.Brush plot1Brush
                                            { get; set; }
                                
                                            [Browsable(false)]
                                            public string plot1BrushSerializable
                                            {
                                                get { return Serialize.BrushToString(plot1Brush); }
                                                set { plot1Brush = Serialize.StringToBrush(value); }
                                            }
                                            
                                        #endregion
                                    }
                                }
                                
                                #region NinjaScript generated code. Neither change nor remove.
                                
                                namespace NinjaTrader.NinjaScript.Indicators
                                {
                                    public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
                                    {
                                        private _OnRenderPlot[] cache_OnRenderPlot;
                                        public _OnRenderPlot _OnRenderPlot(System.Windows.Media.Brush plot1Brush)
                                        {
                                            return _OnRenderPlot(Input, plot1Brush);
                                        }
                                
                                        public _OnRenderPlot _OnRenderPlot(ISeries<double> input, System.Windows.Media.Brush plot1Brush)
                                        {
                                            if (cache_OnRenderPlot != null)
                                                for (int idx = 0; idx < cache_OnRenderPlot.Length; idx++)
                                                    if (cache_OnRenderPlot[idx] != null && cache_OnRenderPlot[idx].plot1Brush == plot1Brush && cache_OnRenderPlot[idx].EqualsInput(input))
                                                        return cache_OnRenderPlot[idx];
                                            return CacheIndicator<_OnRenderPlot>(new _OnRenderPlot(){ plot1Brush = plot1Brush }, input, ref cache_OnRenderPlot);
                                        }
                                    }
                                }
                                
                                namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
                                {
                                    public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase
                                    {
                                        public Indicators._OnRenderPlot _OnRenderPlot(System.Windows.Media.Brush plot1Brush)
                                        {
                                            return indicator._OnRenderPlot(Input, plot1Brush);
                                        }
                                
                                        public Indicators._OnRenderPlot _OnRenderPlot(ISeries<double> input , System.Windows.Media.Brush plot1Brush)
                                        {
                                            return indicator._OnRenderPlot(input, plot1Brush);
                                        }
                                    }
                                }
                                
                                namespace NinjaTrader.NinjaScript.Strategies
                                {
                                    public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase
                                    {
                                        public Indicators._OnRenderPlot _OnRenderPlot(System.Windows.Media.Brush plot1Brush)
                                        {
                                            return indicator._OnRenderPlot(Input, plot1Brush);
                                        }
                                
                                        public Indicators._OnRenderPlot _OnRenderPlot(ISeries<double> input , System.Windows.Media.Brush plot1Brush)
                                        {
                                            return indicator._OnRenderPlot(input, plot1Brush);
                                        }
                                    }
                                }
                                
                                #endregion

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                                0 responses
                                571 views
                                0 likes
                                Last Post Geovanny Suaza  
                                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                                0 responses
                                330 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by Mindset, 02-09-2026, 11:44 AM
                                0 responses
                                101 views
                                0 likes
                                Last Post Mindset
                                by Mindset
                                 
                                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                                0 responses
                                548 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by RFrosty, 01-28-2026, 06:49 PM
                                0 responses
                                549 views
                                1 like
                                Last Post RFrosty
                                by RFrosty
                                 
                                Working...
                                X