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 pibrew, Today, 06:37 AM
        0 responses
        0 views
        0 likes
        Last Post pibrew
        by pibrew
         
        Started by rbeckmann05, Yesterday, 06:48 PM
        1 response
        12 views
        0 likes
        Last Post bltdavid  
        Started by llanqui, Today, 03:53 AM
        0 responses
        6 views
        0 likes
        Last Post llanqui
        by llanqui
         
        Started by burtoninlondon, Today, 12:38 AM
        0 responses
        11 views
        0 likes
        Last Post burtoninlondon  
        Started by AaronKoRn, Yesterday, 09:49 PM
        0 responses
        15 views
        0 likes
        Last Post AaronKoRn  
        Working...
        X