Announcement

Collapse
No announcement yet.

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.

    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.

        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.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            649 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            370 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            109 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            574 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            576 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X