Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Why will the alert function not work in OnStartUp?

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

    Why will the alert function not work in OnStartUp?

    This my code snippet.
    Code:
    [FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]protected [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]override [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] OnStartUp()[/SIZE][/FONT]
    [SIZE=2][FONT=Courier New]{[/FONT][/SIZE]
    [SIZE=2][FONT=Courier New]Alert([/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]"Startup Alert"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2], NinjaTrader.Cbi.Priority.High, [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]"Start Up Alert"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2], [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]"Alert1.wav"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2], [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2], Color.Blue, Color.Azure);[/SIZE][/FONT]
    [SIZE=2][FONT=Courier New]}[/FONT][/SIZE]
    [/SIZE][/FONT]
    However, this alert never happens. Why?

    #2
    Welcome to our forums here - Alerts would only trigger in realtime so this would be never called.

    Please move the Alert part to your OnBarUpdate() and then retry.

    Comment


      #3
      What other things can I do in the OnStartUp method?

      Hi,

      Thanks for your reply,

      Just wondering. What tasks are available in the OnStartUp method. Can I do inital data collection on the historical bars?

      Comment


        #4
        You could allocate custom resources needed that would benefit from being called only one time after the script's Initialize() - http://www.ninjatrader.com/support/h.../onstartup.htm

        Comment


          #5
          Hi & thanks for your help.

          Funny enough, I've tried the Print function, but this will also not work. This caused me concerns if the OnStartUp() gets executed at all. So I've tried showing a message box from within this method and it showed up. Can someone please explain to me why the Alert() and Print() functions will not work in OnStartUp?

          Comment


            #6
            The alert will not work in backtesting, this is expected - what call were you using in OnStartUp() for the other checks - would you have a snippet?

            Is this on latest Beta 18?

            Comment


              #7
              Hi, Thanks.

              Well I'm still working on it. Basically, I want to check current trend direction and size, before leaving control to OnBarUpdate() method.

              At current I'm using beta 17.

              Comment


                #8
                Avrohom, there are no bars available for the strategy to check in the OnStartUp() method. The first instance of when a bar would be available is in OnBarUpdate() when CurrentBar == 0.
                AustinNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                648 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                369 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                108 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                572 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                573 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X