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

Custom PerformanceMetric: How to access Order data from cancelled orders?

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

    Custom PerformanceMetric: How to access Order data from cancelled orders?

    Hello,

    I am attempting to use the stop price of a cancelled stop order to perform calculations in a custom performance metric. I am stumped on how to retrieve this data in the Performance Metric class. In theory, this class includes an array of order strings since it is using NinjaTrader.Gui.TradePerformance and I can see all the orders in the Trade Performance window. I have made some attempts to access OrdersGrid and OrdersGridEnty but I can't figure it out.

    The basic data gap I'm trying to solve is on profitable trades, the trade.Entry.Order.StopPrice and the trade.Exit.Order.StopPrice are both zero based on the managed approach I generally use to enter trades and exit trades.

    General entry code from strategy:
    SetProfitTarget(Name + "Entry" + counter, CalculationMode.Price, ProfitTarget);
    SetStopLoss(Name + "Entry" + counter, CalculationMode.Price, MIN1[0], false);
    EnterLong(1, Name + "Entry" + counter);

    General exit code from strategy:
    ExitLong(1, @"partial" + partials, Name + "Entry" + partials);

    This all works to my satisfaction in execution, and when a partial ExitLong executes, the associated StopLoss order is cancelled. However, I would like to record and use that StopLoss price to do calculations in a custom Performance Metric.

    I cannot call OnOrderUpdate() from a custom Performance Metric, so I figured the next best thing is to access data in the OrderGrid or OrderGridEntry arrays.

    Do you have any coding techniques to properly access the array of string data in the NinjaTrader.Gui.TradePerformance OrderGrid or OrderGridEntry from the PerformanceMetric class?

    Any ideas would be appreciated. ​

    #2
    Hello whizkpm,

    That would not be possible with the information passed to the performance metric. The metric only knows about the Trade which is the paired entry + exit. It wouldn't make sense for the Trade to also include any cancelled target information because then you have 3 orders being paired as a trade when only 2 of the orders filled.

    The only workaround I can think of would be If you use a constant offset for both the target and stop. You could calculate in reverse, for example if the target filled at 10 ticks from entry price you could subtract 20 ticks to get the 10 tick offset stop price.



    JesseNinjaTrader Customer Service

    Comment


      #3
      Jesse,

      Thanks for your response. If anyone else tries to do something similar, I ended up making a custom Exit Signal Name in my strategy which included the value of the unexecuted stop order. In the custom Performance Metric, I manipulated the trade.Exit.Order.Name string to parse out the stop price and then converted to a double variable for calculations in the custom Performance metric.

      I would like to request that OnOrderUpdate() and/or access to the OrderGrid information is made available in the custom Performance Metric class. I believe it is fairly common concept to measure trade performance by the amount of money at risk whether you were profitable or not. This feature would allow the Performance Metric class to be more powerful.

      Thanks for your time,
      Kevin

      Comment


        #4
        Hello Kevin,

        This request is being tracked with ID # SFT-5877.

        Please note, we receive many requests and cannot reasonably implement all requested features or changes. Interest is tracked internally and if enough interest is tracked, it would be weighed against how feasible it would be to make those changes to consider implementing, so we cannot offer an ETA or promise of fulfillment.

        When new features are implemented, they will be listed in the Release Notes page of the Help Guide. The ID number may be different than the internal feature request tracking ID, but the description of the feature will let you know if that feature has been implemented.

        Release Notes - https://ninjatrader.com/support/help...ease_notes.htm
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Thanks for adding it to the list!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by wzgy0920, 02-22-2024, 01:11 AM
          5 responses
          32 views
          0 likes
          Last Post wzgy0920  
          Started by wzgy0920, Yesterday, 09:53 PM
          2 responses
          49 views
          0 likes
          Last Post wzgy0920  
          Started by Kensonprib, 04-28-2021, 10:11 AM
          5 responses
          191 views
          0 likes
          Last Post Hasadafa  
          Started by GussJ, 03-04-2020, 03:11 PM
          11 responses
          3,230 views
          0 likes
          Last Post xiinteractive  
          Started by andrewtrades, Today, 04:57 PM
          1 response
          14 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Working...
          X