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

Heavy CPU and memory usage using Dispatcher.InvokeAsync

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

    Heavy CPU and memory usage using Dispatcher.InvokeAsync

    I finally find a nice solution to my button issues but it is eating up computer resources. I did all the development on my desktop which has a good process or and 32gb ram and did notice a little lag in the strategy opening in the chart but then tried to use it on my VPS computer and it basically just hangs up or crashes it. Wondering if I am doing something wrong or there is another method that doesn't kill a computer. as soon as I comment out this code the computer and strategy are normal again.

    Dispatcher.InvokeAsync((() =>
    {
    if(golongButton != null && goshortButton != null && exitButton !=null)
    {
    if(Position.MarketPosition == MarketPosition.Long)
    {
    golongButton.Content = "Go Long";
    golongButton.Name = "GoLongButton";
    golongButtonClicked = false;
    longEnable = false;
    }
    else if (Position.MarketPosition == MarketPosition.Short)
    {
    goshortButton.Content = "Go Short";
    goshortButton.Name = "GoShortButton";
    goshortButtonClicked = false;
    shortEnable = false;
    }
    else if (Position.MarketPosition == MarketPosition.Flat)
    {
    exitButton.Content = "Close All";
    exitButtonClicked = false;
    exitEnable = false;
    }

    }}));

    #2
    Hello set2win,

    Thanks for your post.

    Is this code being used frequently?

    Are you able to move that code to be in the button event instead of in OnBarUpdate()? If so, do you see improved performance when the code is moved?

    I look forward to assisting further.
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      I added If (State == State.RealTime) prior to this Dispatcher as it is only needed to set the button state in realtime. This fixed the problem.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by JoMoon2024, Today, 06:56 AM
      0 responses
      6 views
      0 likes
      Last Post JoMoon2024  
      Started by Haiasi, 04-25-2024, 06:53 PM
      2 responses
      19 views
      0 likes
      Last Post Massinisa  
      Started by Creamers, Today, 05:32 AM
      0 responses
      6 views
      0 likes
      Last Post Creamers  
      Started by Segwin, 05-07-2018, 02:15 PM
      12 responses
      1,786 views
      0 likes
      Last Post Leafcutter  
      Started by poplagelu, Today, 05:00 AM
      0 responses
      3 views
      0 likes
      Last Post poplagelu  
      Working...
      X