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

'GetAtmStrategyUnrealizedProfitLoss' method error: ATM strategy ID does not exist

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

    'GetAtmStrategyUnrealizedProfitLoss' method error: ATM strategy ID does not exist

    I used the SampleATMPnL as a base and made it send a limit order instead of a market. When I run OnEachTick, sometimes I get the error 'GetAtmStrategyUnrealizedProfitLoss' OR 'GetAtmStrategyEntryOrderStatus' method error: ATM strategy ID does not exist.

    Is this expected? Is there a way to avoid receiving this error when I run OnEachTick? My suspicion is that a tick occurs and updates the indicator before the order can be initialized in the system.
    Attached Files

    #2
    Hello Jack22,

    These warnings are expected if the methods are being called when there is no order id that exists. This can happen if you are calling the methods before an order or also after it has filled and a number of ticks have elapsed. The ATM's are not necessarily like strategy orders which persist constantly in your strategy, these instead have a lifetime and once they are gone you would get this message if the method is still being called.

    Currently there are no ways to suppress this message that I am aware of, I could only suggest using the managed or unmanaged approach to avoid that.

    I look forward to being of further assistance.

    JesseNinjaTrader Customer Service

    Comment


      #3
      Hello Forum,

      I also face an issue with GetAtmStrategyEntryOrderStatus ... I'm using the exact code to create an order based on the system provided template:

      isAtmStrategyCreated = false; // reset atm strategy created check to false
      atmStrategyId = GetAtmStrategyUniqueId();
      orderId = GetAtmStrategyUniqueId();
      AtmStrategyCreate(OrderAction.Sell, OrderType.StopLimit, Low[0]-3*TickSize, Low[0]-2*TickSize, TimeInForce.Day, orderId, atmTemplate, atmStrategyId, (atmCallbackErrorCode, atmCallBackId)
      => {
      //check that the atm strategy create did not result in error, and that the requested atm strategy matches the id in callback
      if (atmCallbackErrorCode == ErrorCode.NoError && atmCallBackId == atmStrategyId){
      isAtmStrategyCreated = true;
      }
      });
      if ( isAtmStrategyCreated == true && orderId.Length > 0 ){
      status = GetAtmStrategyEntryOrderStatus(orderId);
      // Alert("StrategyOrder", Priority.High, "StrategyOrder submitted" + " Chart Period: " + BarsPeriod.Value.ToString() + " " + BarsPeriod.BarsPeriodType.ToString(), NinjaTrader.Core.Globals.InstallDir+...s\Aler t4.wav", 10, Brushes.Black, Brushes.Blue);
      Print("OrderId: " + orderId + " Status: " + status[2]);
      }


      Here's is the NinjaScript Output after the order AtmStrategyCreate() got triggered:

      'GetAtmStrategyEntryOrderStatus' method error: Order ID 'bac1e9602fff474b8317ec94daf4ded1' does not exist


      The order does actually get submitted and appears in the system, so why does the system report, that the Order ID does not exist?

      My Calculate is set to "On bar close" - does a strategy need to be set to "on each tick"???

      Comment


        #4
        Hello abctrader,

        Getting the status of an external strategy will rely on that strategies state, from just the syntax I really couldn't say if that was correct or not for the situation.

        You can try testing the SampleATMStrategy which also uses this method to see if it reports a similar message in that use case, that could help to confirm if this relates to your logic. It is expected to see this warning when the order no longer exists or if you call this before the order is working/filled. You can try using OnEachTick, that will give you more frequent updates in case the OnBarUpdate is happening outside of where the order can be seen.

        If your logic is critical for the state of the orders or targets I would suggest to avoid using the ATM methods and just use the managed or unmanaged approach so you can have complete control over the orders and status of the strategy.

        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by GLFX005, Today, 03:23 AM
        0 responses
        1 view
        0 likes
        Last Post GLFX005
        by GLFX005
         
        Started by XXtrader, Yesterday, 11:30 PM
        2 responses
        11 views
        0 likes
        Last Post XXtrader  
        Started by Waxavi, Today, 02:10 AM
        0 responses
        6 views
        0 likes
        Last Post Waxavi
        by Waxavi
         
        Started by TradeForge, Today, 02:09 AM
        0 responses
        11 views
        0 likes
        Last Post TradeForge  
        Started by Waxavi, Today, 02:00 AM
        0 responses
        2 views
        0 likes
        Last Post Waxavi
        by Waxavi
         
        Working...
        X