• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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:

    https://ninjatrader.com/support/help...nce_user_d.htm

    Please let us know if we may be of further assistance to you.
    Kate W.NinjaTrader Customer Service

    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.
        Kate W.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Oliver81594, Today, 04:09 AM
        0 responses
        1 view
        0 likes
        Last Post Oliver81594  
        Started by Nate G, Yesterday, 05:27 PM
        1 response
        12 views
        0 likes
        Last Post MojoJojo  
        Started by Mindset, Yesterday, 10:35 PM
        1 response
        6 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by habibalex, Yesterday, 08:19 PM
        1 response
        11 views
        0 likes
        Last Post NinjaTrader_Marco  
        Started by lakersfan, Yesterday, 07:53 PM
        0 responses
        10 views
        0 likes
        Last Post lakersfan  
        Working...
        X