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

Workspace Open Event

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

    Workspace Open Event

    I would like to call a function when a given workspace is done opening and I'm wondering how the best way to do this would be. Is there an override OnWorkspaceActivated() type of function, an event handle or do you use OnStateChange()? Is the WorkspaceMenuItem.IsActive a good way to reference it?

    To start out with, I'd just like to show a MessageBox or set a bool variable to true when the workspace is fully loaded.

    Thanks

    #2
    Hello BrennanSalibrici,

    Thanks for your post.

    There is not a supported means to identify when the workspace has finished loading. The workspace will load all charts/windows and also load all other indicators. We do not offer a documented event to identify when this has completed.

    You could consider checking when individual scripts have loaded when they have reached State.Realtime, however. For example, you could try looping through all windows, and checking the State of all indicators to see that they have reached this state, which may attain your goal.

    Something like the following:

    Code:
    foreach (var window in NinjaTrader.Core.Globals.AllWindows)
    {
        //check if the found window is a Chart window, if not continue looking
        if (!(window is NinjaTrader.Gui.Chart.Chart)) continue;
    
        window.Dispatcher.InvokeAsync(new Action(() =>
        {
            //try to cast as a Chart, if it fails it will be null
            var foundChart = window as NinjaTrader.Gui.Chart.Chart;
            if (foundChart == null) return;
    
            foreach ( IndicatorBase indi in foundChart.ActiveChartControl.Indicators)
                Print(indi.Name + " " + indi.State);
        }));
    }
    Please let us know if there is anything else we can do to help.
    JimNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by TraderG23, 12-08-2023, 07:56 AM
    9 responses
    382 views
    1 like
    Last Post Gavini
    by Gavini
     
    Started by oviejo, Today, 12:28 AM
    0 responses
    1 view
    0 likes
    Last Post oviejo
    by oviejo
     
    Started by pechtri, 06-22-2023, 02:31 AM
    10 responses
    125 views
    0 likes
    Last Post Leeroy_Jenkins  
    Started by judysamnt7, 03-13-2023, 09:11 AM
    4 responses
    59 views
    0 likes
    Last Post DynamicTest  
    Started by ScottWalsh, Yesterday, 06:52 PM
    4 responses
    36 views
    0 likes
    Last Post ScottWalsh  
    Working...
    X