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 LiamTwine, Today, 08:10 AM
        0 responses
        2 views
        0 likes
        Last Post LiamTwine  
        Started by Balage0922, Today, 07:38 AM
        0 responses
        5 views
        0 likes
        Last Post Balage0922  
        Started by JoMoon2024, Today, 06:56 AM
        0 responses
        6 views
        0 likes
        Last Post JoMoon2024  
        Started by Haiasi, 04-25-2024, 06:53 PM
        2 responses
        19 views
        0 likes
        Last Post Massinisa  
        Started by Creamers, Today, 05:32 AM
        0 responses
        6 views
        0 likes
        Last Post Creamers  
        Working...
        X