Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Risk data

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

    Risk data

    Hello,
    I'm searching how to access to the risk data of current instrument (main instrument). This data is in Risk Window (using Risk Window) but I don't find how to access programmatically in the scripts, AccountItem is the closest thing but I don't know if it's the same.

    Is it available?


    Thanks in advance.

    #2
    Hello ruina,

    Thank you for your post.

    AccountItem is the only way to access this data.

    The Risk template is applied to a Simulation account, whose account values can then be accessed via AccountItem.

    Gaby V.NinjaTrader Customer Service

    Comment


      #3
      Sorry but I don't find the information about margins of instrument (initial, intraday...).
      I've tried with

      Code:
      account = Account.All.FirstOrDefault(a => a.Name == "Sim101");
      account.GetAccountItem(AccountItem.IntradayMargin, Currency.Euro).Value;
      and the value is 0.
      With Instrument object I have not found any property.
      Last edited by ruina; 03-23-2025, 02:20 PM.

      Comment


        #4
        Hello ruina,

        Has an order been placed to the Sim101 account at the time you're trying to retrieve this value?

        I am not able to reproduce with the below test script.
        Attached Files
        Gaby V.NinjaTrader Customer Service

        Comment


          #5
          Hello,
          Yes, an order has been placed. I'm doing a backtest and many orders are placed.

          The
          myAccount = Account.All.FirstOrDefault(a => a.Name == "Sim101");
          returns an object, it is not null but it doesn't enter never into AccountItem_Update to print the initial margin.

          Comment


            #6
            Hi ruina,

            I'm guessing this is fully unsupported by NinjaTrader for obvious reasons but what you're looking for is the non-browsable NinjaTrader.Cbi.Risk class.
            You can retrieve a risk template and then access the NinjaTrader.Cbi.InstrumentRisk data using Instrument.MasterInstrument.


            Code:
            NinjaTrader.Cbi.Risk riskTemplate = Risk.Get(riskTemplateName);
            NinjaTrader.Cbi.InstrumentRisk riskData = riskTemplate.ByMasterInstrument[masterInstrument];
            double mxMargin= riskData.MaintenanceMargin;
            Hope that's helpful.

            Comment


              #7
              Hello ruina,

              This will not work in backtest, no orders are actually placed to the account in backtest. This will only work in real-time.

              There is no supported means to get this in backtest unfortunately, you could try the unsupported solution provided by CDXTrader.
              Gaby V.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Mindset, Today, 12:46 AM
              0 responses
              3 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by moneymaster, Today, 12:38 AM
              0 responses
              2 views
              0 likes
              Last Post moneymaster  
              Started by WilsonFoster, Yesterday, 11:35 PM
              0 responses
              8 views
              0 likes
              Last Post WilsonFoster  
              Started by MiCe1999, Yesterday, 09:26 PM
              0 responses
              14 views
              0 likes
              Last Post MiCe1999  
              Started by connorlmarble, Yesterday, 08:25 PM
              0 responses
              10 views
              0 likes
              Last Post connorlmarble  
              Working...
              X