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 cmoran13, 04-16-2026, 01:02 PM
        0 responses
        43 views
        0 likes
        Last Post cmoran13  
        Started by PaulMohn, 04-10-2026, 11:11 AM
        0 responses
        25 views
        0 likes
        Last Post PaulMohn  
        Started by CarlTrading, 03-31-2026, 09:41 PM
        1 response
        162 views
        1 like
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        98 views
        1 like
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        157 views
        2 likes
        Last Post CaptainJack  
        Working...
        X