Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Closing an Automated Trade Position with a Limit Order

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

    Closing an Automated Trade Position with a Limit Order

    hello all,

    let's say your automated trading strategy creates a juicy trade. you are way up, and you want to take profits, instead of waiting for strategy to exit.

    what is correct way to exit the trade so that:

    a) you place a limit order and get that current profitable price? (not a less profitable market price)

    b) you don't mess up the strategy's "accounting", meaning after you exit, the strategy will show a flat position, not 1L or what have you.

    thanks in advance. you are generally super helpful.

    #2
    Hello,

    Thanks for the note.

    This depends heavily on the coding of the strategy.

    Are you using ATM Strategies or EnterLong() calls?

    Mostly however you will want to cancel the strategy and to do this simply hit the Close button. This will close the strategy, get you out of your position, and cancel any remaining orders left. You can then re-enable your strategy at a later time.

    Comment


      #3
      Originally posted by NinjaTrader_Brett View Post
      Hello,

      Thanks for the note.

      This depends heavily on the coding of the strategy.

      Are you using ATM Strategies or EnterLong() calls?

      Mostly however you will want to cancel the strategy and to do this simply hit the Close button. This will close the strategy, get you out of your position, and cancel any remaining orders left. You can then re-enable your strategy at a later time.
      Yes, but I want to get out at a limit price, not market price. that's the crux of the matter.

      and for the record, my strategies are coded in terms of EnterLong() calls.


      Thanks for responding so quickly

      Comment


        #4
        Hello,

        In this case I would shutdown the strategy. Strategies Tab->Disable.

        Then submit your limit order to exit. By disabling the strategy you will ensure that when you exit, your strategy wont then try to exit at a later time (When the strategy was programmed to exit) to submit a order to sell 1 contract (lets say you where long 1 contract before you did the limit order to go flat) then you would end up with an unexpected short position.

        Let me know if I can be of further assistance.

        Comment


          #5
          You can then re-enable the strategy at a later time and make sure to follow in sync instructions.


          Strategy Position vs. Account Position:


          1st solution:

          You can include the following statement in your code to avoid the strategy to be calculated on historical data.

          // Only run on real-time data
          if (Historical)
          return;
          Add the statement to the top of OnBarUpdate()

          2nd solution:
          You can set 'On starting a real-time strategy' to 'Wait until flat before executing live'.
          This option can be found at Tools-->Options-->Strategies-->NinjaScript-tab.

          3rd solution, would be submitting manual orders to sync the strategy and account positions described in the link

          4th solution, would be to enable Sync account position to true.

          Comment


            #6
            thanks, I'll try this

            Comment


              #7
              I've been experimenting using limit orders in my strategies and see that some strategies don't begin to enter trades. Might this be due to a 2 or more tick gap in the bid to ask price? Also, when using market replay, limit orders don't respond properly in strategies. Market orders work fine. I tested grain futures. It appears that using market orders in strategies works best. In these volatile markets, I would prefer to use limit orders in strategies. Any feedback on this subject?

              Comment


                #8
                Hello,

                Thanks for the note.

                This is the downside of using limit orders. You will get a good fill but that comes at the price of not getting in the market if the market cannot fill you at that price at that time.

                Let me know if you feel something else is going on and what information you have that would help us further assist.

                -Brett

                Comment


                  #9
                  I totally agree with LTWCI. I'd rather get in on limit orders, knowing full well the order might not be filled. I'm trying to make more successful trades, not necessarily more trades.

                  I have changed certain strategies to limit orders however, only to find that the strategies never fires. I mean, they totally go "green" and never fire and never turn yellow. They just sit there, like they are broken strategies.

                  Comment


                    #10
                    Yellow means waiting to go flat to enter live. This means that your strategy has a position in historical that it has no exited. You will need to wait for the exit for the strategy to enable or turn off the option under control center->tools->options->strategies->ninjascript sub tab->uncheck wait for flat before executing live.

                    Let me know if I can be of further assistance.

                    Comment


                      #11
                      Yes, we understand that. What I mean is these suckers just stay green.

                      Usually, when you enable a strategy over a whole bunch of futures, some of them start off yellow, meaning using historical value, they would have already entered hypothetical trades. but when you enable a strategy with limits orders, it is not uncommon to get all greens, which makes me suspicious

                      Comment


                        #12
                        Hello,

                        In this case you needed to make sure you are debugging your strategies correctly and checking there status to make sure everything is correctly operating.

                        Please see these guides:





                        Let me know if I can be of further assistance.

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by maybeimnotrader, Yesterday, 05:46 PM
                        2 responses
                        21 views
                        0 likes
                        Last Post maybeimnotrader  
                        Started by adeelshahzad, Today, 03:54 AM
                        5 responses
                        32 views
                        0 likes
                        Last Post NinjaTrader_BrandonH  
                        Started by stafe, 04-15-2024, 08:34 PM
                        7 responses
                        32 views
                        0 likes
                        Last Post NinjaTrader_ChelseaB  
                        Started by merzo, 06-25-2023, 02:19 AM
                        10 responses
                        823 views
                        1 like
                        Last Post NinjaTrader_ChristopherJ  
                        Started by frankthearm, Today, 09:08 AM
                        5 responses
                        22 views
                        0 likes
                        Last Post NinjaTrader_Clayton  
                        Working...
                        X