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 llanqui, Today, 03:53 AM
      0 responses
      3 views
      0 likes
      Last Post llanqui
      by llanqui
       
      Started by burtoninlondon, Today, 12:38 AM
      0 responses
      10 views
      0 likes
      Last Post burtoninlondon  
      Started by AaronKoRn, Yesterday, 09:49 PM
      0 responses
      14 views
      0 likes
      Last Post AaronKoRn  
      Started by carnitron, Yesterday, 08:42 PM
      0 responses
      11 views
      0 likes
      Last Post carnitron  
      Started by strategist007, Yesterday, 07:51 PM
      0 responses
      14 views
      0 likes
      Last Post strategist007  
      Working...
      X