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 CarlTrading, 03-31-2026, 09:41 PM
        1 response
        81 views
        1 like
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        42 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        64 views
        2 likes
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        66 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        54 views
        0 likes
        Last Post CarlTrading  
        Working...
        X