Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Swing System

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

    Swing System

    Hello,

    I have built a strategy based on a swing system that submits stop losses and profit targets to scale out of a position.

    Everything works fine -- it puts in the stop losses / targets just fine. It scales out just fine. The problems occur when I hold a position overnight. If the strategy is holding a position at I close NT down for the day after the markets close, then the next day when I open it up and start the strategy again, it does one of two things:

    1). If I have NT set to immediately fill historical orders, it puts in all new stop losses / profit targets based on the current ask price, even though the stop losses / profit targets from the previous day are already there.

    2). If I set NT to wait until flat to submit orders, it doesn't put in new stop losses / targets, but the existing ones that are there are no longer associated with a strategy. That is, on the orders tab, they are still listed, but they have nothing in the Strategy column.

    In the second case above, I also notice that on the executions tab, I see fake orders -- buy or sell orders that aren't actually submitted -- though I assume that this is just to tell me the current state of the strategy (whether it currently thinks it is long or short). Very bizarre and confusing way of representing this, by the way.

    First question:
    ===========

    Please advise what the best practice is for this case. What setting should I be using? I assume that I should set it to wait until flat.

    Second question:
    =============

    Assuming your answer is to tell me to set it to wait until flat, I have a problem with this. Let's say on a given day, the lines cross and the system goes short. It puts in the profit targets / stop losses. At some point, one of my profit targets is hit and 20% of my shares are sold off. Great. When the markets close, I shut down NinjaTrader.

    The next day, I load up NinjaTrader and start my strategy again. I have it set to "wait until flat", so no new targets / stop losses are put in. But again, remember that the existing ones now show up on the orders tab as not being associated with any strategy. Let's say the lines now cross, and the strategy should now cover the remaining 80% and go long. Is it going to cover when it's set to "wait until flat?" Is it going to remember that it only needs to cover 80%, even though it was shut down overnight and restarted and the targets/stops are no longer associated with the strategy?

    To complicate matters further, I have a second strategy running (not a swing system, no targets/stops, just a simple end of day, EMA cross strategy) that trades the same instrument. If both strategies are in the market, is there going to be interference between the two?

    Thank you.

    #2
    jeffshantz,

    As you restart a strategy, there is no mapping back to prior states. Closing NT and starting up again creates a completely new instance of a strategy that has no knowledge of prior trades, orders, etc. It is your responsibility to keep your account position in line with your strategy position at strategy start. Easiest way to do this is to flatten your account, use Wait until Flat and the accounts will come in sync when the strategy reaches a flat state too.

    If you want to maintain your prior position without closing it, you should be using Immediately submit.

    The key thing to note here is that there is no recognition of prior trades from an older run of the strategy. It doesn't see it or know about it.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Josh,

      Originally posted by NinjaTrader_Josh View Post
      Easiest way to do this is to flatten your account, use Wait until Flat and the accounts will come in sync when the strategy reaches a flat state too.
      Okay, but that's completely useless for anything other than a system that closes its position at the end of day. The point here it automation. I can't just flatten my account and close my position in the morning -- I buy/sell when the lines cross or one of my targets/stops is hit.

      If you want to maintain your prior position without closing it, you should be using Immediately submit.
      That would be perfect, if it were true. As I mentioned above, this generates new stop losses and profit targets at the CURRENT ask -- not the ask where the strategy initially bought in the day before (obviously, since it's a new instance of the strategy, as you said). So now I have my stop losses / profit targets entered from the day before, and then I have all new duplicate stop losses and profit targets put in when I start the strategy the next day, except that they are wrong since they're using the current ask.

      Comment


        #4
        For sure it will generate new orders. As stated, it does NOT map back to anything from a prior run. When you start up the strategy again it is a brand new instance that does NOT know what it did yesterday. Furthermore, since the strategy is recalculated, all values will be based on the historical data instead of how it was processed in real-time.

        Your stops/targets will go in at whatever price the code determines it to be. When recalculated historically for sure this is different than what you may actually get in real time. Especially since there is no historical bid/ask data.

        To reiterate, it is your responsibility to sync your brokerage account with your strategy account. If you don't want to do this, don't stop the strategy.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Josh View Post
          For sure it will generate new orders. As stated, it does NOT map back to anything from a prior run. When you start up the strategy again it is a brand new instance that does NOT know what it did yesterday. Furthermore, since the strategy is recalculated, all values will be based on the historical data instead of how it was processed in real-time.

          Your stops/targets will go in at whatever price the code determines it to be. When recalculated historically for sure this is different than what you may actually get in real time. Especially since there is no historical bid/ask data.
          So, are you telling me that NT is only good for day trading? It can't handle a system that holds stop losses and profit targets overnight?

          Comment


            #6
            Not sure what your concern is about. There is no issue with the handling of starting/stopping strategies. You need to ensure the positions match up. NT7 will provide more syncing options, but it is still your responsibility to make sure your account is in sync with your strategy.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_Josh View Post
              Not sure what your concern is about.
              Josh, not to be argumentative, but exactly what do you mean you're not sure what my concern is about? (!) I just iterated to you in length what my problem is.

              I have a system that puts in stop losses and profit targets. It holds positions overnight. In the morning, when I start up my strategy, I need those stop losses and profit targets to be at the same prices that they were the day before. If I set it to automatically submit historical orders, it puts in new stop losses / profit targets based on the current ask. If I set it to wait until flat, it doesn't do anything, but the existing stops/targets are not associated with the strategy anymore.

              Obviously, I'm going to have to have the strategy write the stop loss and profit target prices to a file and load the file and resubmit them in the morning at their original prices. It's just beyond me that NT can't handle something so simple.

              How else am I supposed to "sync my account", as you say?

              Comment


                #8
                When you restart a strategy it does NOT do anything in relation to any prior run of your strategy. Your strategy is completely recalculated based on historical data as opposed to real-time data yesterday. The difference between this can be as apparent as night and day. Running on historical data is essentially the same as backtesting and backtesting is comletely different than real-time. This means your strategy has the potential to calculate differently and as such your orders can be different.

                If you are using ask/bid as your stop/target values this will for sure be different as ask/bid data is available in real-time, but not in a historical sense.

                If you want the orders to be at the same price, you need to submit them at the same price. When you use things like GetCurrentBid/Ask(), you are NOT submitting them at the same price.
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by NinjaTrader_Josh View Post
                  When you restart a strategy it does NOT do anything in relation to any prior run of your strategy.
                  Thanks Josh, I am a professional software developer and am fully aware that when a new object is instantiated in code, it does not retain the state of any previous objects. Thanks for repeating that 10 times.

                  I was trying to figure out if there was a way to get the strategy to resubmit the stops/targets at the previous prices. Your lack of comprehension and obvious unwillingness to help ensure that you'll remain in a support role for many years to come. Enjoy that.

                  Comment


                    #10
                    jeffshantz,

                    With all due respect, I fully comprehend the scenario and all I have done is explain to you how NinjaTrader works. You are asking for concepts that do not exist. When the strategy does not know of any prior orders there is no way it knows what your prior price was. Only information it can run off of is the historical data and as stated, historical data does not include bid/ask. If you want to submit at previous prices, you need to make sure your strategy does so. You have already proposed a workable solution for your use case scenario and as such I am closing this case now. Thank you and have a good day.
                    Josh P.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                    0 responses
                    648 views
                    0 likes
                    Last Post Geovanny Suaza  
                    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                    0 responses
                    369 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by Mindset, 02-09-2026, 11:44 AM
                    0 responses
                    108 views
                    0 likes
                    Last Post Mindset
                    by Mindset
                     
                    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                    0 responses
                    572 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by RFrosty, 01-28-2026, 06:49 PM
                    0 responses
                    574 views
                    1 like
                    Last Post RFrosty
                    by RFrosty
                     
                    Working...
                    X