Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Exit on session close is reversing orders when closed via mobile

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

    Exit on session close is reversing orders when closed via mobile

    Hi there,

    We have a customer who is helping us beta test one of our automated strategies. The strategy works fine on desktop and executes as intended. However, today something interesting happened and he reported it to us.

    An automated trade triggered, and after being in the trade for a while and in profit, he decided to exit early via the mobile app. He flattened his position via the app and that worked fine. He closed out his 6 long MNQ contracts via mobile.

    Now, at the end of the day, just 30 seconds before the session was over, he was notified via mobile that he was now in a short position! He was short 6 MNQ contracts. The strategy does not have any logic inside it whatsoever that would cause a reversal like that. The filters for a directional trade are very specific and today was clearly a LONG day.

    It seems to me that the fact that he manually closed out via mobile earlier in the day is related. It seems like the mobile app didn't "update" the strategy's position, even though the account was flat.
    We have been testing this system for months and have never come across anything like this, so we think it's related to the mobile experience in particular.

    Is there anything that I'm not aware of that could cause this? Why would a manual close via the mobile app cause a position to reverse instead of doing nothing, if already flat?
    jaybedreamin
    NinjaTrader Ecosystem Vendor - Zion Trading Algos

    #2
    Originally posted by jaybedreamin View Post
    We have a customer who is helping us beta test one of our automated strategies. The strategy works fine on desktop and executes as intended. However, today something interesting happened and he reported it to us.

    An automated trade triggered, and after being in the trade for a while and in profit, he decided to exit early via the mobile app. He flattened his position via the app and that worked fine. He closed out his 6 long MNQ contracts via mobile.

    Now, at the end of the day, just 30 seconds before the session was over, he was notified via mobile that he was now in a short position! He was short 6 MNQ contracts. The strategy does not have any logic inside it whatsoever that would cause a reversal like that. The filters for a directional trade are very specific and today was clearly a LONG day.

    It seems to me that the fact that he manually closed out via mobile earlier in the day is related. It seems like the mobile app didn't "update" the strategy's position, even though the account was flat.
    We have been testing this system for months and have never come across anything like this, so we think it's related to the mobile experience in particular.

    Is there anything that I'm not aware of that could cause this? Why would a manual close via the mobile app cause a position to reverse instead of doing nothing, if already flat?
    What's the problem?
    Sounds like normal expected behavior to me.

    How does the strategy running on NinjaTrader Desktop know
    that the NinjaTrader Mobile app closed the account position?

    It doesn't.

    Ok, so the strategy running on the Desktop had no idea that it
    needed to close the strategy position -- so your customer created
    an out-of-sync condition between the account position and the
    strategy position -- he did this by closing the account position
    on the Mobile app
    .

    Yet, back on the Desktop, the strategy keeps running.

    Despite the account position being closed on the Mobile app,
    the strategy still has a position that is 'Long 6'.

    Ok, let's keep going... so how did the short position occur?

    Simple.

    I presume IsExitOnSessionCloseStrategy was true.
    I presume ExitOnSessionCloseSeconds was set to 30.

    Thus, 30 seconds before session close, your strategy sells 6
    contracts to close the 'Long 6' position. The strategy knows
    nothing about what happened on the Mobile app.

    So, what happened?
    Your strategy position is now Flat.
    Your account position is now 'Short 6' contracts, because your
    strategy sold 6 contracts to exit the Long position.

    I mean, you seem to have a classic example of account
    position vs strategy position becoming out of sync.

    Remember, all your broker sees is Buys and Sells, doesn't
    matter if Desktop submits the orders, or the Mobile app
    submits them -- but with automated entries, if you mix &
    match platforms, like what your customer did, you're just
    asking for trouble.

    Mix & match platforms with manual trades is probably not
    an issue -- but an automated strategy has a strategy position
    that needs special care and attention to prevent out of sync
    conditions.

    Moral of the story:
    Generally speaking, positions opened by the Strategy need
    to be closed by the Strategy. Closing the account position
    on the Mobile app doesn't affect the strategy position on
    the Desktop -- I'd bet my left nut that is what happened.


    Last edited by bltdavid; 07-14-2023, 03:41 AM.

    Comment


      #3
      How to solve this?

      Your customer needs to subscribe to and run all automated
      strategies from a VPS.

      Then, using their PC/Mac/Linux desktop, or their phone,
      or their tablet, or whatever -- they log into this VPS.

      The NinjaTrader Mobile app is not a VPS service, and
      I presume it does not and cannot know about strategies
      running somewhere else on some running instance of
      NinjaTrader Desktop.

      [EDIT: Full disclosure, I've never run the NinjaTrader mobile
      app, and don't know if the above statement is actually true.
      But, nonetheless, I'm doubling down on my left nut that my
      presumption about Mobile vs Desktop separation is true.]

      Your customer would check their position by phone by
      logging into the VPS
      , and seeing the Desktop instance
      running on that VPS, and then closing the strategy position,
      probably via a special 'Close' button provided by your
      strategy.

      The point is:
      Your customer needs to use a VPS as a centralized point
      of control for all automated strategies -- if they intend to
      control these running strategies from their phone.


      [And there you are, back to one platform -- the Desktop.
      Using a VPS has always been the solution to these 'mobile
      access' problems.]

      Just my 2˘.

      Last edited by bltdavid; 07-13-2023, 07:18 PM. Reason: double down on Mobile vs Desktop separation

      Comment


        #4
        Count on bltdavid to not only drop some jewels, but to be drop a joke or two in there as well haha. This makes a lot of sense! I use a VPS personally but he does not, at least not yet. I do find it interesting that the account gets update correctly on both platforms, but the Strategy is only aware of its net position when on desktop. It makes sense because the strategy did keep running on the desktop according to him. So the code was just doing what it was instructed to do!
        jaybedreamin
        NinjaTrader Ecosystem Vendor - Zion Trading Algos

        Comment


          #5
          Hello jaybedreamin,

          bltdavid is providing good information. Orders that are not submitted by the strategy do not affect the strategy position or order methods and will cause the account and strategy positions to be out of sync. The strategy position would not be closed and the exit on close will still send an order to close the strategy position.

          Below is a link to a forum post that discusses.


          And a link to the help guide.
          Chelsea B.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by NullPointStrategies, Yesterday, 05:17 AM
          0 responses
          62 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          134 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          75 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          45 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          50 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X