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

Live or Demo account?

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

    Live or Demo account?

    Hello,

    is there a way to detect if account my strategy is connected to is Live mode or simulation mode?

    Thanks for help

    Paul

    #2
    Hello kujista,

    Thank you for your post.

    The Account property has the account object a strategy is running on.

    Below is a link to the help guide.​

    https://ninjatrader.com/support/helpGuides/nt8/strategy_account.

    Please let us know if you have any further questions.
    Gaby V.NinjaTrader Customer Service

    Comment


      #3
      Thank you for response. Could you please tell me how exactly i know that we are running on live account?

      Comment


        #4
        Hello kujista,

        There is no way for the strategy to know whether the accounts selected are simulation accounts or live accounts, so you would need to get the Account.Name and check if it is the Sim101 account, for example.

        if (Account.Name == "Sim101")
        Print("this is a simulation account);

        Please let us know if you have any further questions.
        Gaby V.NinjaTrader Customer Service

        Comment


          #5
          This is pitty :-/ I use this code
          Code:
          if (account.Name == "Playback101")
          
          {
          
          tradingMode = EnumModeTrading.Replay;
          
          } else if (account.Name.Contains("DEMO"))
          
          {
          
          tradingMode = EnumModeTrading.Backtest;
          
          } else if (int.TryParse(account.Name, out accNr))
          
          {
          
          tradingMode = EnumModeTrading.Live;
          
          }
          ​
          trying to detect live account, is there a way get formats of account names? i mean especially for live accounts? According to account type - live or demo i do some logic in sending notification mails. different levels of loging trades.. etc.

          Comment


            #6
            Hello kujista,

            Live account names are determined by your broker and do not have a set format. I suggest getting the account names of all your live accounts, then you can check them similarly to checking if the Account.Name == "Sim101".

            Please let us know if you have any further questions.
            Gaby V.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Critical_Catch, Today, 08:35 AM
            0 responses
            8 views
            0 likes
            Last Post Critical_Catch  
            Started by smartromain, Today, 02:52 AM
            0 responses
            18 views
            0 likes
            Last Post smartromain  
            Started by Marklhc1988, 04-19-2023, 11:11 AM
            12 responses
            580 views
            1 like
            Last Post victor68133  
            Started by nicthe, Yesterday, 02:58 PM
            1 response
            17 views
            0 likes
            Last Post nicthe
            by nicthe
             
            Started by percy3687, 05-17-2024, 12:28 AM
            3 responses
            38 views
            0 likes
            Last Post percy3687  
            Working...
            X