Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to get Account properties from the code?

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

    How to get Account properties from the code?

    Hello!

    I am trying to update an old Turtle strategy that I found on this forum.
    After reading Van K. Tharps thoughts on money management, I have decided to code the strategy to risk 2 percent of total capital per order.

    My question is, how do I get the value of the account size?
    Is there an Ninja Trader API somewhere? (I looked, but could'nt find one)

    I am going to try to implement the following:
    1. Get the actual ATR (14 days)
    2. Set a stoploss Close[0] - 2 * ATR
    3. Calculate (2 percent of total capital) / 2 * ATR = Number of shares
    4. Place the order.

    Wish me luck

    Ps. At what performance rating do you guys consider yourself to have a good and sound strategy?

    Thanks!

    #2
    Hi bebjo, there is a method called GetAccountValue() that you can use for this purpose. It only works in real-time though, so you can't backtest it - http://www.ninjatrader.com/support/h...countvalue.htm.

    As for the performance rating, I would say once you have a strategy that has a profit factor greater than 1.7 or 1.8ish (including a 1 or 2 tick slippage), you can start working on refining it and running it real-time to see how it performs.
    AustinNinjaTrader Customer Service

    Comment


      #3
      Hi Austin,

      I just have a quick follow up question about performance.
      You mentioned that I could settle for 1.7 - 1.8 in performance rating.
      Is that measured by best possible timeframe or how do I choose what time segment to measure.
      2008-2010 Gives a different rating than 2006-2008 for instance.

      Hope you understand what I mean
      Thanks!

      Comment


        #4
        bebjo, just to clarify, nothing I say here should be construed as trading advice. A ~1.8 profit factor means that the profits are 1.8 times the losses. The profit factor you decide to start trading at is entirely up to you. I'm just saying a higher profit factor means a more profitable strategy, but not for every case.

        You will also have to decide what timeframe you want to optimize your strategy on, as well as the duration.
        AustinNinjaTrader Customer Service

        Comment


          #5
          Also, you can find the reference manual for the NinjaScript API in the NinjaScript section of the help guide - http://www.ninjatrader.com/support/h...nt7/index.html.
          AustinNinjaTrader Customer Service

          Comment


            #6
            Thanks for the link to the API Austin.

            But I am afraid I did'nt get much clearer on the time frame issue.
            Backtesting gives different profit factors from different timeframes.

            Should I choose worst result as my base or my best result?

            Lets say I get a profit factor of 1.4 between 2008-2011 and 2.0 between 2005-2008
            How do I know it's good enough?

            Or am I just over analyzing?

            Thank you again Austin!

            Comment


              #7
              bebjo,

              This would depend on your personal tolerance to your profit factor and we couldn't make any recommendations further than what has been suggested so far.
              MatthewNinjaTrader Product Management

              Comment


                #8
                Ok, I understand.

                Thanks!

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                633 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