Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

GetAtmStrategyMarketPosition failing randomly

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

    GetAtmStrategyMarketPosition failing randomly

    Sometimes the GetAtmStrategyMarketPosition report flat when the atm is in position. I attached a sample strategy where you can test this out. Usually on second or third filled entry the GetAtmStrategyMarketPosition report flat, and a new atm enter while there is already an atm present with an open position.

    Hatori.
    Attached Files

    #2
    hatori, thanks - will take a look here shortly into your sample.

    Comment


      #3
      I was not able to reproduce here on my end, tried for example on the ES 15 sec chart to get some trades quickly in - please do this, try the same chart and our default SampleAtmStrategy, open output window up and wait until the strategy gets filled?

      Does it report ok?

      Then while still in the trade and the exit bracket is working, please add manually one contract via a Market Buy Order from the DOM for example -

      Does this get reported ok as well?

      Comment


        #4
        GetAtmStrategyMarketPosition

        I tried again and add timestamp to the print: you can see that the ATM order is filled (at 22:36:45) and right away the
        GetAtmStrategyMarketPosition report flat status (check the code where that print is) , and then an over-entry occurs.

        I am almost sure that you can reproduce this with attached sample.
        That code (and the strategy which is based on that) is working perfectly in NT6.5 for a very long time.
        Attached Files

        Comment


          #5
          Hello,

          This could occur due to the fact the the market position is not updated in onBarUpdate(), as you will need to wait until the next OnBarUpdate for the Market Position to be reflected.

          Let me know if I can be of further assistance.
          BrettNinjaTrader Product Management

          Comment


            #6
            I am not sure you saw the code , there is an else if there , so the flat print must came from the next onBarUpdate.

            Comment


              #7
              hatori, if the order just filled (like in your shown sample) there's no guarantee that the position update at that point is indeed done, it would be for sure showing after the next subsequent OnBarUpdate() call, so you would have let your test run one bar longer before disabling to see it being reflected.

              Comment


                #8
                The flat print came form the next subsequent OnBarUpdate() call , also please notice that this is not a custom code , we are talking about your basic atm sample with an extra print , and CalculateOnClose set to false.

                Not clear why is it working in NT6.5 and fail in NT7 , pure luck?

                Comment


                  #9
                  hatori,

                  This is working as expected. This is the same in 6.5 and 7. There is no guarantee GetAtmStrategyMarketPosition() will be updated until the next OnBarUpdate() event. If you see it get updated earlier than the next OnBarUpdate(), great, but it is not guaranteed to be updated until the next OnBarUpdate() event.
                  Josh P.NinjaTrader Customer Service

                  Comment


                    #10
                    Josh ,the flat print came from the next subsequent OnBarUpdate.
                    The GetAtmStrategyMarketPosition() report flat on the next onbarupdate when the atm has a filled position.
                    Last edited by hatori; 06-10-2010, 11:28 AM.

                    Comment


                      #11
                      We've tested on two installs here on our end with this file attached on CalculateOnBarClose = false as your original case and could not find an issue, it would update as soon as the position update is received, at last on the next bar update then.
                      Attached Files

                      Comment


                        #12
                        Hello,

                        You've got an extra
                        GetAtmStrategyMarketPosition
                        call which is not present in the basic sample eighter, without that , it is happening all the time.

                        If I understand right , that extra call is doing some sync in the background , so on the next OnBarUpdate the function return with the correct value.
                        Attached Files

                        Comment


                          #13
                          hatori,

                          Please do not strip away the print outs from outside the if-statement. Those are necessary to see the relationship of the next OnBarUpdate() event versus GetAtmStrategyMarketPosition().

                          This is the output of your version with me disabling it a minute after the entry is filled. Once entry is filled the strategy stops producing any useful output:
                          Code:
                          0039 22:26:53.12 Working    Flat
                          0040 22:26:53.62 Working    Flat
                          0041 22:26:54.12 Filled    Flat
                          **NT** Disabling NinjaScript strategy 'Atm3/aa6f7992f39149eebcb02c2a9062bf85'
                          Even with removing the GetAtmStrategyMarketPosition check inside the status.GetLength(0) > 0 if-statement does not make a difference of this behavior. There is no "atmStrategyId reset" call on the next OnBarUpdate(). Please be sure you are on NT7B17. We are testing with Simulated Data Feed on our end.

                          Output with the "extra" code commented out (attached below).
                          Code:
                          ------- START 5 -------
                          22:32:51.81 Working    Flat
                          22:32:51.81 The current ATM Strategy market position is: Flat
                          ------- END 5 -------
                          
                          ------- START 6 -------
                          22:32:52.36 Filled    Flat
                          22:32:52.36 The current ATM Strategy market position is: Flat
                          ------- END 6 -------
                          
                          ------- START 7 -------
                          22:32:52.84 The current ATM Strategy market position is: Long
                          ------- END 7 -------
                          Attached Files
                          Josh P.NinjaTrader Customer Service

                          Comment


                            #14
                            I do not have more time for this. It is still happening easily. What I can suggest to reproduce: wait for a sudden , at least two tick move , and do not call GetAtmStrategyMarketPosition on the same OnBarUpdate event when you trigger the ATM . Call GetAtmStrategyMarketPosition only when the strategyId is not null.

                            Regards,
                            Hatori.
                            Attached Files

                            Comment


                              #15
                              Thanks for the added details hatori, we'll will continue to monitor this for an issue.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              607 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              353 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              105 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              560 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              561 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X