Home › Forums › Trading System Mentor Course Community › Running Your Trading Business › Exploration for Interactive Brokers DDE
- This topic is empty.
-
AuthorPosts
-
February 22, 2016 at 8:49 pm #101437Nick RadgeKeymaster
Dynamic Data Exchange (DDE) is a method that allows an excel spreadsheet talk directly with other platforms, specifically in this example we’re talking about the Interactive Brokers TWS platform. A DDE allows a fast upload of orders and can be extremely useful for mean reversion systems that can generate a lot of orders on a given day.
Below is exploration code that will generate an output that you can ‘cut and paste’ and insert into the IB DDE. This will also allow you to do your position sizing within AmiBroker which in turn will auto generate the orders for you.
Code:AccB = Param(“Explorer: Account Balance”,100000,1,1000000,1);
PcntRisk = Param(“Explorer: % Equity”,10,1,100,0.01);
STB1 = round((AccB*PcntRisk/100)/BuyLim);BO1 = LETrigger;
SetOption(“NoDefaultColumns”,True);
Filter = LETrigger;
Width = 65;
Width1 = 75;
if(Status(“action”)==4)
{
SetSortColumns(1);
}
AddTextColumn(WriteIf(BO1,”” + Name(),””),”Symbol”,1.3,29,55,90);
AddTextColumn(WriteIf(BO1,”STK”,””),”Type”,1.3,29,55,80);
AddTextColumn(WriteIf(BO1,””,””),”Expiry”,1.3,29,55,Width);
AddTextColumn(WriteIf(BO1,””,””),”Strike”,1.3,29,55,Width);
AddTextColumn(WriteIf(BO1,””,””),”P/C”,1.3,29,55,Width);
AddTextColumn(WriteIf(BO1,””,””),”Multiplier”,1.3,29,55,Width);
AddTextColumn(WriteIf(BO1,””,””),”Trading Class”,1.3,29,55,Width);
AddTextColumn(WriteIf(BO1,”SMART”,””),”Exchange”,1.3,29,55,80);
AddTextColumn(WriteIf(BO1,””,””),”Primary Exchange”,1.3,29,55,Width);
AddTextColumn(WriteIf(BO1,”AUD”,””),”Currency”,1.3,29,55,Width);
AddTextColumn(WriteIf(BO1,””,””),”Comb Legs”,1.3,29,55,Width);
AddTextColumn(WriteIf(BO1,””,””),”Leave This Empty”,1.3,29,55,Width1);
AddTextColumn(WriteIf(BO1,”Buy”,””),”Action”,1.3,29,55,Width);
AddTextColumn(WriteIf(BO1,””+STB1,””),”Quantity”,1.0,29,55,Width);
AddTextColumn(WriteIf(BO1,”LMT”,””),”Order Type”,1.3,29,55,Width1);
AddTextColumn(WriteIf(BO1,””+BuyLim,””),”Lmt Price”,1.3,29,55,Width);
AddTextColumn(WriteIf(BO1,””,””),”Aux Price”,1.3,29,55,Width);
AddTextColumn(WriteIf(BO1,””,””),”Ctrl”,1.3,29,55,Width1);
AddTextColumn(WriteIf(BO1,””,””),”Id”,1.3,29,55,Width1);
AddTextColumn(WriteIf(BO1,””,””),”Status”,1.3,29,55,Width1);
AddTextColumn(WriteIf(BO1,””,””),”Filled”,1.3,29,55,Width1);
AddTextColumn(WriteIf(BO1,””,””),”Remaining”,1.3,29,55,Width1);
AddTextColumn(WriteIf(BO1,””,””),”Ave Fill Price”,1.3,29,55,Width1);
AddTextColumn(WriteIf(BO1,””,””),”Last Fill Price”,1.3,29,55,Width1);
AddTextColumn(WriteIf(BO1,””,””),”Parent Id”,1.3,29,55,Width1);
AddTextColumn(WriteIf(BO1,”DAY”,””),”Time in Force”,1.3,29,55,Width1);March 14, 2016 at 5:26 am #102877AnonymousInactiveNick Radge wrote:Below is exploration code that will generate an output that you can ‘cut and paste’ and insert into the IB DDE. This will also allow you to do your position sizing within AmiBroker which in turn will auto generate the orders for you.Hi Nick/All,
Any recommendations of an excel spreadsheet / application capable of this?March 14, 2016 at 5:32 am #102878Nick RadgeKeymasterYou copy the output and paste straight into a blank CSV or XLS depending on how you’re uploading.
My API uses a CSV but not sure what the default IB DDE uses.
Here’s the info from IB: https://www.interactivebrokers.com/en/index.php?f=5041
March 14, 2016 at 5:38 am #102879Nick RadgeKeymasterI should add that this is just for generating the entry orders and not the exits.
So I use three sets of code for the system:
MCS – for backtesting etc
Exploration – for generating buy and sell signals
DDE – for generating orders to send through the API to IBMarch 22, 2016 at 3:08 pm #103002StephaneFimaMemberHi,
I’ve just tried the IB Excel DDE and I was just about going crazy because it was not working. After 1 day of reseach, I found what was wrong and it is really simple:
1) I rounded the quantity figure with “AddTextColumn(WriteIf(BO1,””+Round(STB1),””),”Quantity”,1.0,29,55,Width);” as TWS doesn’t like commas.
2) I had to leave the “Time in Force” column blank, so I deleted “AddTextColumn(WriteIf(BO1,”DAY”,””),”Time in Force”,1.3,29,55,Width1);” in the codeWith those two modifications, this is perfectly working and it’s really quick and nice now.
March 23, 2016 at 8:18 am #102880TrentRothallParticipantThankyou that might help me also! Frustrating at the moment!
I am getting an error msg saying “no security definition has been found for your request” will keep hunting!
March 23, 2016 at 8:53 pm #102881Nick RadgeKeymasterTrent – are you using the DDE or my API?
March 23, 2016 at 11:58 pm #102882TrentRothallParticipantIB DDE, as i understand from our chat the other day i basically only need it for bulk uploads on the ASX, no position monitoring?
March 24, 2016 at 2:24 am #103444Nick RadgeKeymasterYes, but why not use the API you already have?
-
AuthorPosts
- You must be logged in to reply to this topic.