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

noob error; looking at past bars gives no data

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

    noob error; looking at past bars gives no data

    why does Close[0] work fine?
    but Close[1] returns nothing ?

    i have lots of data, i can see that Close[0] is 74.34, and prev close is 74.32

    see the bottom of the code snippet




    [Description("test/tutorial trying to replicate MO, from QT")]
    public class VolSMA : Indicator
    {
    #region Variables
    // Wizard generated variables
    private int period = 10; // Default setting for Period
    // User defined variables (add any user defined variables below)
    #endregion

    /// <summary>
    /// This method is used to configure the indicator and is called once before any bar data is loaded.
    /// </summary>
    protected override void Initialize()
    {
    Add(new Plot(Color.FromKnownColor(KnownColor.Green), PlotStyle.Bar, "Plot0"));
    Add(new Line(Color.FromKnownColor(KnownColor.DarkOliveGree n), 0, "Line1"));
    Add(new Line(Color.FromKnownColor(KnownColor.Khaki), 0, "Line2"));
    CalculateOnBarClose = true;
    Overlay = false;
    PriceTypeSupported = false;
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    // double average = SMA(VOL(),Period)[0];
    double average = Momentum(Close,14)[0]-Momentum(Close,10)[0];
    average = Close[0] ; /// this works fine, unless i have the following:
    average = Close[1] ; /// this generates NO lines or data
    Plot0.Set(average);
    }

    #2
    n/m figured it out

    added the CurrentBar test

    Comment


      #3
      Welcome to our forums here, great you got it working!
      BertrandNinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Max238, Today, 01:28 AM
      1 response
      23 views
      0 likes
      Last Post CactusMan  
      Started by giulyko00, Yesterday, 12:03 PM
      2 responses
      10 views
      0 likes
      Last Post giulyko00  
      Started by r68cervera, Today, 05:29 AM
      0 responses
      4 views
      0 likes
      Last Post r68cervera  
      Started by geddyisodin, Today, 05:20 AM
      0 responses
      7 views
      0 likes
      Last Post geddyisodin  
      Started by JonesJoker, 04-22-2024, 12:23 PM
      6 responses
      38 views
      0 likes
      Last Post JonesJoker  
      Working...
      X