Quote from 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?
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.