NexusFi: Find Your Edge


Home Menu

 





TWS and Excel


Discussion in Platforms and Indicators

Updated
      Top Posters
    1. looks_one TIFONTrader with 5 posts (0 thanks)
    2. looks_two arjfca with 3 posts (4 thanks)
    3. looks_3 comintel with 1 posts (1 thanks)
    4. looks_4 Fadi with 1 posts (3 thanks)
      Best Posters
    1. looks_one Fadi with 3 thanks per post
    2. looks_two arjfca with 1.3 thanks per post
    3. looks_3 comintel with 1 thanks per post
    4. looks_4 FalseProphets with 1 thanks per post
    1. trending_up 11,252 views
    2. thumb_up 10 thanks given
    3. group 7 followers
    1. forum 11 posts
    2. attach_file 0 attachments




 
Search this Thread

TWS and Excel

  #1 (permalink)
 
TIFONTrader's Avatar
 TIFONTrader 
Prague Czech Republic
 
Experience: Beginner
Platform: Sierra Chart, daytradr
Broker: EdgeClear
Trading: Eurex Futures
Posts: 517 since Nov 2011
Thanks Given: 1,339
Thanks Received: 451

Hello,

I am using Excel with XLQ plugin for extracting daily data from yahoo and intraday from IB.
I was wondering whether there is any magician who is able to program a way how to automatically send orders from Excel to TWS.

Thanks and successful trading.
Hana

Follow me on Twitter Visit my NexusFi Trade Journal Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
ZombieSqueeze
Platforms and Indicators
What broker to use for trading palladium futures
Commodities
MC PL editor upgrade
MultiCharts
Trade idea based off three indicators.
Traders Hideout
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
 
  #2 (permalink)
 
Fadi's Avatar
 Fadi 
Luxembourg
 
Experience: Advanced
Platform: NinjaTrader
Broker: IB / Kinetick
Trading: ES, CL
Posts: 485 since Apr 2012
Thanks Given: 667
Thanks Received: 648


hadamkov View Post
Hello,

I am using Excel with XLQ plugin for extracting daily data from yahoo and intraday from IB.
I was wondering whether there is any magician who is able to program a way how to automatically send orders from Excel to TWS.

Thanks and successful trading.
Hana

Check the recorded webinars: https://individuals.interactivebrokers.com/en/general/education/priorWebinars.php?ib_entity=llc

Successful people will do what unsuccessful people won't or can't do!
Follow me on Twitter Reply With Quote
Thanked by:
  #3 (permalink)
 
TIFONTrader's Avatar
 TIFONTrader 
Prague Czech Republic
 
Experience: Beginner
Platform: Sierra Chart, daytradr
Broker: EdgeClear
Trading: Eurex Futures
Posts: 517 since Nov 2011
Thanks Given: 1,339
Thanks Received: 451





Thanks, I will check out the DDE and Excel API.
H

Follow me on Twitter Visit my NexusFi Trade Journal Started this thread Reply With Quote
  #4 (permalink)
 arjfca 
Montreal, Canada
 
Experience: Intermediate
Platform: Multicharts
Broker: Interactive Broker
Trading: Forex
Posts: 263 since Sep 2010
Thanks Given: 440
Thanks Received: 91


hadamkov View Post
Hello,

I am using Excel with XLQ plugin for extracting daily data from yahoo and intraday from IB.
I was wondering whether there is any magician who is able to program a way how to automatically send orders from Excel to TWS.

Thanks and successful trading.
Hana

Did you resolve your problem? I'm sending Excel to send orders to IB via TwsLink2 (api and function). I'm not an expert at all, but I did succeed to send orders

Now, I'm looking for a way to receive a confirmation that an order as been executed.

Good luck

Martin

This code send a long stop order with a time ( after and before) validation ( order cancel after a given time by IB).
Attached to hit, a stop order is send. It will be activated if the stop entry is activated. It will be cancelled at the same time if the initial order is not triggered within the proper allowed time

 
Code
 UidParentOrder = _
            TwsLink.PLACE_ORDER(UidContract, Uidorder, Action, OrderType, QT, _
            LimitEntry_Long, StopEntryPrice_1, Duration_Entry, NotTransmit, 0)
        ' Set a commentary string
        
        If GTD <> "" Then
            setOValue = TwsLink.SET_ORDER_VAL(UidParentOrder, 9, GTD, Transmit)
            setOValue = TwsLink.SET_ORDER_VAL(UidParentOrder, 8, GAD, Transmit)
        End If
        Setup = "L"
        setOValue = TwsLink.SET_ORDER_VAL(UidParentOrder, 49, WorksheetFunction.Clean("ETy Lg: " & Iscale & Str(QT / 1000) & "K@" & Str(StopEntryPrice_1) & GTD & " til " & GAD & Space(1) & Setup & Space(1)), Transmit)
       
            
        'MsgBox (UidParentOrder & ", " & 8 & ", " & GAD & ", " & -1)
        
        Uid_StopOrder = _
            TwsLink.PLACE_ORDER(UidContract, Uidorder, ReverseAction, "STP", QT, _
            ExitLimitPrice_2, StopIbEntryPrice_1, Duration_Exit, NotTransmit, UidParentOrder)

Reply With Quote
Thanked by:
  #5 (permalink)
 
TIFONTrader's Avatar
 TIFONTrader 
Prague Czech Republic
 
Experience: Beginner
Platform: Sierra Chart, daytradr
Broker: EdgeClear
Trading: Eurex Futures
Posts: 517 since Nov 2011
Thanks Given: 1,339
Thanks Received: 451

Thanks Martin,

I gave up . I am still entering orders manually but it is just a ten-minute procedure each day so I do not worry about it.

H

Follow me on Twitter Visit my NexusFi Trade Journal Started this thread Reply With Quote
  #6 (permalink)
 arjfca 
Montreal, Canada
 
Experience: Intermediate
Platform: Multicharts
Broker: Interactive Broker
Trading: Forex
Posts: 263 since Sep 2010
Thanks Given: 440
Thanks Received: 91


hadamkov View Post
Thanks Martin,

I gave up . I am still entering orders manually but it is just a ten-minute procedure each day so I do not worry about it.

H

Is your bug is with Excel or with the API?
The best site that I know for Excel help is MrExcel.com... Forum. Can't get better for the price... free


You could try TWSLINK free for 1 month. The site as some example on how to set it. Never work with Ib API directly. A friend of has done it do.



1' First you have to Connect to IB using the proper port
 
Code
 connected = TwsLink.connect(Host, Port, 1, delayed)
2' You need to get your contract UID (here Eur.Usd)
 
Code
Sub GetEurUsdUIDConTract()
    If TwsLink Is Nothing Then
        Set TwsLink = CreateObject("twslink2.twslinkCom")
    End If
    UidContract = TwsLink.REGISTER_CONTRACT("EUR", "CASH", "USD", "IDEALPRO", "", "", "", 0#, "", 0, 0#)
   
End Sub
3' Then and only then you would be able to send an order
 
Code
Sub PlaceA_BuyLimitContract()
    If TwsLink Is Nothing Then
        Set TwsLink = CreateObject("twslink2.twslinkCom")
    End If
    Uid_Buy_Limit = TwsLink.PLACE_ORDER(UidContract, 0, "BUY", "LMT", 30000, 1.3, 0#, "GTC", 1, 0, "", "", -1)
    Uid_Buy_Limit = TwsLink.PLACE_ORDER(UidContract, Uid_Buy_Limit, "BUY", "LMT", 30000, 1.303, 0#, "GTC", 1, 0, "", "", -1)
        
End Sub

Reply With Quote
Thanked by:
  #7 (permalink)
 
TIFONTrader's Avatar
 TIFONTrader 
Prague Czech Republic
 
Experience: Beginner
Platform: Sierra Chart, daytradr
Broker: EdgeClear
Trading: Eurex Futures
Posts: 517 since Nov 2011
Thanks Given: 1,339
Thanks Received: 451


arjfca View Post
Is your bug is with Excel or with the API?
The best site that I know for Excel help is MrExcel.com... Forum. Can't get better for the price... free


You could try TWSLINK free for 1 month. The site as some example on how to set it. Never work with Ib API directly. A friend of has done it do.



1' First you have to Connect to IB using the proper port
 
Code
 connected = TwsLink.connect(Host, Port, 1, delayed)
2' You need to get your contract UID (here Eur.Usd)
 
Code
Sub GetEurUsdUIDConTract()
    If TwsLink Is Nothing Then
        Set TwsLink = CreateObject("twslink2.twslinkCom")
    End If
    UidContract = TwsLink.REGISTER_CONTRACT("EUR", "CASH", "USD", "IDEALPRO", "", "", "", 0#, "", 0, 0#)
   
End Sub
3' Then and only then you would be able to send an order
 
Code
Sub PlaceA_BuyLimitContract()
    If TwsLink Is Nothing Then
        Set TwsLink = CreateObject("twslink2.twslinkCom")
    End If
    Uid_Buy_Limit = TwsLink.PLACE_ORDER(UidContract, 0, "BUY", "LMT", 30000, 1.3, 0#, "GTC", 1, 0, "", "", -1)
    Uid_Buy_Limit = TwsLink.PLACE_ORDER(UidContract, Uid_Buy_Limit, "BUY", "LMT", 30000, 1.303, 0#, "GTC", 1, 0, "", "", -1)
        
End Sub


Thanks a lot! I think the bug is in my head (or hands ). I will try again as soon as the manual order entry frustrates me again...
Thanks for the link to the forum.
H.

Follow me on Twitter Visit my NexusFi Trade Journal Started this thread Reply With Quote
  #8 (permalink)
 comintel 
Raleigh NC USA
 
Experience: Advanced
Platform: CTS T4 and TradeStation
Trading: Oil
Posts: 17 since May 2011
Thanks Given: 0
Thanks Received: 7


hadamkov View Post
Thanks, I will check out the DDE and Excel API.
H


Note that there is now also an ActiveX API that should be faster and more reliable than the older DDE one.

Reply With Quote
Thanked by:
  #9 (permalink)
FalseProphets
Toledo, OH
 
Posts: 41 since Nov 2012
Thanks Given: 16
Thanks Received: 46

Hi,
The templates that come with IB API options are a great starting point. You can achieve all in your wishlist and more with them. As an advisor, i cannot use Ninja anymore as they dont support Multiple accounts. So i had to build my own and I used the ActiveX technology to do it.
All the best!

Reply With Quote
Thanked by:
  #10 (permalink)
schematics12
Los Angeles, CA
 
Posts: 14 since Jan 2016
Thanks Given: 0
Thanks Received: 5


Here is another interesting Excel spreadsheet, based on IB ActiveX API and serves as a template for implementing your trading rules for Interactive Brokers. Also lets you trade manually, I like their bracket orders feature.

Take a look, I've been using it recently and pretty happy with it:

Interactive Brokers Excel Trader - Trading Geeks

Reply With Quote
Thanked by:




Last Updated on January 29, 2016


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts