IB - "Automatic" intraday trades without using API

Discussion in 'Interactive Brokers' started by TiC, Nov 11, 2019.

  1. TiC

    TiC

    Hi,

    My trading strategy involves staying long when share price is higher than 20D MA, immediately sell at market intraday when share price drops below 20D MA, but buy back again if share price moves back higher than 20D MA. The 20D MA is calculated daily before market opens, using the close prices for the past 20 sessions, and will stay as one value throughout the day. I have some good back-testing results for momentum stocks. I know nothing about API - but I am utilizing the parent/child + conditional orders in IB. I would be most grateful if anyone can point out whether there is a smarter way to achieve the same strategy, or if this simply won't work:

    - Say I already owned 100 shares of TSLA, and before market opens today, I calculated the 20D MA to be $335
    - Stock opens at $337
    - In IB, my parent order (1.0) is to sell 100 shares at market via IEX with a conditional trigger when share price drops below $335. I didn't use Stop order as it may not work well if the stock gaps down a lot at open. I didn't use market sell via SMART as the slippage seems large. I didn't use adaptive or other algos as they are not allowed in conditional parent-child orders
    - A child order (1.1) is created, and will be triggered only if 1.0 is completed. This is to buy at market via IEX if share price > $335
    - A sub-child order (1.2) is added, and will be triggered only if 1.1 is completed. This is to sell at market via IEX if share price < $335
    - A series of orders is repeated this way

    My worry is that the orders will all be executed very quickly if the share price bounds within a narrow range. I was hoping to add a 5-min waiting time between orders but seems cannot be done in IB.

    Any comments are welcome. Thanks!
     
  2. Will you be watching your TWS screen the entire trading day while your strategy is at work? Or do you want it to operate autonomously, without you being present?
    I haven't tried in TWS how many "children-of-children" orders you can enter. This seems to be an important parameter for your strategy.
     
    isc1746 likes this.
  3. d08

    d08

    Don't enter at the same exact price unless you really really have to. So buy at 336 and sell at 334, that will give you leeway.

    Other than that, you'd need to use the API in which case it would be relatively straightforward. These are the cases for which the API is for, after all. Because you don't know how many times the price might fluctuate over your trigger, it can be none or it can be 50. Adding that many orders seems to be a recipe for distaster and can potentially end up a nightmare since no tracking of open positions is kept.
     
    Metamega likes this.