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

SystemPerformance Calculate trades without an AccountSelector SelectedAccount

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

    SystemPerformance Calculate trades without an AccountSelector SelectedAccount

    I am trying to access a set of trades that an account has made over a current session, but keep getting an error or crash in my code. Most of all this seems to occur with a live account and not any sim accounts.

    I am referencing this code https://ninjatrader.com/support/foru...ns#post1090999

    In my AddOn there is an AccounSelector UI element that lets me select the account I want, but I would like to generalize the AddOn to monitor all accounts and not just the specific account that has been selected by the selector.

    if I use just the SelectedAccount from the AccountSelector the code works as intended.

    Code:
    var myPositions = SystemPerformance.Calculate(accountSelector.SelectedAccount.Executions);
    But if I want to calculate the trades of a non selected account by setting the AccountSelector.DesiredAccount and run the same code, I will get an error "Unhandled exception: Object reference not set to an instance of an object". Most of all this happens with setting a live account as the DesiredAcccount. Also if I set the account to the live account and shutdown and open NT, NT will automatically crash when connecting.

    Click image for larger version  Name:	Unhandled execption.PNG Views:	0 Size:	5.0 KB ID:	1130952

    Code:
    accountSelector.DesiredAccount = "Sim101";
    var myPositions = SystemPerformance.Calculate(accountSelector.SelectedAccount.Executions); // Up to this point works
    accountSelector.DesiredAccount = "****|ExampleLiveAccount";
    var myPositions = SystemPerformance.Calculate(accountSelector.SelectedAccount.Executions); // This line will cause a error or crash
    Is there any way to get Executions on an Account without having to use an AccountSelector? Something I can get info for an account by just passing in the account name?

    Or another option would be a better way to force AccountSelector to change to a new account in code?
    Last edited by archieoi; 12-06-2020, 02:57 PM.

    #2
    Hello archieoi,

    The SystemPerformance would not be available to addons. This is something that was designed for NinjaScript Strategies.

    Is this in a Strategy or is this actually an addon and not a strategy?

    The .DesiredAccount property is not documented and I would not be able to assist with this. The Strategy should be assigning the Account the orders are submitted to, but the SystemPerformance would not be the account performance and instead would be the strategy performance which is separate from the account performance.
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by f.saeidi, Today, 01:32 PM
    1 response
    2 views
    0 likes
    Last Post NinjaTrader_Erick  
    Started by mmckinnm, Today, 01:34 PM
    0 responses
    3 views
    0 likes
    Last Post mmckinnm  
    Started by traderqz, Today, 12:06 AM
    9 responses
    16 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by kevinenergy, 02-17-2023, 12:42 PM
    117 responses
    2,766 views
    1 like
    Last Post jculp
    by jculp
     
    Started by Mongo, Today, 11:05 AM
    5 responses
    15 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Working...
    X