Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Real-time risk management

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

    Real-time risk management

    Apologies if this has been asked and answered previously -- I couldn't find it if it was.

    Does anyone have working NinjaScript code to do the following (supported or unsupported methods welcome):
    • Identify base currency of the account
    • Identify available account balance
    • Calculate the available margin at any time in real-time
    • Calculate the value per pip in real-time for any combination of circumstances:
      • Trading any currency pair (e.g. EURCHF)
      • Account in any base currency (e.g. GBP)
      • Going long or short
      • Any account configuration: one pip, half pip or tenth pip
    • Calculate stop loss parameters for any order where any of the following may be fixed or variable:
      • Risk amount in base currency of the account or any other currency
      • Stop loss size in pips
      • Going long or short
      • Number of units to buy or sell short (i.e. fractional lotsize, not rounded)
    • Calculate PnL accurately in real-time for any position
    • Calculate take profit parameters for any position where any of the following may be fixed or variable:
      • Profit amount in base currency of the account or any other currency
      • Take profit size in pips
      • Long or short position
      • Number of units to sell or buy to cover (i.e. fractional lotsize, not rounded)

    Whilst I am aware of a number of NinjaScript data structures and methods that can determine some of these things, there are quite a few things I do not know, including some uncertainty on the formulae to use. I am looking for comprehensive code to implement all these things. I'm happy to consolidate code snippets, so long as the overall effect is to produce the above in a robust, accurate (preferably elegant) method. I will repost any end-result code.



    Many thanks!
    Multi-Dimensional Managed Trading
    jeronymite
    NinjaTrader Ecosystem Vendor - Mizpah Software

    #2
    Hello jeronymite,

    The only supported account values that you can get is "Buying Power", "Cash Value", and "Realized Profit and Loss" as demonstrated in the following Help Guide link.



    As for the Stop Loss it would be whatever you have set it to before your entry order was called. I am not aware of any method to check this but you may set the Stop Loss value before your entry order once again to ensure that the Stop Loss value is going to be what you would like it to be set to. The same thing can be done with the Profit target.

    SetStopLoss: http://www.ninjatrader.com/support/h...etstoploss.htm

    Profit Target: http://www.ninjatrader.com/support/h...ofittarget.htm
    JCNinjaTrader Customer Service

    Comment


      #3
      Thanks, JC.

      Fortunately, I was aware of all that, but I appreciate your response nonetheless.

      What I need is as described originally. Any insights or even unsupported ways to achieve this would be greatly appreciated. Anything unsupported obviously comes with a strong CAVEAT to "use at your own risk". I fully understand that, as I currently employ a variety of unsupported (but legitimate) data structures and methods, so I am very familiar with the disclaimer and have no problem with that.

      Any further advice/assistance (from any reader) would be very much appreciated indeed!

      Thanks!
      Multi-Dimensional Managed Trading
      jeronymite
      NinjaTrader Ecosystem Vendor - Mizpah Software

      Comment


        #4
        ... and one further comment after the fact, which I should have mentioned before.

        Obviously, when any requests of this nature are made and the answer is "not supported" or "not possible at this time" or "no/not ...", may I strongly urge NinjaTrader to add the request automatically to the list of requested features for consideration in future versions of NinjaTrader, please? You may already do this (I'm impressed by NinjaTrader's diligence in this matter), but just in case, I offer this recommendation for your earnest consideration.

        Many thanks! Very much looking forward to NT8's arrival!
        Multi-Dimensional Managed Trading
        jeronymite
        NinjaTrader Ecosystem Vendor - Mizpah Software

        Comment


          #5
          Hello jeronymite,

          I will forward your suggestions to our development team for consideration on future releases of NinjaTrader and leave this thread open for other members to contribute their experiences.
          JCNinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          634 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          364 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          105 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          567 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          568 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X