Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy not re-synching after re-enable NT8 B12

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

    Strategy not re-synching after re-enable NT8 B12

    I had a strategy working fine against IB connection.
    StartBehavior=WaitUntilFlat.
    When it went Flat, I disabled it (say at 14:25), and just added some more informational Print statements (no changes to the program structure), recompiled, and re-enabled the strategy at 14:34. If it had remained enabled it would have gone Long 'for real' at 14:30.
    After re-enabling the strategy it correctly picks up this EnterLong at 14:30 and shows:
    Position=100000L", Acct= -
    but it also says "Sync=true" which is surely wrong, because the real Account is flat so is NOT in sync with the strategy.
    Now each subsequent OnBarUpdate tries to use ExitLongLimit(price), and price specified is being hit during the bar, but the strategy does not simulate this action, so does not go Flat, so it remains in (amber) "waiting until it reaches a flat position" and so never goes back to live mode again.

    #2
    Hello DaveE, and thank you for your report.

    Would it be possible to provide us with a stripped-down version of your code, showing only the relevant conditional logic? This will enable us to better investigate and assist.
    Jessica P.NinjaTrader Customer Service

    Comment


      #3
      Hello Jessica,
      The attached StratTestSync reliably demonstrates the problem (at least on my system).

      I added it to Strategies tab with DataSeries: USDJPY/Last/Minute/1

      Setting Strategy Parameter UseLimit=true it uses standard Limit order functions for all entries/exits. If false then it uses Market order functions for all entries exits.

      I was running on connection to IB Gateway on paper trading account.
      It would not be a good idea to run on a live account since all it does is go round a regular cycle, of Long, Flat, Short, Flat ...
      Its designed to make it easy to start the strategy in either a Long, Short or Flat position.
      Then in theory it is expected then NT will sync the account when strategy goes Flat (which should never take more than a few minutes), and continue cycling around.
      For all the tests below I ensured that the Account was Flat before enabling the strategy.

      My initial results:
      If I set UseLimit=true:
      If the strategy is enabled when Flat (normal situation if current minute ends in 4 or 9) then NT syncs up fine (except the Sync column often shows the wrong value). It carries on working through the cycle in real-time.

      But if the strategy is enabled when its either Long (normal state when minute ends with 1 or 2) or Short (normal state when minute ends with 6 or 7) then NT never syncs up. No trades are sent to the real account.
      This seems to mean that StartBehavior.WaitUntilFlat is not currently working with Limit orders (unless you are lucky enough to enable your strategy while it is already Flat).

      If I set UseLimit=false:
      The strategy works fine regardless of the initial MarketPosition. Only problem I can see is the Sync column sometimes shows the wrong value (but it does not seem to affect the working).
      Attached Files
      Last edited by DaveE; 07-21-2016, 07:43 AM.

      Comment


        #4
        more info

        Looking at the Print statements and TraceOrders output:
        I see that if strategy has UseLimit=true, and is enabled while Short, then:

        Pre State.Realtime TraceOrders logs something like this
        Entered internal SubmitOrderManaged() method at 21/07/2016 16:26:00: BarsInProgress=0 Action=SellShort OrderType=Limit Quantity=100,000 LimitPrice=106.16'2
        then my code Prints
        OnOrderUpdate 21 Jul 2016 16:26:13 order: Name=Sell short, Qty=100000, filled=100000, avgFillPrice=106.162
        whereas after State.Realtime TraceOrders logs something like this
        Entered internal SubmitOrderManaged() method at 21/07/2016 16:28:00: BarsInProgress=0 Action=BuyToCover OrderType=Limit Quantity=0 LimitPrice=106.20'9
        The big difference is that NT managed orders has ignored the DefaultQuantity of 100000 and substituted 0 which obviously is never going to get the strategy Flat, so its stuck in perpetual WaitUntilFlat mode.

        A similar problem happens with Limit Quantity zeroed if strategy is enabled while Long..

        Comment


          #5
          Hello DaveE, and thank you for this additional information.

          We are currently reviewing both the functionality and documentation (available here, http://ninjatrader.com/support/helpG..._positions.htm ) for syncing in this manner. We will return to this thread when we have more information.
          Jessica P.NinjaTrader Customer Service

          Comment


            #6
            work-around

            Hello Jessica,
            I made a few changes and I think I identified the problem and a work-around.
            The problem is that these signatures do not work correctly in WaitUntilFlat mode:
            • ExitLongLimit(double limitPrice)
            • ExitShortLimit(double limitPrice)


            the documentation says
            If you do not specify a quantity the entire position is exited rendering your strategy flat
            I think the problem is that while in WaitUntilFlat mode (after State.Realtime) these signatures are currently incorrectly getting the position quantity from the Account, whereas they need to continue to get it from the strategy until WaitUntilFlat mode has finished.

            Work-around. I changed to using these instead:
            ExitLongLimit(DefaultQuantity, Close[0]);
            ExitShortLimit(DefaultQuantity, Close[0]);

            Comment


              #7
              Hello, and thank you for your report. This behavior was confirmed on our end. We will be investigating this further. Please keep an eye on the NinjaTrader 8 Release Notes page for updates and bugfixes.



              Jessica P.NinjaTrader Customer Service

              Comment


                #8
                Hello DaveE,

                I would like to ask, has this behavior persisted for you into Beta 12?
                Jessica P.NinjaTrader Customer Service

                Comment


                  #9
                  Hello DaveE,

                  After further testing and evaluation, we were able to confirm the syncing feature is working as designed, and that the Account position is properly being ignored by WaitUntilFlat . I hope this thread serves to clear up any further confusion. Please let us know if there are any other ways we can help.
                  Jessica P.NinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by bortz, 11-06-2023, 08:04 AM
                  47 responses
                  1,606 views
                  0 likes
                  Last Post aligator  
                  Started by jaybedreamin, Today, 05:56 PM
                  0 responses
                  8 views
                  0 likes
                  Last Post jaybedreamin  
                  Started by DJ888, 04-16-2024, 06:09 PM
                  6 responses
                  18 views
                  0 likes
                  Last Post DJ888
                  by DJ888
                   
                  Started by Jon17, Today, 04:33 PM
                  0 responses
                  4 views
                  0 likes
                  Last Post Jon17
                  by Jon17
                   
                  Started by Javierw.ok, Today, 04:12 PM
                  0 responses
                  13 views
                  0 likes
                  Last Post Javierw.ok  
                  Working...
                  X