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

How can we catch such events ?

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

    How can we catch such events ?

    If we enabled "TraceOrders=true;" then we see such occasions:

    Code:
    xxxxx: Entered internal SubmitOrderManaged() method at 16-Jul-20 2:30:00 AM: BarsInProgress=0 Action=Sell OrderType=Market Quantity=0 LimitPrice=0 StopPrice=0 SignalName='myExitSignal' FromEntrySignal=''
    
    
    xxxxx: Ignored SubmitOrderManaged() method at 16-Jul-20 2:30:00 AM: BarsInProgress=0 Action=Sell OrderType=Market Quantity=0 LimitPrice=0 StopPrice=0 SignalName='myExitSignal' FromEntrySignal='' Reason='This was an exit order but no position exists to exit'
    however, neither in OnOrderUpdate, nor in OnExecutionUpdate, such events are not being passed .
    Where/how we can detect those events, so we could write our logic to address those occasions?

    i.e.
    OnOrderUpdateOrWhatever(...)
    {

    if (Order.State==..Ignored) {
    ...
    }
    }


    or how?

    #2
    Hello ttodua, thanks for your post.

    That message means that NinjaTrader suppressed the order before it was even created, so OnOrderUpdate would not be called. To avoid that you must make sure the strategy only calls exit orders when the strategy is in a position.

    Kind regards.

    Chris L.NinjaTrader Customer Service

    Comment


      #3
      ChrisL.
      Many thanks, but the answer doesn't satisfy me. The example i have given, was about exits. however, that is just example, and i have met cases like :
      Once in a while, i have logs: Bar CloseTime: 01:00:00.000 22-Jan-2020 [ BarN: 1559; O:37.45 H:37.62 L:37.45 C:37.61 ] ---------------------------- orderId='x' account='Sim101' name='buy1' orderState=Submitted instrument='abc' orderAction=Buy orderType='Market' limitPrice=0 stopPrice=0 quantity=100 tif=Gtc oco=''

      where the BUY order become cancelled. (the reason was like : submited after session exit handled was finished , or like that sentence, cant remember).

      so, there should be a way hook/subscribe into those events where I can fire my logic programatically, while that event happens (those events which are caught by TraceOrders). However, just TraceOrders logs doesnt help me. I want to have programatic logic in those cases in my code, like i do with OnOrderUpdate.

      i hope i clearly explained.. thanks.

      Comment


        #4
        Hi ttodua, thanks for your reply.

        There is not an event for these type of orders. All suppressed orders can be avoided with the strategy logic. If you want to handle an order that is submitted outside of the session time, don't submit the order.

        Please let me know if I can assist any further.
        Chris L.NinjaTrader Customer Service

        Comment


          #5
          ChrisL, don't get me wrong, but neither this is answer, as you are telling things that are reason-healers, not the actual solution to question. what you said above are:
          - don't fire exit order if there is no position
          - don't submit order if you are outside regular hours..

          so, "don't .. don't" is nowhere near the answer to the problem asked by me. I ask that my strategy do submit exit order when there is no position, and my strategy do submit orders when it might be outside of trading hours.
          So, i want a programmattic access to do this or that (i.e. log into file, or throw my custom message, or do anything i want) when such events fire. So, that should be exposed to programmers to have access to those events, like we have with OnOrderUpdate.

          Comment


            #6
            Hi ttodua, thanks for your reply.

            I found this event method:


            The trace order strings can be parsed to determine the error message if you would like to handle the messages in this way.

            Please let me know if this does not resolve your inquiry.
            Chris L.NinjaTrader Customer Service

            Comment


              #7
              Thanks chris.
              that is now a solution. thank you.
              1) however, it will need a headache to parse correctly, as that is the string which i dont know how is formed in all cases- do you have any examples to help in parsing for those?

              2) if you already tried(if not i will try...) are those events triggered even when i turn off the TradeOrders=false? so, i could hook into such events without printing the log/stuff on client OutputWindow.
              Last edited by ttodua; 07-30-2020, 01:39 PM.

              Comment


                #8
                3) please rename this topic to "How to catch order events (like from TraceOrders) " and after renaming delete this exact post you are reading at this moment.

                Comment


                  #9
                  Hi ttodua, thanks for your reply.

                  No, the message string will be empty if TraceOrders is false. When you override OnOrderTrace, it completely takes over the trace order logic. So if you don't print anything within OnOrderTrace then nothing will print to the output window. So you can leave trace orders turned on and not print anything if performance is an issue.

                  Please let me know if I can assist any further.
                  Chris L.NinjaTrader Customer Service

                  Comment


                    #10
                    ttodua, unfortunately, I don't know of any example that parses the error messages already. You would need to compare the strings that you get from the standard traceorder message. If you want to see all of the messages it has, the strings are located in in NinjaTrader.Core.xml under C:\Program Files (x86)\NinjaTrader 8.

                    Best regards.
                    Chris L.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by bmartz, 03-12-2024, 06:12 AM
                    4 responses
                    31 views
                    0 likes
                    Last Post bmartz
                    by bmartz
                     
                    Started by Aviram Y, Today, 05:29 AM
                    4 responses
                    12 views
                    0 likes
                    Last Post Aviram Y  
                    Started by algospoke, 04-17-2024, 06:40 PM
                    3 responses
                    28 views
                    0 likes
                    Last Post NinjaTrader_Jesse  
                    Started by gentlebenthebear, Today, 01:30 AM
                    1 response
                    8 views
                    0 likes
                    Last Post NinjaTrader_Jesse  
                    Started by cls71, Today, 04:45 AM
                    1 response
                    7 views
                    0 likes
                    Last Post NinjaTrader_ChelseaB  
                    Working...
                    X