Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

No reaction to the orders placed.

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

    No reaction to the orders placed.

    Hello NT8.
    I would like you to help me to figure out the following issue, please. I have some number of the instances of the strategy launched on various accounts. All those strategies have the same parameters. All those instances worked for days and even weeks. One day one of the instances failed... There are two pieces of a custom logging in the attachment that shows the workflow for failed and correct instances. Some entry condition was met. All instances processed it and placed entry orders. And almost all of them got confirmation that orders are filled. Except failed one... It seems no matter how many orders that strategy places, neither OnExecutionUpdate, nor OnPositionUpdate methods don't work... And there are no any error records in the NT8 Log tab about cancelled or rejected ordes. Also there are no any records about provider was disconnected... I had to restart NT8 to make the strategy work again. Is there any explanation of such a behaviour and what would you suggest to avoid them? Thank you.​
    Attached Files

    #2
    Hello PopovDS,

    The output you provided would really only be helpful for you to debug the script as you know where in the script you placed the prints. I wouldn't be able to gain anything from looking at those outputs. If OnExecutionUpdate or OnOrderUpdate were not called that would mean no order was submitted so no order states were observed, those are only called once an order has been submitted or filled.

    I would suggest using TraceOrders to see if the orders were being ignored for some reason. https://ninjatrader.com/support/help...aceorders2.htm

    Comment


      #3
      Hello Jesse! Thank you for your response. I will apply TraceOrders functionality in the next version of the strategy. There was another weird thing. As I mentioned I didn't see filled orders in my custom log. I didn't see them in the NT8 log tab of desktop application too. But I saw those trades in the web version of NT8. But they were incomplete, only 2 contracts instead of 3. It seems NT8 tried to process orders but something went wrong... Is there a way to check some other files of NT8 built-in logging system to figure it out?

      Comment


        #4
        Hello PopovDS,

        You can check the log file for the time where you had seen orders however that is a combination of all orders placed and is not specific to one strategy. If you are running more than one strategy on the same instrument/account it is possible the orders were from one of the other strategies and not the one that failed to work. The log files are located in the folder Documents\NinjaTrader 8\log.



        Comment


          #5
          Hello.
          Still investigating weird behavior with orders I have noticed one more interestin thing. There is a template of the piece of the strategy logic below.

          Code:
          protected override void OnExecutionUpdate(Execution execution, string executionId, double price, int quantity, MarketPosition marketPosition, string orderId, DateTime time)
          {​
             // log output
             lock (someLocker)
             {
                // some processing
             }
          }
          
          protected override void OnOrderUpdate(Cbi.Order order, double limitPrice, double stopPrice,
                      int quantity, int filled, double averageFillPrice,
                      Cbi.OrderState orderState, DateTime time, Cbi.ErrorCode error, string comment)
          {
             // log output
             // some processing
          }
          
          protected override void OnPositionUpdate(Cbi.Position position, double averagePrice,
                      int quantity, Cbi.MarketPosition marketPosition)
          {
             // log output
             // some processing​
          }​​​
          
          private void OnAccountItemUpdate(object sender, AccountItemEventArgs e)
          {
              if (e.AccountItem == AccountItem.RealizedProfitLoss)
             {
                lock (someLocker)
                {
                   // log output
                   // some processing​​
                }
             }
          }
          The strategy works for few days and then the issue occurs... And I can see 2 possible sorts of abnormal things at that moment:
          1. I never get log output from OnAccountItemUpdate callback.
          2. The log record from OnPositionUpdate callback may be output more than 2 hours (!) later after execution is filled (I see it in the logs from OnOrderUpdate and OnExecutionUpdate)

          Either there is some delay or... the reason may be in usage of lock (someLocker) operator. I have been successfully using lock operator in my coding practice for long time when creating some external applications, not NT8 scripts. But I don't know the inner logic of NT8 and I guess my approach can lock some important trading workflow... Can you advise something here?
          Last edited by PopovDS; 01-08-2024, 09:21 AM.

          Comment


            #6
            Hello PopovDS,

            I would suggest trying to remove the locks you are using, those would not be needed for any of the strategies overrides. locks are only needed when accessing platform properties or collections that can be updated outside of your script, one example is the accounts collection to find an account. lock otherwise is not needed at all in your custom code.

            Comment


              #7
              OK, I will remove them, test again and let you know about the result. Thank you!

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by NullPointStrategies, Today, 05:17 AM
              0 responses
              50 views
              0 likes
              Last Post NullPointStrategies  
              Started by argusthome, 03-08-2026, 10:06 AM
              0 responses
              126 views
              0 likes
              Last Post argusthome  
              Started by NabilKhattabi, 03-06-2026, 11:18 AM
              0 responses
              69 views
              0 likes
              Last Post NabilKhattabi  
              Started by Deep42, 03-06-2026, 12:28 AM
              0 responses
              42 views
              0 likes
              Last Post Deep42
              by Deep42
               
              Started by TheRealMorford, 03-05-2026, 06:15 PM
              0 responses
              46 views
              0 likes
              Last Post TheRealMorford  
              Working...
              X