Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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...
    BertrandNinjaTrader Customer Service

    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 kevinenergy, 02-17-2023, 12:42 PM
        118 responses
        2,778 views
        1 like
        Last Post kevinenergy  
        Started by briansaul, Today, 05:31 AM
        0 responses
        9 views
        0 likes
        Last Post briansaul  
        Started by traderqz, Yesterday, 12:06 AM
        11 responses
        28 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by PaulMohn, Today, 03:49 AM
        0 responses
        8 views
        0 likes
        Last Post PaulMohn  
        Started by inanazsocial, Today, 01:15 AM
        1 response
        10 views
        0 likes
        Last Post NinjaTrader_Jason  
        Working...
        X