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

StartAtmStrategy missing trades

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

    StartAtmStrategy missing trades

    Hi,

    Have a strategy that uses StartAtmStrategy(Via custom button click):

    Code:
    private void OnBuyLongClick(..)
    {
         Order eo = Account.CreateOrder(Instrument, OrderAction.Buy, OrderType.Limit, OrderEntry.Manual, TimeInForce.Day, 3, limitPrice, 0, string.Empty, "Entry", Core.Globals.MaxDate, null);
         atmStrategy = NinjaTrader.NinjaScript.AtmStrategy.StartAtmStrategy(ATMLongMan, eo);
         Print(atmStrategy.IncludeTradeHistoryInBacktest); //False
    }
    Then, in OnBarUpdate, trying to calc Unrealized PnL and Realized PnL.
    But there are never any trades.
    All the expected executions are there (ATM entry executions and ATM exit executions via atm targets or atm stops)

    Code:
    OnBarUpdate(..)
    {
         if (atmStrategy != null)
         {
              OrderState os = atmStrategy.InitialEntryOrder.OrderState;
              int posQuantity = 0;
              if (atmStrategy.Positions != null)
              {
                   // Only check Position property if Positions != null, otherwise CRASH
                   posQuantity = atmStrategy.Position.Quantity;
              }
    
              // Trade was filled, but we no longer have a position, so it is complete, and we should have trades
              if ((os == OrderState.Filled || os == OrderState.PartFilled) && posQuantity == 0)
              {
                     Print("ATM Trades Count: " + atmStrategy.SystemPerformance.AllTrades.Count());
                     Print("ATM Realized PnL " + atmStrategy.SystemPerformance.RealTimeTrades.Trade sPerformance.Ticks.CumProfit);
                     Print("Atm Executions: " + atmStrategy.Executions.Count);  //In my test, all the expected executions open and close executions are present
              }
    If I run a TradePerformanceReport for the day I used the ATM, I do see the expected trades, with a strategy name column that matches the name of the ATM(ATMLongMan) that I pass to startAtmStrategy()

    Any ideas ?
    Anything I can call with a list of executions that will calc realized PnL ? I know I can do it by hand

    BTW, AtmStrategyCreate() and the ATM Monitoring calls work as expected, but that has other limitations( no way to resume monitoring for running ATMs if the strategy stops and has to be restarted),








    #2
    Hello michelm,

    Thank you for your post.

    Unfortunately, this not supported, and we can't offer any direction for using SystemPerformance with ATMs, only with NinjaScript strategies.

    That being said, if you can monitor executions you could try to pair them together in trades. You might have some luck trying to build a TradeCollection from there to get TradePerformance, but that would be very much DIY.

    One of my colleagues suggested perhaps this script I've attached below could be of use to explore your unsupported idea.

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

    Comment


      #3
      Originally posted by NinjaTrader_Kate View Post
      Hello michelm,

      Thank you for your post.

      Unfortunately, this not supported, and we can't offer any direction for using SystemPerformance with ATMs, only with NinjaScript strategies.

      That being said, if you can monitor executions you could try to pair them together in trades. You might have some luck trying to build a TradeCollection from there to get TradePerformance, but that would be very much DIY.

      One of my colleagues suggested perhaps this script I've attached below could be of use to explore your unsupported idea.

      Please let us know if we may be of further assistance to you.
      Thanks for the info, I do appreciate the quick response

      Just because something is broken, IMHO, it should not be classified as "unsupported". This seems to be a reoccurring issue of late. At least now Ninjatrader has seemed to drop the pretense of creating bug reports with a ticket ID that will never be worked.

      I'd say it's broken. As far as I know, there is no logical reason why the trades are not tracked in this case...the code to produce trades out of executions is already in there somewhere, I guess.....

      I'm using documented calls here.

      *Nothing against NinjaTrader_Kate, you do a great job, comments are directed at the Company as a whole...
      Last edited by michelm; 02-19-2021, 03:42 PM.

      Comment


        #4
        Hello michelm,

        Thank you for your reply.

        I understand your feelings, however, there is no documentation that recommends use of SystemPerformance with ATM strategies. If you found documentation that says this is possible, please let us know.

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

        Comment


          #5
          Originally posted by NinjaTrader_Kate View Post
          Hello michelm,

          Thank you for your reply.

          I understand your feelings, however, there is no documentation that recommends use of SystemPerformance with ATM strategies. If you found documentation that says this is possible, please let us know.

          Please let us know if we may be of further assistance to you.
          To me, that's a disappointing response. Sometimes I feel like your company is losing the vision and drive that made Ninjatrader one of the best platforms out there, hands down.

          Instead of asking me why I'm trying to do what I'm trying to do, the interest seems to be more oriented in defending some documentation semantics. Perhaps I'm working on a pain point that I get a lot of requests around, and addressing would be really cool and add a little more flex to NT, addressing the issue could benefit both me and Ninjatrader.

          If the standard is that every interaction between the various API pieces has to be explicitly spelled out in the documentation, like your implying...well that's just a disappointing position for Ninjatrader to take, but it's all good, I guess you "win", you are correct, nowhere in the documentation does it state that trades should be tracked when using AtmStratagies(which is a subclass of a normal AtmStrategy). The NT Print() is not explicitly documented to work from within an AtmStrategy either, for example

          I do appreciate the suggested workaround, but now I'm writing infrastructure code, that's already been done by NT, and it's well done, well tested, battle-hardened, way better code than I could come up with, that's why I use NT.

          I want to use your product. I want to see it grow and improve. It's probably just me, but I kind of feel like NT is getting tired of developers and pushing the product forward, and it makes me sad. Hope I'm wrong(again I guess)...







          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by RubenCazorla, 08-30-2022, 06:36 AM
          3 responses
          77 views
          0 likes
          Last Post PaulMohn  
          Started by f.saeidi, Yesterday, 12:14 PM
          9 responses
          23 views
          0 likes
          Last Post f.saeidi  
          Started by Tim-c, Today, 03:54 AM
          0 responses
          3 views
          0 likes
          Last Post Tim-c
          by Tim-c
           
          Started by FrancisMorro, Today, 03:24 AM
          0 responses
          5 views
          0 likes
          Last Post FrancisMorro  
          Started by Segwin, 05-07-2018, 02:15 PM
          10 responses
          1,772 views
          0 likes
          Last Post Leafcutter  
          Working...
          X