Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

After hours automated trading with interactive brokers

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

    After hours automated trading with interactive brokers

    Hi,

    my goal is to trade stocks with ATM and or strategies at interactive brokers after hours. I thought that NinjaTrader was the solution for this but it's not possible out of the box from what I see. Let me explain a typical scenario that I am trying to achieve and the obstacles I am facing, if you could give me any help getting there it would be greatly appreciated.

    my goal:
    - I'd like to buy stocks that get good news outside of regular trading hours, and apply a trailing stop loss to sell if the momentum doesn't hold.

    the problems I am facing are:
    - the ATM feature would be just perfect for me, but I am disappointed to see that you cannot put any sell limit in a ATM for equities, which is well supported in normal strategies
    - if I try to build a strategy with complex rules of manually programmed trailing stop losses (so I can enter a limit sell offset), the synchronize account feature is not working, because it's only trying to flatten or whatever catch up with my account with market orders, which again are not supported after hours. So I cannot use my strategies neither for the moment.

    So whatever I do, all my orders are rejected by ibkr outside of regular hours because they're always market orders.

    I tried to unlock the code to add the adopt account feature in the script, but I am a newbie coming from python and at this point, I am wondering if I have chosen the right software for automated stocks trading. I know you all think that NT is for futures, but I loved the simulated trading and I would like it to work, I've bought the lifetime license anyway lol. Thanks for your help and opinions.

    #2
    Hi RT001, thanks for posting.

    In the ATM editor, expand "More" and there will be an option to set the sell stop market order to a sell limit order for your stop loss. The subject of NinjaScript Strategies is also a viable option and provides maximum flexibility. We do recommend those starting out with NinjaScript be intermediate to advanced level in C# object oriented programming. To add the adopt account position startup behavior, just add this line to the State.SetDefaults section of the OnStateChanged method:

    if (State == State.SetDefaults)
    {
    IsAdoptAccountPositionAware = true;
    }

    After adding this you will see the Adopt Account Position option for strategy startup.

    Please let me know if you have any other questions.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_ChrisL View Post
      Hi RT001, thanks for posting.

      In the ATM editor, expand "More" and there will be an option to set the sell stop market order to a sell limit order for your stop loss.
      Hi Chris, I believe the documentation states that this feature is not working for stocks, so your comment is a little bit misleading in my explained scenario, right?

      Comment


        #4
        Hello RT001,

        I believe you are referring to the Help Guide note below.

        Note: The "Stop Limit for Stop Loss" will not apply to Equities or Forex instruments, as these markets do not support Stop Limit orders. If this property is enabled when trading a stock or forex instrument, Stop Market orders will be used, instead.
        https://ninjatrader.com/support/help...ed_options.htm

        Attempting to use Stop Limit orders with a broker/market that does not support them will result in an order rejection. You may be able to use logic in a NinjaScript strategy to submit an order when the price hits a certain level, but this would not be the same thing as a Stop Limit order. For example, if you wait for a price to hit for the stop price of an imaginary Stop Limit order, you could then wait for the price to hit the limit price of the imaginary Stop Limit order, and then submit a market order to close the position, but you still may get slippage as the order to close the position is a market order.

        As for using AdoptAccountPosition, it works nicely to skip historical processing and submit the target and stop once the strategy transitions to realtime data. Attached are a few examples.



        Attached Files
        JimNinjaTrader Customer Service

        Comment


          #5
          Thanks for your help Jim and Chris,

          it would be awesome to add the possibility to close an ATM strategy with a limit sell order, so it works with equities outside of regular trading hours. Since that logic is already possible with strategies, you would think that it could be not too complicated to implement that feature in the ATM toolset - and it would be so useful.

          Thanks for the ninja script examples, this is indeed the road that I am taking now.

          Comment


            #6
            Originally posted by RT001 View Post
            it would be awesome to add the possibility to close an ATM strategy with a limit sell order, so it works with equities outside of regular trading hours. Since that logic is already possible with strategies, you would think that it could be not too complicated to implement that feature in the ATM toolset - and it would be so useful.
            To NinjaTrader Support,

            When designing an ATM strategy,
            Isn't a Sell Limit order automatically used for the profit target for Long positions?
            Isn't a Buy Limit order automatically used for the profit target for Short positions?

            I confess I only trade Futures.
            I confess I am ignorant about trading stocks w/NT using Interactive Brokers.

            Is OP saying those order types are not supported with stocks?
            --Or--
            Is OP saying those order types are not supported with stocks at Interactive Brokers?

            I was under the assumption Buy/Sell Limit orders were pretty fundamental
            and well supported by every broker on the planet, and that the NinjaTrader
            platform supported those order types inside ATM strategies for all instruments.

            What am I missing?
            Last edited by bltdavid; 07-28-2021, 09:40 AM.

            Comment


              #7
              Not sure if I am mixing things up myself, but to summarize as much as possible:

              With any ATM strategy, Interactive Brokers (and the NT Executions log) receives any equity stop loss order as a market order, which do not work outside of regular trading hours. Same for the synchronize feature of the strategies, they all are executing as a market order only.

              Bottom line is I would like my stop loss threshold to trigger a limit sell order so I can use them outside of regular trading hours.

              Comment


                #8
                Hello bltdavid and RT001,

                Limit orders are used for the profit target for ATM strategies across with all brokers and asset types.

                If you select Use Stop Limit for Stop Loss in an ATM strategy's Advanced Options, a Stop Limit order will be used for the stop loss. However, if you are trading FOREX or Equities, the ATM strategy will automatically convert that order to a Stop Market order.

                Just testing that now on Interactive Brokers, I was able to place a Stop Limit order manually to a paper trading account, but I could not do so with the ATM strategy on FOREX or Equities because the ATM strategy converts the stop loss to the Stop Market order.

                I do not think this should be the case and I believe this is something that can be improved. I submitted an internal ticket to have this looked at with the Development team. I will follow up after they have been able to look into this and if changes can be made in the near term.
                Last edited by NinjaTrader_Jim; 07-28-2021, 11:59 AM.
                JimNinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by NinjaTrader_Jim View Post

                  I do not think this should be the case and I believe this is something that can be improved. I submitted an internal ticket to have this looked at with the Development team. I will follow up after they have been able to look into this and if changes can be made in the near term.
                  This would be so awesome Jim, thanks for taking the time to look into the issue.

                  I understand you guys have limited dev capacities, but ATM is the feature #1 that brought me to NT, I am disappointed to find out that I cannot use it after hours - while the feature is simple and possible under the hood in the software. With all the feature tracking numbers floating around, it would be great if it could be improved in the near term indeed. Thanks for your help!



                  Comment


                    #10
                    Hello RT001,

                    I do not expect conversion to a Stop Market order from a Stop Limit order as the issue for after hours trading. With Interactive Brokers, I would suggest ensuring that you have enabled "Trigger After Hours" in your connection settings for the Interactive Brokers connection in NinjaTrader, and that you have also have "Allow order to be activated, triggered, or filled outside of regular trading hours" checked in Trader Workstation/IB Gateway.

                    Interactive Brokers describes changing this property here (publicly available link)
                    JimNinjaTrader Customer Service

                    Comment


                      #11
                      Thanks Jim, my IBKR settings are ok, and I do not want market orders but rather limit orders for after hours trading.

                      Comment


                        #12
                        Hello RT001,

                        The setting I recommended above would be suggested for submitting orders so they are active after hours with Interactive Brokers.

                        As for changing the ATM strategy Stop Limit For Stop Loss behavior, there is a sound argument that this may be supported at the broker level but may not be supported at the exchange level. This makes it more complicated to have a definitive rule for converting the order in ATM strategies for assets that may likely not support the order type at exchange level.

                        As such, we will be tracking interest behind this before making a change. Your interest is being tracked in the Change Request ticket ID SFT-3711. This is an internal number, but for anyone else wishing to have their interest tracked, please let our support staff know that you would like a vote added for this request.

                        Feature Request Disclaimer

                        We receive many requests and cannot reasonably implement all requested features or changes. Interest is tracked internally and if enough interest is tracked, it would be weighed against how feasible it would be to make those changes to consider implementing. As such we cannot offer an ETA or promise of fulfillment.

                        When new features are implemented, they will be listed in the Release Notes page of the Help Guide. The ID number will be different than the internal feature request tracking ID, but the description of the feature will let you know if that feature has been implemented.

                        Release Notes - https://ninjatrader.com/support/help...ease_notes.htm


                        JimNinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by johnMoss, Today, 04:06 PM
                        0 responses
                        2 views
                        0 likes
                        Last Post johnMoss  
                        Started by agraham, Today, 01:05 PM
                        0 responses
                        25 views
                        0 likes
                        Last Post agraham
                        by agraham
                         
                        Started by jagswe, Today, 01:34 PM
                        0 responses
                        13 views
                        0 likes
                        Last Post jagswe
                        by jagswe
                         
                        Started by PaulMohn, Yesterday, 05:25 AM
                        9 responses
                        34 views
                        0 likes
                        Last Post NinjaTrader_PaulH  
                        Started by srbdoc, Today, 12:20 PM
                        1 response
                        8 views
                        0 likes
                        Last Post NinjaTrader_ChristopherJ  
                        Working...
                        X