Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Managing CashFlow in Strategy Backtest

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

    Managing CashFlow in Strategy Backtest

    Hi,

    I am making some backtest with a strategy that I've just implemented. But I am having a hard time managing the cash flow. Is there a built-in way of doing this? For example, I start my strategy with $1000,00 and I can't let my "account" became negative!!

    Thanks!

    #2
    Hello PrimoItch,

    Thank you for your post.

    When backtesting there is no means to set the values of the account. You would instead implement internal calculations in your strategy to calculate and track your own custom values for the desired account values.

    For example:

    Initial Capital = your backtest starting value.
    UnrealizedPnL = (Position.GetUnrealizedProfitLoss(PerformanceUnit. Currency, Close[0]));
    CumNetPnL = SystemPerformance.AllTrades.TradesPerformance.Curr ency.CumProfit;
    CurrentCapital = InitialCapital + UnrealizedPnL + CumNetPnL

    Then you could update these on each pass through On Bar Update and modify the logic from this example to stop the strategy after a set loss or profit amount:



    Please let us know if we may be of further assistance to you.

    Comment


      #3
      This works when backtesting a single instrument, but when backtesting a basket of instruments, how can you keep track of your total cumulative profit of all instruments combined? For example, in OnBarUpdate() before entering a trade, I'd like to know the current cumulative profit of all instruments at that bar.

      Comment


        #4
        Hello bkonia,

        Thank you for your reply.

        Are you talking about using the Strategy Analyzer to run backtests on an entire instrument list? This wouldn't be possible as the backtests do not run simultaneously and each run of the strategy is a separate instance of the strategy.

        Please let us know if we may be of further assistance to you.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        116 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        61 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        40 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        43 views
        0 likes
        Last Post TheRealMorford  
        Started by Mindset, 02-28-2026, 06:16 AM
        0 responses
        82 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Working...
        X