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

Modify SystemPerformance.AllTrades.TradesPerformance.Currency.CumProfit

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

    Modify SystemPerformance.AllTrades.TradesPerformance.Currency.CumProfit

    For a CFD strategy I need to reduce the SystemPerformance.AllTrades.TradesPerformance.Curr ency.CumProfit after each trade by Interest and Tax.
    How can I modify Value?
    Thanks

    #2
    Hello starcd,

    Thanks for your post.

    This value will be calculated from the TradePerformance object after a new trade is added to the Trades collection. I would not recommend modifying this value and would instead suggest creating a private strategy variable for "CumProfitAdjusted" and to then update this variable after a trade closes. I have included a snippet that can describe how this can be accomplished.

    Code:
    private int TradesCount = 0;
    private double CumProfitAdjusted;
    private double TaxAndInterest = -5;
    
    protected override void OnExecutionUpdate(Cbi.Execution execution, string executionId, double price, int quantity, 
        Cbi.MarketPosition marketPosition, string orderId, DateTime time)
    {
        if (SystemPerformance.AllTrades.Count > TradesCount)
        {
            TradesCount = SystemPerformance.AllTrades.Count;
            CumProfitAdjusted += SystemPerformance.AllTrades[TradesCount-1].ProfitCurrency + TaxAndInterest;
            Print(CumProfitAdjusted);
        }
    }
    Please let me know if I can be of further assistance.
    JimNinjaTrader Customer Service

    Comment


      #3
      Hello Jim,

      thanks a lot.

      I want to make the strategy analyser reflect the interest / tax either in the Trade Profit or the Cum. net Profit (like the Slippage - but at the end of the trade..). Is there a way to manipulate the TradePerformance object? That would help a lot.

      Comment


        #4
        Hello starcd,

        I would instead suggest creating a custom performance metric in this case.

        Custom performance metrics can be enabled from the Control Center under Tools > Options > General menu. An example performance metric SampleCumProfit is included with the platform.

        Documentation on performance metrics can be found here - https://ninjatrader.com/support/help...ce_metrics.htm

        Let us know if you have any additional questions.
        JimNinjaTrader Customer Service

        Comment


          #5
          Hallo Jim,

          thank's.

          I understand. But that means that I have to write own custom performance metrix for all the Functions that are already there:
          E.g. Summary: NetProfit, Drawdown, Profitfactor, Sharp ratio etc. because they do not reflect the changes concerning Interest andTax.
          The Trades and Analyser Displays the same...

          It would save much time if I could have access to the TradePerformance object.

          Comment


            #6
            Hello starcd,

            SystemPerformance.AllTrades.TradesPerformance.Curr ency.CumProfit is not read only so you could modify it if you wish. I would not advise this as this would not be a supported use of TradePerformance. I have tested adding to CumProfit from OnExecutionUpdate and have observed the modifications in the Strategy Analyzer. You are welcome to proceed experimenting with these adjustments for AllTrades.TradesPerformance as well as other Trade Collections in SystemPerformance and you may get the results you are looking for, but please understand that this would not be a something we can provide further direction with.

            Code:
            protected override void OnExecutionUpdate(Cbi.Execution execution, string executionId, double price, int quantity, 
                Cbi.MarketPosition marketPosition, string orderId, DateTime time)
            {
                SystemPerformance.AllTrades.TradesPerformance.Currency.CumProfit += 5000000;
            }
            You may also wish to write back here with your findings so other community members trying to attempt the same can have some further direction.

            If you have any other inquiries please don't hesitate to open a new ticket.
            JimNinjaTrader Customer Service

            Comment


              #7
              Thank's a lot Jim!

              Comment


                #8

                Hi Jim,
                changing SystemPerformance.AllTrades.TradesPerformance.Curr ency.CumProfit is not reflected by all other calculations eg. MaxDrawdown, ProfitFactor...
                The fun comes when you write to execution.Commission. At last I was able to put in all my individual Trade Costs. Not that static like using Commission Templates... These Costs are substracted from the Profit Column of the strategie analyser and then considered by all other calculations. Hooray! protected override void OnExecutionUpdate(Cbi.Execution execution, string executionId, double price, int quantity, Cbi.MarketPosition marketPosition, string orderId, DateTime time) { //First Calculate your individual TradeCost e.g. Comission, Tax, Dividents, Interest... if(BarsSinceExitExecution()==0) { execution.Commission +=TradeCost; } } Thank's again for pointing me in the right direction.

                edit: The Summary page does not update, but the Trades and Analyse pages.
                If someone find a way for that let me know.
                Last edited by starcd; 01-19-2020, 04:59 PM.

                Comment


                  #9
                  Hey starcd,

                  I know this might not be the perfect solution, but maybe it would get you pretty close? I've used the Slippage value in the Strategy Analyzer to estimate some of those things. You'd need to change the value based on the instrument to reflect the correct dollar value per tick etc but the slippage is reflected in both Summary and Analysis pages.

                  One important note, the NT8 guide here says the following about Slippage: Set the amount of slippage in ticks to apply to market / stop market / Market-if-touched order executions (default is 0)

                  This then seems like you'd need to use some type of market orders which might not work well for you. Another note is that if you use a Slippage of 4 ticks, it will apply to the entry and exit, meaning 8 ticks per trade.

                  Hopefully that helps!

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Skifree, Today, 03:41 AM
                  1 response
                  2 views
                  0 likes
                  Last Post Skifree
                  by Skifree
                   
                  Started by usazencort, Today, 01:16 AM
                  0 responses
                  1 view
                  0 likes
                  Last Post usazencort  
                  Started by kaywai, 09-01-2023, 08:44 PM
                  5 responses
                  603 views
                  0 likes
                  Last Post NinjaTrader_Jason  
                  Started by xiinteractive, 04-09-2024, 08:08 AM
                  6 responses
                  23 views
                  0 likes
                  Last Post xiinteractive  
                  Started by Pattontje, Yesterday, 02:10 PM
                  2 responses
                  23 views
                  0 likes
                  Last Post Pattontje  
                  Working...
                  X