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

how about this?**NT** Error on calling 'OnBarUpdate' method for strategy 'alaoluo/41d

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

    how about this?**NT** Error on calling 'OnBarUpdate' method for strategy 'alaoluo/41d

    when I run a strategy....the output window print this

    **NT** Enabling NinjaScript strategy 'alaoluo/41d23067d6584cd3a48fa605947334a2' : On starting a real-time strategy - StrategySync=WaitUntilFlat SyncAccountPosition=False EntryHandling=AllEntries EntriesPerDirection=1 StopTargetHandling=PerEntryExecution ErrorHandling=StopStrategyCancelOrdersClosePositio ns ExitOnClose=True/ triggering 30 before close Set order quantity by=Strategy ConnectionLossHandling=KeepRunning DisconnectDelaySeconds=10 CancelEntryOrdersOnDisable=False CancelExitOrdersOnDisable=True MaxRestarts=4 in 5 minutes
    **NT** Error on calling 'OnBarUpdate' method for strategy 'alaoluo/41d23067d6584cd3a48fa605947334a2': 'Object reference not set to an instance of an object'

    #2
    Anyone Can help me, I will apretiate very much!

    Comment


      #3
      And here is my Ninja 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
      // This namespace holds all strategies and is required. Do not change it.
      namespace NinjaTrader.Strategy
      {
      /// <summary>
      /// Enter the description of your strategy here
      /// </summary>
      [Description("Enter the description of your strategy here")]
      public class alaoluo : Strategy
      {
      #region Variables
      // Wizard generated variables
      // User defined variables (add any user defined variables below)
      #endregion
      /// <summary>
      /// This method is used to configure the strategy and is called once before any strategy method is called.
      /// </summary>
      #region Variables
      private DateTimeSeries myDateTimeSeries; // Define a DateTimeSeries variable
      #endregion
      protected override void Initialize()
      {
      Add("RL",PeriodType.Minute,1);
      Print("data is ready");
      CalculateOnBarClose = true;
      }
      /// <summary>
      /// Called on each bar update event (incoming tick)
      /// </summary>
      protected override void OnBarUpdate()
      {

      {


      if (BarsInProgress==0 || BarsInProgress==1 )
      {
      if(CurrentBar < 1)
      return;
      if ((ToTime(Time[0]) <= ToTime(9, 30, 0)) &&( ToTime(Time[0]) >= ToTime(9, 35, 0))
      && (CurrentDayOHL().CurrentHigh[0]-CurrentDayOHL().CurrentLow[0]<=2))
      {
      Print("symbol"+Instrument.FullName+currentdailyran ge is"
      +(CurrentDayOHL().CurrentHigh[0]-CurrentDayOHL().CurrentLow[0]));
      }




      if ((ToTime(Time[0]) <= ToTime(10, 30, 0)) && (ToTime(Time[0]) >= ToTime(9, 35, 0))
      && (CurrentDayOHL().CurrentOpen[0]>Bars.GetDayBar(1).Close+0.5)
      && (Close[0]-CurrentDayOHL().CurrentOpen[0]<0)
      && (CurrentDayOHL().CurrentLow[0]-Bars.GetDayBar(1).Close>0))
      {
      int lowestbarnum1=LowestBar(Close,ToTime(Time[0])-ToTime(9, 30, 0));
      int highestbarnum1=HighestBar(Close,ToTime(Time[0])-lowestbarnum1);

      if ( (Math.Abs(Close[LowestBar(Close,highestbarnum1)]-
      Close[lowestbarnum1])<=0.05)
      && (Close[highestbarnum1]-Close[lowestbarnum1]>=0.2)
      && (Close[0]>Close[lowestbarnum1]) && (Close[0]<Close[highestbarnum1]))

      Print("symbol"+Instrument.FullName+"NOW is available");
      }

      }
      }
      }
      #region Properties
      #endregion
      }
      }










      Best wishes

      Comment


        #4
        hi ....I have resolve this problem
        because bars object should be new before use it
        while this another question
        **NT** Error on calling 'OnBarUpdate' method for strategy 'alaoluo/270d83c26bbc4aaba31b678537911df4': You are accessing an index with a value that is invalid since its out of range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.

        I am sure array index >=0 and I want to backtest multiinstrument strategy...
        pls help me.

        another question:
        when a reload a charts with 3000 bars,I run the multiinstruments strategy...it load another instrument data as 3000 bars or not?


        best wishes,thanks.

        Comment


          #5
          the key Code as mentioned above is this:

          double initvalue=Close[ToTime(Time[0])-ToTime(9, 35, 0)]-Close[ToTime(Time[0])-ToTime(9, 31, 0)];

          Comment


            #6
            silverness, likely you run into this issue here - http://www.ninjatrader.com/support/f...ead.php?t=3170

            For a MultiSeries script the check needs to be expanded to cover any series you use.
            BertrandNinjaTrader Customer Service

            Comment


              #7
              thanks a lot!

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by DJ888, 04-16-2024, 06:09 PM
              6 responses
              18 views
              0 likes
              Last Post DJ888
              by DJ888
               
              Started by Jon17, Today, 04:33 PM
              0 responses
              1 view
              0 likes
              Last Post Jon17
              by Jon17
               
              Started by Javierw.ok, Today, 04:12 PM
              0 responses
              6 views
              0 likes
              Last Post Javierw.ok  
              Started by timmbbo, Today, 08:59 AM
              2 responses
              10 views
              0 likes
              Last Post bltdavid  
              Started by alifarahani, Today, 09:40 AM
              6 responses
              41 views
              0 likes
              Last Post alifarahani  
              Working...
              X