simple IB automated system

Discussion in 'Automated Trading' started by junkyard, Mar 27, 2008.

  1. junkyard


    I'm looking to automate a simple system with trades(stock trades) executed just prior to the close every day. I use Interactive Brokers. I know nothing of programming. Ideas? Best/easiest way to do this?
  2. You might be able to do it with Excel, but you'd still have to be good enough with Excel/programming to do it.

    What are the setups for the trades? Could you use the features of TWS? Pre-process limit order alerts in text files, then load with TWS?

    Probably we'd need to know more about what you are trying to do.
  3. Tums


    1. Hire someone to do the programming.


    2. Go to the library and grab a book on programming.
    Go to the library and grab a book on Auto-trading.
    Join an Auto-trade discussion group. (eg. Yahoo group).
  4. thrunner


    Don't be discouraged by this, it seems difficult and it will take a while, but it can be done. IB does not provide a simple facility for automated trading. Have you considered using other platforms to generate the trading signal?

    You could try a myriad of platforms out there that could do automated trading but one of the easier platform is Tradestation (TS). The language is called Easylanguage and is Pascal based and is fairly easy to read; in the following example a certain condition is met right before the end of the day and the strategy will buy at the close (in practice the time should be 1558 to ensure execution):


    You can do automated trading directly in TS or send the signal from TS to IB TWS API (via a third party software) for automated trading in your IB account.

    This is just one example of one platform. There are may more out there and you should do your own research and trials.
  5. m_kramar


    If you want to code something complex then you should hire a programmer. If your system is simple then you should do it yourself in one of the major traing platforms. It will take some time to learn but you will be able to change/improve your system yourself.
  6. Clym


    Hey Junkyard, This is very easy to do with excel so follow these instruction s and view this video for clarification.
    To modify IB’s excel Sample so that it sends all orders that you have typed in on the order entry page.
    Assuming you know nothing about VBA programming and/or are new to IB, here are the simple steps.
    1. Download the API from IB
    2. Enable DDE in TWS
    3. Open IB’s spreadsheet called TwsDde.xls
    Press Alt+F11 to open Visual Basic (or see the video)
    create a module and place this code in that module

    Sub sendorders()
    Dim ws As Worksheet
    Dim lastrow As Integer

    Set ws = Workbooks("TwsDde.xls").Worksheets("Orders")
    With ws
    'Select all orders that are to be sent
    lastrow = .Cells(rows.Count, "a").End(xlUp).row
    .Range(.Cells(12, 1), .Cells(lastrow, 1)).Select
    End With
    'sends the order
    Application.Run "TwsDde.xls!Sheet2.placeOrder"
    End Sub

    Place this in "ThisWorkbook" (see video)

    Private Sub Workbook_Open()
    'send orders before market close (change this to desired time)
    Application.OnTime TimeValue("02:59:45 pm"), "sendorders"
    End Sub

    4. Now save the workbook
    5. For testing purposes just run the “sendorders” procedure manually from list of Macros
    6. the sendorders procedure will run automatically at 02:59:45 pm.

    Even if this is not exactly what you want to do it should give you an idea how easy it is in excel.

    In my opinion this is the best beginner book to learn VBA for Excel. It’s 10 bucks, very clear and concise and covers a lot that is needed for creating automated trading systems in excel.
  7. ganesh6


    Which third party software can be used to send signal from TS to IB.
  8. I would be interested in this also.

    If anyone has implemented EL code and DDL's from NinjaTrader through TS2000i for automated trading, please PM me. Or post your pros and cons here for the practicality of getting this implemented through TS2000i.
  9. tradebullet - easy for noobs
    twslink - requires coding
    ninjatrader (i think)

    i'm sure there are several others.


    i think most are designed for 2000i, but i could be wrong
  10. junkyard


    Thanks for all the interest in my thread, all good tips.

    I would use TradeStation, however, I'm Canadian and last time I tried to open a TradeStation account to trade stocks they told me that I could only open a futures account(this was a couple years ago). Plus I already have an IB account.

    It sounds like I may need to learn to do some programming in Excel.

    My system is quite simple, always in the market, reverses position when a signal is triggered.
    #10     Mar 29, 2008