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 Mindset, 04-21-2026, 06:46 AM
        0 responses
        93 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by M4ndoo, 04-20-2026, 05:21 PM
        0 responses
        138 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by M4ndoo, 04-19-2026, 05:54 PM
        0 responses
        68 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by cmoran13, 04-16-2026, 01:02 PM
        0 responses
        123 views
        0 likes
        Last Post cmoran13  
        Started by PaulMohn, 04-10-2026, 11:11 AM
        0 responses
        73 views
        0 likes
        Last Post PaulMohn  
        Working...
        X