Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Plot a dot at a zero line for each bar

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

    Plot a dot at a zero line for each bar

    Hello,

    I am developing an indicator which oscillates above/below a zero line. The indicator plots the oscillator and plots a zero line.

    At each bar I'd like to add a dot on the zero line but I'm struggling to make the AddPlot() syntax detailed in the help guide work for me, my code is below.
    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    AddPlot(new Stroke(Brushes.Blue), PlotStyle.Dot, "MyPlot2");

    protected override void OnBarUpdate()
    {
    MyPlot[0] = 0​;
    }

    [Browsable(false)]
    [XmlIgnore]
    public Series<double> MyPlot
    {
    get { return Values[0]; }
    }

    What am I missing?

    Thanks,

    Neil

    #2
    Hello burtoninlondon,

    Thanks for your post.

    The correct syntax to add a Dot plot to the chart would look something like below.

    Code:
    protected override void OnStateChange()
    {
        if (State == State.SetDefaults)
        {
            AddPlot(new Stroke(Brushes.Blue, 2), PlotStyle.Dot, "PlotTest");
        }
    }
    
    protected override void OnBarUpdate()
    {
        PlotTest[0] = 0;
    }
    
    [Browsable(false)]
    [XmlIgnore]
    public Series<double> PlotTest
    {
        get { return Values[0]; }
    }
    See the help guide documentation below for more information.
    AddPlot(): https://ninjatrader.com/support/help...t8/addplot.htm

    Let us know if we may assist further.
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment


      #3
      Thanks NinjaTrader_BrandonH for your response.

      When I add the code "PlotTest[0] = 0;" to my indicator script it changes the oscillator plot and does not plot the dots on the zero line. By adding the second plot for the dots, I now have two AddPlots in the same indicator, should I be doing anything to differentiate between the different plots?

      Comment


        #4
        Hello burtoninlondon,

        Thanks for your note.

        That sample code was meant to be an example and not the exact code that should be used in your script.

        If you compare the sample code in my previous post to the code in your initial post, we can see the following syntax difference, other than the plot names, in bold.

        Your code: AddPlot(new Stroke(Brushes.Blue), PlotStyle.Dot, "MyPlot2");

        Sample code: AddPlot(new Stroke(Brushes.Blue, 2), PlotStyle.Dot, "PlotTest");

        This means your AddPlot() code should look like this: AddPlot(new Stroke(Brushes.Blue, 2), PlotStyle.Dot, "MyPlot2");

        See the attached example script demonstrating adding a dot plot with AddPlot.

        Let us know if we may assist further
        Attached Files
        <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

        Comment


          #5
          Thanks NinjaTrader_BrandonH , that worked.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          576 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          334 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
          553 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          551 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X