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

GetAtmStrategyMarketPosition() fails to update

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

    GetAtmStrategyMarketPosition() fails to update

    I have a strategy that checks GetAtmStrategyMarketPosition() continually tick by tick while a limit order is pending. Once the limit order fills, the next tick should have GetAtmStrategyMarketPosition() = MarketPosition.Long or Short, correct?

    However, in my case, the next tick after a limit order fills, is getting GetAtmStrategyMarketPosition() = MarketPosition.Flat. Why is this? It only happens when connected to a realtime data feed. When I replay the same exact ticks through Market Replay, then GetAtmStrategyMarketPosition() = MarketPosition.Long in this scenario.

    Is there a bug in the internal NT code for GetAtmStrategyMarketPosition(), or is this possibly a tick data problem? How many ticks after a limit order fills is the GetAtmStrategyMarketPosition() status changed?

    Thanks!
    Bryan
    Last edited by cassb; 11-12-2012, 11:11 AM.
    cassb
    NinjaTrader Ecosystem Vendor - Logical Forex

    #2
    Hello Bryan,

    Thank you for your post.

    Market Replay will use the same simulation engine as the SIM101 account and can have fills a lot quicker than the real market. For information on the SIM101 account please visit the following link: http://www.ninjatrader.com/support/h...01_account.htm

    With that said have you enabled TraceOrders in your strategy to track the orders in the Output Window (Tools > Output Window) to see when the order is filled in comparison to when the ATM Strategy is reported as Long or Short?
    If not, I recommend using TraceOrders to do so. For information on TraceOrders please visit the following link: http://www.ninjatrader.com/support/f...ead.php?t=3627

    Please let me know if I may be of further assistance.

    Comment


      #3
      Hi Patrick. This is in the SIM101 account vs. Mkt Replay.
      cassb
      NinjaTrader Ecosystem Vendor - Logical Forex

      Comment


        #4
        Hello Bryan,

        Thank you for your response.

        The same details apply here as with the Replay101 account.
        Market Replay will use the same simulation engine as the SIM101 account and can have fills a lot quicker than the real market. For information on the SIM101 account please visit the following link: http://www.ninjatrader.com/support/h...01_account.htm

        With that said have you enabled TraceOrders in your strategy to track the orders in the Output Window (Tools > Output Window) to see when the order is filled in comparison to when the ATM Strategy is reported as Long or Short?
        If not, I recommend using TraceOrders to do so. For information on TraceOrders please visit the following link: http://www.ninjatrader.com/support/f...ead.php?t=3627

        Please let me know if I may be of further assistance.

        Comment


          #5
          Originally posted by NinjaTrader_PatrickH View Post
          Hello Bryan,

          Thank you for your response.

          The same details apply here as with the Replay101 account.
          Market Replay will use the same simulation engine as the SIM101 account and can have fills a lot quicker than the real market. For information on the SIM101 account please visit the following link: http://www.ninjatrader.com/support/h...01_account.htm

          With that said have you enabled TraceOrders in your strategy to track the orders in the Output Window (Tools > Output Window) to see when the order is filled in comparison to when the ATM Strategy is reported as Long or Short?
          If not, I recommend using TraceOrders to do so. For information on TraceOrders please visit the following link: http://www.ninjatrader.com/support/f...ead.php?t=3627

          Please let me know if I may be of further assistance.
          Patrick, if Market Replay uses the same simulation engine as Sim101, then why is the result different when I use Market Replay vs. using Sim101 with live data?
          cassb
          NinjaTrader Ecosystem Vendor - Logical Forex

          Comment


            #6
            Hello Bryan,

            Thank you for your response.

            This can be as simple as the fact that you are looking at the market at two different times and getting two different results.
            Does this occur when you are playing at a slower speed such as 1X on Replay?
            Does it matter what time in replay or real-time that you place the trade?

            I look forward to your response.

            Comment


              #7
              Originally posted by NinjaTrader_PatrickH View Post
              Hello Bryan,

              Thank you for your response.

              This can be as simple as the fact that you are looking at the market at two different times and getting two different results.
              Does this occur when you are playing at a slower speed such as 1X on Replay?
              Does it matter what time in replay or real-time that you place the trade?

              I look forward to your response.
              Are you saying that there must be a problem in my code and that there is no way that the
              GetAtmStrategyMarketPosition() method would return a value of "Flat" 1 tick after a limit order is filled?
              cassb
              NinjaTrader Ecosystem Vendor - Logical Forex

              Comment


                #8
                Hello Bryan,

                Thank you for your response.

                I am not saying there is any issues with your code. However, if you wish to test further please use the following information at the link below for debugging: http://www.ninjatrader.com/support/f...ead.php?t=3418

                Do you have any code that I can test on my end or any examples? Please detail the instrument and interval used.

                I look forward to your response.

                Comment


                  #9
                  Originally posted by NinjaTrader_PatrickH View Post
                  Hello Bryan,

                  Thank you for your response.

                  I am not saying there is any issues with your code. However, if you wish to test further please use the following information at the link below for debugging: http://www.ninjatrader.com/support/f...ead.php?t=3418

                  Do you have any code that I can test on my end or any examples? Please detail the instrument and interval used.

                  I look forward to your response.
                  I just ran a test with my strategy, and it took 84 ticks(!) from the time an order was marked as "Filled":

                  string[] status = GetAtmStrategyEntryOrderStatus(orderId);

                  and status[2] = "Filled" (I think that means that the limit order has been filled, right?)

                  ...and the time that the ATM Strategy said that the position was not Flat:

                  mPos = GetAtmStrategyMarketPosition(atmStrategyId);
                  and mPos != Cbi.MarketPosition.Flat (I think this means that the ATM Strategy has begun managing the position, right?)


                  That means that there are 84 ticks of data where the order was filled, but was unmanaged.

                  Now, either 1) The ATM Strategy really has control of the position, but the GetAtmStrategyMarketPosition() method is unable to keep up with live data stream, or 2) I have an unmanaged position for 84 ticks(!). I hope it's #1 and there's just some kind of bug in the GetAtmStrategyMarketPosition() code that's not keeping up with the market for some reason.

                  Like I said, in Market Replay, the GetAtmStrategyMarketPosition() method seems to return a correct value 1 tick after the order is filled.
                  cassb
                  NinjaTrader Ecosystem Vendor - Logical Forex

                  Comment


                    #10
                    Hello Bryan,

                    Thank you for your response.

                    Can you provide the Strategy or a Toy version of the Strategy that I can use on my end to test this matter?
                    If so please send to support[at]ninjatrader[dot]com with 'ATTN: Patrick' in the subject line and a reference to this thread in the body of the e-mail: http://www.ninjatrader.com/support/f...ad.php?t=53811

                    I look forward to assisting you further.

                    Comment


                      #11
                      Hi NinjaTrader_PatrickH, cassb,
                      Looks like you took this conversation offline from this public forum. Curious if you might be able to post as to what solutions you found and how you were able to move forward from this.
                      I'm also experiencing lag after a Limit Order has been filled before the Order Information becomes available to the active Strategy, and would appreciate what you found that worked for you.
                      Thanks!
                      RK

                      Comment


                        #12
                        Hello RK,

                        Unfortunately, this ticket from 2012 is no longer in our system.

                        Please note, NinjaTrader 7 is no longer in active development and we are no longer considering new feature requests or changes for NinjaTrader 7. Main development has shifted to our flagship platform NinjaTrader 8. This does mean updates from brokerages, data feeds, or operating systems that require an update in NinjaTrader will not be implemented in NinjaTrader 7 and may cause an interruption in service.

                        While there is not a set ETA for the complete discontinuation of NinjaTrader 7, we highly recommend transitioning to NinjaTrader 8 as soon as possible before NinjaTrader 7 reaches its end of life to prevent interruption of service.

                        Click below to download NinjaTrader 8.
                        http://ninjatrader.com/GetStarted


                        It is normal for a limit order to take time to fill, send a message back to NinjaTrader, and then for the execution to process, then the position to update. This typically is not longer than a second after the . However, this does mean it will be necessary to wait 1 or a few ticks (with CalculateOnBarClose false) before atm status is updated and can be retrieved with GetAtmStrategyEntryOrderStatus().

                        That said, as NinjaTrader 7 is single threaded unlike NinjaTrader 8 which is multi-threaded, you could be experiencing a performance impact from other scripts running in the workspace.

                        How long after the execution message appears on the Log tab of the Control Center does it take before the atm status changes?

                        Are you testing this in a new blank workspace with all other workspaces closed on a single chart with absolutely no indicators applied, using a test script with only the few lines of code necessary to submit the order with the atm and retrieve the status?
                        Chelsea B.NinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by gentlebenthebear, Today, 01:30 AM
                        1 response
                        8 views
                        0 likes
                        Last Post NinjaTrader_Jesse  
                        Started by Aviram Y, Today, 05:29 AM
                        1 response
                        7 views
                        0 likes
                        Last Post NinjaTrader_ChelseaB  
                        Started by cls71, Today, 04:45 AM
                        1 response
                        7 views
                        0 likes
                        Last Post NinjaTrader_ChelseaB  
                        Started by TradeForge, Today, 02:09 AM
                        1 response
                        22 views
                        0 likes
                        Last Post NinjaTrader_ChelseaB  
                        Started by elirion, Today, 01:36 AM
                        2 responses
                        14 views
                        0 likes
                        Last Post elirion
                        by elirion
                         
                        Working...
                        X