Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

OnStartUp() not called when toggling instruments

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

    OnStartUp() not called when toggling instruments

    I have used OnStartUp() to rename the plots for FDAX.

    Observed with NT 7.0.0.22

    When adding the indicator to the FDAX chart, the plots are correctly renamed and the plotname is displayed on the chart.

    Now I toggle to another instrument -> original plotname appears (expected)
    Now I toggle back to FDAX -> original plotname is maintained (not expected OnStartUp() is ignored)

    Problem

    OnStartUp() is not called, when toggling from one instrument to another. Or how can you explain that an indicator applied to FDAX changes its value when toggling to ES and the back to FDAX?

    This is the code used:

    Code:
     
    protected override void OnStartUp()
    {
    if (Instrument.MasterInstrument.Name == "FDAX") 
    Plots[0].Name = "NewName";
    }
    NewName appears when adding indicator, but not when toggling to ES and back to FDAX.
    Last edited by Harry; 09-30-2010, 02:35 PM.

    #2
    Plots is not re-initialized when toggling

    Sorry, I need to be more precise.

    On StartUp() is called, but when toggling from one instrument to another the plots are not initialized. I have coded a simple test indicator, which I attach.

    Please do the following:

    Apply indicator to a simple ES chart. Then toggle to FDAX and back to ES. And now the indicator displays something different.

    When toggling to FDAX -> OnStartUp() is called (as expected)
    When toggling back to ES -> the Plot is not reinitialized, so indicator still displays FDAX which is not the plot name.

    As the Plots are set in the Initialize() section, I do expect that they are initialized, if I toggle.
    Attached Files

    Comment


      #3
      Harry,

      The behavior you see is correct. To achieve what you are trying to do you would instead want to add an else condition.

      Code:
      protected override void OnStartUp()
      {
          if (Instrument.MasterInstrument.Name == "FDAX" )
              Plots[0].Name = "FDAX";
          else
              Plots[0].Name = "Other Instruments";
      }
      Reason: If plots were reinitialized that would mean any time someone changed the instrument on their chart their indicators would reset to defaults. If someone changed their SMA to be a red colored plot, changed instruments, reinitializing the plots would mean the SMA is now the default orange again. This would definitely not be expected.
      Josh P.NinjaTrader Customer Service

      Comment


        #4
        Thanks for the clear answer, that makes sense.

        It is counterintuitive, just sort of a paradox, as the condition that checks the instrument is interfering with the toggling, creating a feedback loop. In the end you get a different plotname for the same instrument.

        Originally posted by NinjaTrader_Josh View Post
        Harry,

        The behavior you see is correct. To achieve what you are trying to do you would instead want to add an else condition.

        Code:
        protected override void OnStartUp()
        {
            if (Instrument.MasterInstrument.Name == "FDAX" )
                Plots[0].Name = "FDAX";
            else
                Plots[0].Name = "Other Instruments";
        }
        Reason: If plots were reinitialized that would mean any time someone changed the instrument on their chart their indicators would reset to defaults. If someone changed their SMA to be a red colored plot, changed instruments, reinitializing the plots would mean the SMA is now the default orange again. This would definitely not be expected.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        598 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        343 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
        556 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        555 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X