• 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

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

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by superkolleech, Today, 12:46 AM
                1 response
                11 views
                0 likes
                Last Post MojoJojo  
                Started by davidwade, Today, 02:51 AM
                0 responses
                2 views
                0 likes
                Last Post davidwade  
                Started by aviat72, 04-26-2020, 09:41 PM
                10 responses
                91 views
                0 likes
                Last Post kissandfly  
                Started by healthooa, Today, 01:28 AM
                0 responses
                7 views
                0 likes
                Last Post healthooa  
                Started by harjinderjit, Yesterday, 08:24 PM
                0 responses
                20 views
                0 likes
                Last Post harjinderjit  
                Working...
                X