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

Question on Account Size and Backtesting

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

    Question on Account Size and Backtesting

    I determine the lot-size (# of shares / contracts) based on stop-loss level and risk per trade. The risk per trade is derived from the account size / cash balance.
    E.g. if my account size is $10000 and risk per trade is 2%, I would risk $200 on each trade. Based on my stop-loss and tick-value, the lot-size is determined accordingly.

    But in back-testing it seems the values for cash balance etc are returned as 0.

    I read about using AccountSize - but instead of hard-coding I would like it to be set by the user. (E.g. user sets trading capital to say $10,000 through properties / settings).

    How do I determine whether a strategy is running in back-testing mode ?

    Any other suggestions to my problem ?

    #2
    adheer, thanks for the post. You can generally set an account size for backtesting for that purpose -



    For checking if you're in backtesting, you could check for the Account.Name return to give you the "Backtest" account string.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Betrand,

      Thank you for the reply.

      The problem with AccountSize is that it is not useful when calculating lot-size via code within the strategy. It does not update dynamically when positions are opened / closed.

      This property does not update dynamically for access to updated account size values. It is dynamic for order sizing only. Should you want a dynamically updating account size you will need to track this with your own variables.
      If I want to find out how my strategy performed with $10,000 initial capital and a custom position sizing method based on account equity there is no simple way. Writing additional code to calculate account size based on open and realized P/L of historical trades does not make sense.
      We end up have two code-paths - one for live trading and one for back-testing.

      IMHO, the account size should have been a basic feature available during back-testing.

      Comment


        #4
        Thanks for the thoughtful feedback provided to us, that's correct in understanding. A dynamically updating format is on our feedback lists for future considerations, I'm making sure a vote on your behalf gets added in as well to track.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Trade Performance

          Does the lastTrade functionality work in backtesting if you wanted to calculate your own running account size?

          Comment


            #6
            Yes, the Performance classes would report in backtesting as well so you could use it to cumulate.
            BertrandNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by ETFVoyageur, 05-07-2024, 07:05 PM
            6 responses
            50 views
            0 likes
            Last Post ETFVoyageur  
            Started by Klaus Hengher, Yesterday, 03:13 AM
            2 responses
            15 views
            0 likes
            Last Post Klaus Hengher  
            Started by Sebastian - TwinPeaks, Yesterday, 01:31 PM
            2 responses
            13 views
            0 likes
            Last Post Sebastian - TwinPeaks  
            Started by wbennettjr, 07-15-2017, 05:07 PM
            16 responses
            2,533 views
            1 like
            Last Post eladlevi  
            Started by Human#102, Yesterday, 09:54 AM
            2 responses
            8 views
            0 likes
            Last Post Human#102  
            Working...
            X