Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

NT7.0.0.16 ?bug? - Instrument.FullName changes in subsequent calls of Initialize()

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

    NT7.0.0.16 ?bug? - Instrument.FullName changes in subsequent calls of Initialize()

    Good Morning Ninjas, I wonder if this is by design or a bug. I vote for bug....

    Chosen instrument name is not "stored" when a new instance of strategy created through the subsequent call of Initialize() method.

    It most likely happens all the time when creating a new instance of a strategy and than trying to edit the same strategy. My experiment focused on the "Strategy" tab.


    Steps to recreate I've used the SampleMACrossover, saved as SampleMACrossover02 and made the code changes below in red and bold.
    Compile the new strategy and than create a new instance on the "Strategy" tab.
    Select other then default Instrument and account...
    Click ok than highlight and edit the strategy and see how the Instrument Name will change...

    See results on the output window
    note: OnbarUpdate() seems to work fine...

    My problem is that my DB based initialization done through the Initialize() method is messing up my custom settings. I am able to work around this doing it again in the OnbarUpdate() however that is not the behavior I am expecting when the Initialize() method is called.

    Please advise! Thanks atata,

    #region Variables
    private int fast = 10;
    private int slow = 25;

    private string sInstrumentName;
    private string sAccountName;

    #endregion

    /// <summary>
    /// This method is used to configure the strategy and is called once before any strategy method is called.
    /// </summary>
    protected override void Initialize()
    {
    Print("++++++++++++ Start SampleMACrossOver02 - Initialize() +++++++++++++++++");
    sInstrumentName = Instrument.FullName.ToString();
    Print("sInstrumentName is... " + sInstrumentName);

    sAccountName = Account.Name.ToString();
    Print("Account Name... " + sAccountName);

    SMA(Fast).Plots[0].Pen.Color = Color.Orange;
    SMA(Slow).Plots[0].Pen.Color = Color.Green;

    Add(SMA(Fast));
    Add(SMA(Slow));

    CalculateOnBarClose = true;
    Print("++++++++++++ Done SampleMACrossOver02 - Initialize() +++++++++++++++++");
    }

    #2
    atata,

    This is expected. You should not be running logic off of Initialize(). If you have some things you want to do only once on start up you should do it in the OnStartUp() method instead where the Bars of the indicator/strategy will already be solidified.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Josh, thanks for the prompt reply. I'll follow your recommendation.

      Comment


        #4
        It would appear that OnStartUp() is a new method introduced in NT7, so I not longer need to use this ?

        Code:
        if (CurrentBar == 0) 
        { 
        statement; 
        statement; 
        etc;
        }
        ref: http://www.ninjatrader.com/support/f...50&postcount=4 from NinjaTrader_Tim

        Comment


          #5
          Correct koganam, custom resources that you allocated on first OnBarUpdate() bar can now be triggered in the new OnStartUp() method in NT7, this will only be called once.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          599 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          344 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          103 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          558 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          557 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X