Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

help with indicator basics

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

    help with indicator basics

    Can anybody say why this indicator does not show up in a chart when I add it? A panel appears on the chart, but there is no line in the chart.

    thanks,
    Matthew.

    Code:
    #region Using declarations
    using System;
    using System.ComponentModel;
    using System.Diagnostics;
    using System.Drawing;
    using System.Drawing.Drawing2D;
    using System.Xml.Serialization;
    using NinjaTrader.Cbi;
    using NinjaTrader.Data;
    using NinjaTrader.Indicator;
    using NinjaTrader.Gui.Chart;
    using NinjaTrader.Strategy;
    #endregion
    
    namespace NinjaTrader.Indicator {
        public class R_indicator : Indicator {
            uint timeCounter = 0; 
            DataSeries R;
            protected override void Initialize() {
                R = new DataSeries(this);
                Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "R"));
            }
            protected override void OnBarUpdate() {
                 if (timeCounter > 0) R.Set(Close[0]-Close[1]); else R.Set(0);
                 Print(timeCounter + "   " + R[0]);
                 timeCounter += 1;
            }
        }
    }

    #2
    Please check into this tip here - http://www.ninjatrader-support2.com/...ead.php?t=3170

    You likely see an error in the log, as you attempt to access bars not defined at the OnBarUpdate() start...

    Comment


      #3
      Thanks Bertrand,

      I added:
      if (CurrentBar < 1) return;

      to the start of OnBarUpdate() but I still have the same problem. Note that my timeCounter variable achieves the same anyhow. There are no errors output to the log.

      Any other ideas?

      Thanks,
      Matthew.

      Comment


        #4
        Matthew,

        You didn't set anything to a plot. You set it to the R DataSeries object which is something you created as a custom DataSeries. You need to set values to the actual plot itself, not a custom DataSeries.
        Josh P.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        602 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        347 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        103 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        560 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        559 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X