MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_NextPart_01C696B3.0D43D720" This document is a Single File Web Page, also known as a Web Archive file. If you are seeing this message, your browser or editor doesn't support Web Archive files. Please download a browser that supports Web Archive, such as Microsoft Internet Explorer. ------=_NextPart_01C696B3.0D43D720 Content-Location: file:///C:/0EAC30E5/IB_DirectV4QuickGuide.htm Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset="us-ascii"
IB_Direct
V4.015 Beta
DRAFT
Friday, June 23, 2006Prerequi=
sites
& Recommendations
Starting the IB_Direct program
On the
Adjusting stop/limit prices (primary order)=
Ø
Ø The IB TWS works within t= he Java Run-Time environment. It= is highly recommended to upgrade to the latest Java Virtual Machine (currently v1.6 with or without SDK)
Ø
Java and the TWS can use =
up a
substantial amount of RAM. To
ensure there isn’t excessive paging, RAM specs are as follows:
&=
nbsp; Minimum:
256MB (Recommended: 512MB or =
more)
Ø The latest IB API must be first installed. However, the IB API is almost in permanent beta stage, and is very poorly documented. This has not made programming arou= nd it very easy. At this time, the current version works with API V8.8 (May 2006). Please note that the API interface sometimes changes radically with a seemingly minor update, and may cause = u>IB_Direct to stop functio= ning. In such rare e= vents, please downgrade to the previous API until I fix the IB_Direct calls according to the new interface. One can only hope the API interfac= e will soon stabilize.
Ø If the API Setup does not automatically register the TWS.OCX, the program will crash upon loading the main form. Please register it manually the following command: “regsvr32 C:\JTS\ActiveX\Tws.OCX̶= 1; (you may have to change the path according to actual location).
Ø The program setup may req= uire the .NET framework from Microsoft. It is usually installed along with Windows XP but can also be downlo= aded separately at http://msdn.microsoft.com/netframework/downloads/updates/default.aspx= a> . IB_Direct requires the following files which are bundled in the setup file: MFC70.DLL, MSVCI70.DLL, and MSVCR70.DLL (or later versions). Please contact me in case the setup program does not install them correctly.
Ø
It is essential to fully
understand how orders are processed at IB for the exchange being traded.
Ø Lastly, although not requ= ired, a multiple screen setup is recommended.
The ultimate purpose of the = IB_Direct program is to handle signals coming from an automated trading system and send orders automatically to IB thro= ugh the TWS Java console. Its functionalities are more straightforward than this (too) long document may suggest.
The IB_Direct program in the
current version is not yet linked to an external signal source, hence orders
are entered manually into the IB TWS at a click of a button hence allowing =
fast
safe simple trading (scalping strategy).&n=
bsp;
While the TWS Java console(s) need to be running along with IB_Direc=
t,
they can be minimized as IB_Direct represents the essential trading “dashboard”.
The user interface has been designe= d to be as intuitive as possible. I h= ave tried my best to keep it as simple and as uncluttered as possible… = span>
This walk-through guide will start = with running the program and describe its program design and layout. As we go along, it will then expla= in in details how to handle different order set-ups.
When the program starts, the user is prompted to enter the number of IB = TWS (local or remote)[2]= consoles he will wish to connect to. 3 concurrent IB accounts[3] (i.e. 3 separate TWS instances) can be linked at this time.
=
Fig 1
(Layout may change in final release)
What do we see on this screenshot (= Fig1 on page 3)?
Ø On the left side is a lis= t box where to select the number of IB accounts the user wishes to link to. That number of IB accounts[4] (1, 2 or 3), like most settings in the program, is saved as default in the Windows™ Registry= . As displayed above in the dialog bo= x, the 1st IB account must have a valid[5] data subscription[6] with IB.
Ø An = IB_Direct session id or session number has been added. This allows to fully separate sett= ings in the Registry in case several instances of = IB_Direct run concurrently for different instruments. Each instance can then connect independently to the same IB TWS Java consoles.
Ø Registration will enable = IB_Direct to run permanently = after the trial period has expired. A serial code or license will be issued per user on a single PC. This license will also be linked to hardware (HD serial number). = This feature is not activated yet in this BETA version.
Ø This initial form also of= fers an Internet Time Synchronization (“Time Sync” button) based on = the RFC868 protocol. IB_Direct must be firewall-enabled to connect to the Internet Time Serv= er (time.ien.it by default). The= time sync may take some time depending on connection speed and server availabili= ty. It is run in a different thread wh= ich can be interrupted if necessary. = When time is returned from the Internet Server, system time is also updated on y= our PC (admin privileges are required with Win2K, Win XP).
Ø The program also checks f= or the API version. It will display = an alert if an upgrade is required, and then close. The current IB_Direct build works w= ith the last API v8.71 which seems to be quite stable.
Ø In the final release, this dialog will also display a “Check for Update” button.
On rare occasions, it may be necess= ary to clear all registry settings. = Such option has been added to the system menu (program icon at top left corner of the window). A major program release may also force automatic reset of those settings to predefined defa= ult values.
When ready, just press
“Proceed”, or the Enter key to continue.
The IB_Direct=
main dialog
After pressing “Proceed”= ;, the main I= B_Direct form should now be displayed as shown below. Its footprint has been substantially reduced from earlier versions.
Fig 2 (Actual layout ma=
y change
slightly in final release)
In a nutshell, the above dialog is = composed of a ticker area, order buttons (arrows), program menu buttons, and optiona= l info area at the bottom.
Before describing these various ele= ments on this main form, let’s first take a look at the system menu (top left = icon on the main dialog above), to which a few custom items have been added.
System menu
Ø “Settings”, “Connect” and “Disconnect” are just function copies= of the buttons on the main dialog form.
Ø “Reset buttons status” has been left while debugging the program, and may be of use = in some rare occasions. In normal trading operations, an entry/exit button is disabled after being clicked in order to avoid entering multiple positions by mistake. In some cases, a trader may howeve= r also want to scale the current position up or down. The program has not been fully tes= ted for this trading mode though. On many occasions, new features have been coded to see them added to the API a= few months later. Let’s hop= e IB will do something about this functionality.
Ø “Enable/disable ord= er button control”. As said above, one may choose to disable buttons to = make sure that an exit always follows an entry.
Ø “Clear Order Ids in Registry” will reset recorded order Ids. It may sometimes be needed p= articularly in the situation where the user has placed/cancelled orders directly into t= he TWS, thus creating a possible discrepancy in order numbering.
Ø
“Clear Connect
Ports”: if a connection to the TWS fails for any reason, the ports
settings can be cleared here instead of closing IB_Direct altogether. By default, IB_Direct will always c=
onnect
through the same ports, e.g. 7496 for TWS1, 7497 for TWS2, 7498 for TWS3.=
span>
Ø “Clear All Registry Settings”. Same as on the initial dialog, all registry settings can be cleared here.
Ø “Return to MKT order type”. When one enters a trade Limit or Stop, one may forget to reset order type to Market, which se= ems sensible in case one wants to get quickly out of a position. If this option is ticked, order ty= pe will be reset to MKT on fill confirmation of STP or LMT entry order.=
Ø “Request IB news bulletins”[7]= . There are several levels of news bulletins which can be sent to the Info/Status window if so desired. A dialog is displayed to select the filter level.
Ø
“Set Log Level̶=
1;. IB
Ø “Window stays on top”
Ø “About IB_Direct= 221;
Let’s now take a closer look at the main elements now displayed:
The upper left list containing pric= es is the ticker received in real time from IB.&= nbsp;
=
Fig 4
The ticker starts automatically upon connection. Bid, Ask and Last= prices[8] are displayed, along w= ith 1 Tick Up and 1 Tick Down prices. Double-clicking a price sets a limit price for the next order (order type is also changed to LMT). For instance, a double click on the Bid price (1145.25) followed by a Buy will = send a “BUY 2 ES LMT 1145.25” order to IB. This will be explained again later= in this document.
The ticker can be stopped using the= On/Off buttons if deemed distracting. The ticker is however required in mo= st cases, unless one chooses to trade market orders only (quick scalpi= ng, reversal strategies for instance).
The time displayed on the left is t= he last ticker update. The figure on = the right (381) is the number of contracts or shares traded in the last minute. It may be an indicati= on of low trading activity. Please = note however that volume reported by IB does not always seem to tally with volume figures reported by other data sources. This situation may improve now that= IB also provides data streams through the API (since v8.50).
Entries and exits use the same butt= ons as shown here (arrows):
They can alternatively be displayed by acronyms (below). In doubt, all buttons have context= tips (mouse hover). The acronym ve= rsion is disabled at present, but it can be reinstated if arrows seem confusing.<= /span>
BE is Buy Entry. BX is Buy Exit. BR= is Buy Reverse (exit long then entry short), etc…
In order to make sure entries or ex= its are not duplicated, only allowed buttons[9] are enabled by default. IB would otherwise f= or instance let you enter into a buy by pressing SX twice. In case of a bug, or to override t= his feature, button status can be reset in the system menu.
Please note that pressing the order= button is in a way a confirmation of any prior setting, particularly the Order Type and Price for Stop or Limit orders. There is no added confirmati= on box here. In other words, everything has first to be correctly defined. This particularly applies to Limit= and Stop entries or exits.
Settings remain unchanged after the= order is sent through, i.e. by default a Bid/Ask type entry will be followed by a Bid/Ask exit. You may however= want to enter limit and exit market. It is actually recommended to revert back to Market order once entry has been filled and manage the open position with optional attached stop and limit orders.
=
Fig 6
These buttons are placed on the rig= ht of the main dialog.
Ø ON and OFF are connection buttons to the IB TWS.
Ø The next button below with tools displays the Settings dialog (opened automatically upon valid connect= ion to the TWS).
Ø “Info” displays the Sta= tus / Info window.
Ø “S/L Entry” displays a modeless form where the user can set or adjust Stop/Limit entry price(s)
Ø “S/L Exit” di= splays a modeless form where the user can set or adjust Stop / Limit exit prices.<= span style=3D'mso-spacerun:yes'> It is recommended to exit a positi= on that way.
Ø MktDepth or AdvMktDepth d= isplay additional information about the order book. AdvMktDepth can be used to place /= amend orders. Since most trading operations can be carried out from the AdvMktDepth features, a specific sec= tion is available later in this document.
Ø “Refresh” sen= ds a message to IB to refresh the open[10] order status.<= /p>
Ø “Cancel” as i= ts name says, cancels the currently pending open order[11].
Order type is defined with the list box (see right).
Valid order types vary according to exchanges, and IB will in most cases offer a simulated order type if not supported natively by the exchange.
Order types currently supported by = the API are:
Ø
MKT &=
nbsp; &nbs=
p; in
I=
B_Direct
Ø
MKTCLS &=
nbsp; re=
levant
to institutional clients only
Ø
LMT &=
nbsp; &nbs=
p; in
I=
B_Direct
Ø
LMTCLS &=
nbsp; re=
levant
to institutional clients only
Ø
PEGMKT &=
nbsp; relevant
to institutional clients only
Ø
STP &=
nbsp; &nbs=
p; in
I=
B_Direct
Ø
STPLMT &=
nbsp; in
I=
B_Direct
Ø
TRAIL &=
nbsp; &nbs=
p; &=
nbsp; in
I=
B_Direct
Ø
LIT &=
nbsp; &nbs=
p; in
I=
B_Direct
Ø
MIT &=
nbsp; &nbs=
p; in
I=
B_Direct
Ø
REL &=
nbsp; &nbs=
p; coded
in IB_Direct, but not activated
Ø
VWAP &=
nbsp; &nbs=
p; may
be added in the future
Order construction does not differ significantly according to its type, so it should be relatively easy to add= new ones if so desired. Please al= ways check the selected order type is supported by the exchange and instrument traded.
LIT (Limit if Touched) and MIT (Market if Touched) are the latest additions to = IB_Direct.
Lik= e STP and LMT orders, LIT and MIT require trigger prices. To make sure the user does not for= get, the entry price dialog pops up when LIT or MIT order type is selected.
Default order size is defined in “Settings”.
Order size could also be amended on= the main form, but this feature is seldom used, so has been disabled in BETA version. In most cases, one w= ill choose to select a type of entry to increase order size.
A very simple rule is here used, i.= e. a simple multiplier:
Ø Conservative: &= nbsp; use default order size
Ø Balanced: &= nbsp; 2 X default order size
Ø Aggressive: &= nbsp; 3 X default order size
Ø Very aggressive: 4 X d= efault order size
Like order size, such multiplier ca= nnot of course only be modified while in position.
Some settings are available on the = main dialog form. These core functionalities have been extracted from IB sample code, and should work OK= . They however could not be tested u= sing the IB demo account.
=
The next display area is the order = status 1 list control. This part of the dialog is hidden when not in the market.&n= bsp; It is possible to visualize it briefly however by pressing the “Refresh” button. Additionally, in order to keep the UI fairly uncluttered, this area actually has several functions:
Ø When the entry order is f= illed, it will display the attached stop and limit exit orders, with current total position and exit prices.
Ø When the order is not fil= led yet (stop/limit entry), it displays the pending order details submitted to IB.
One must understand that this list = is a container for order status messages sent back by IB. Since those messages have to fit o= n one line only (per TWS), on some occasions, they may supersede (or erase) a previous message (if unrelated), or complete a previous message (for instan= ce, limit exit submission message after stop loss exit submission message pertaining to the same entry)
Usage notes (UI):
Ø Clicking on the Order Sta= tus 1 list refreshes the open order status. Unlike the “Refresh” button, this applies to any status change from orders initiated on IB_Direct only. The “Refresh” button calls for a status update on all open orders[12]= span> for the current symbol, including those made directly on the TWS.
Ø Double-clicking the Order Status 1 list clears the list.
Ø Right-clicking the Order = Status 1 list allows for cancellation of open orders (both pending entry/exit and = attached exit orders).
Ø
It is possible to select =
which
account(s) to include or not for next orders to come (this does not apply to
existing orders in the market, i.e. cannot be used to cancel orders). The TWS1 cannot be excluded.
This option must be with extreme ca=
ution
as it may quite difficult to follow orders sent on such or such TWS.=
Here is an example (Fig 5) of a long position with 1 stop and 2 limit exit orders:
=
Fig 5
The status list shows stop and limi= t exit orders for a total of 2 contracts. In this case, 2 contracts will be sold at 1154 STP (StpP), 1 contract will be sold 1157 LMT (LmtP1), 1 contract at 1159 LMT (LmtP2). It is a “display only”= area: Exit orders cannot be modified here.
Please note that identical orders a= re always sent to all enabled IB accounts (check box). If an account is disabled, followi= ng later positions may be very difficult.&nbs= p; This feature should therefore be used with extreme caution.= p>
The bottom list displays the las= t order status retrieved from IB. Upon fill, up to 6 attached orders (3 stops & 3 limits) can be s= ent, so the returned status info will come in bursts, and only the last item<= /u> can be here displayed. All information is however recorded on the Status/Info window (Fig7) as well as in the log file.
This list is more useful to check t= he status of a pending primary order (i.e. stop/limit entry or exit)
Possible values include:
Ø PendingSubmit - indicates that you have transmitted the order, but have not yet received confirmation that it has been accepted by the order destination.
Ø PendingCancel - indicates that you have sent a request to cancel the order but have not y= et received cancel confirmation from the order destination. At this point, your order is not confirmed canceled. You may still receive an execution while y= our cancellation request is pending.
Ø PreSubmitted - indicates that a simulated order type has been accepted by the system and that this order has yet to be elected. The order is held in the system (and= the status remains DARK BLUE on the TWS) until the election criteria are met. At that time the order is transmitted to the order destination as specified (a= nd the order status color will change).
Ø Submitted - indicates that your order has been accepted at the order destination and = is working.
Ø Cancelled - indicates that the balance of your order has been confirmed canceled by t= he system. This could occur unexpectedly when the destination has rejected your order.
Please check on the IB web s= ite for possible updates (also see order types).
Before going any further with this = process, it is important to present an important feature in the IB_Direct program: the “Status” window. =
=
Fig7
The status list is a small window a= djustable in size, where all major events will be shown (new lines come on top). Errors will be displayed in Dark Red. Warnings are displayed in Green, and general info in Blue.
This window has an “always on top” flag, but it can be hidden.&nbs= p; It can also be extended width-wise if the message is too long to display.
Let’s now look at the connect= ion procedure.
An IB TWS Java console must be runn= ing for each IB account being traded, and = ActiveX clients must be enabled (see below). TWS windows can be minimized since they should not be needed during trading. Memory usage should = not increase significantly with more than one IB account, as only one Java Virt= ual Machine is running.
=
(TWS layout is likely to change)
Warning: please note the IB TWS hav= ing been first designed to handle single accounts, running several TWS consoles may = be a little tedious at first. IB_Direct will always associate each TWS to a definite port. It is recommended to always open t= he several TWS consoles in the same order and check their default socket port.= The ticker will be called from TWS= 1.
Open orders and positions are always checked by I= B_Direct. The “Dow= nload Open Orders on Connection” setting may not really matter, but it is recommended to leave it on.
=
Press the “Connect” but= ton to link to the TWS[13]. Connecting is actually a local sys= tem process, since the TWS is the Java program which will handle the communicat= ion over the Internet with the server at IB.
=
The Port number must of course coin= cide with the socket parameter that has been set in the TWS configuration.
The IB_Direct program may be
running on a different machine than the TWS through IP channeling if
needed. If the IP field remai=
ns
blank, it is assumed that the TWS is located on the
The client Id[15] is generally irreleva=
nt
for individual accounts. The
program relies entirely on authentication as handled by the TWS, and the on=
ly
valid link identifier per se is the Port number (7496 in the example above)=
. However, Client Id can also be use=
d to
allow several instances of =
IB_Direct to connect to the
The option “Account Specifics= ” makes it now possible to trade a different number of contracts/shares for each IB= account. Caution should be exercised here, particularly if fractional exits are used.= Other account specific= s may be added in a future version.
Press OK when ready.
=
A message appears in the Status win= dow[16], asking you to acknowledge the connection request on the IB TWS window. The only response from IB, w= hen connected, is the next valid order id[17] which may then be use= d in the system. Order ids are han= dled automatically by simple increment within the program. As you will see, when stop and lim= it orders are used, the main entry order number is immediately followed by the stop order(s) and limit order(s) numbers.
=
Connect / Disconnect[18] does not use a toggle button as one might first expect. The reason is that it is better to handle multiple connections this = way. If a connection to an individual T= WS drops[19], it can be restarted = by clicking the Connect button without affecting other running TWS. Disconnecting does not reset conne= ction ports. Ports can be cleared by restarting the program or from the system menu.
The Settings dialog will appear automatically upon successful connection to the TWS. Please refer to IB Help = page for further details.
=
(Layout may change slightly in final release)
It can also be later called from th= e system menu or by clicking the toolbox button.
Settings are sent to IB upon closin= g this dialog, so while settings can be consulted off-line, they are only truly va= lid upon successful connection to IB.
In most instances (particularly day= trading futures), little will need be changed here except maybe for default stop/li= mit points, and the contract expiry. All settings are saved in the Windows Registry. The above settings are OK for ES e-mini. The Extended Attribut= es[20] do not really need to= be modified at this stage (see IB documentation for details).
Only 1 ticker is used at present (i= .e. only 1 instrument is traded). Plea= se note that the TWS only serves as a “Java” gateway to IB, i.e. t= he broker. The ticker being sele= cted does not have to be defined in the TWS, although it is most advisable to do= so to check orders are correctly built and transmitted.
The ticker frame includes all minim= um[21] settings required to trade either futures or stocks. It does not however cater for options at this stage. Order construction is basically the same, so it should not be a problem to add options specifics to this form if needed.
In most cases, IB orders are routed= through GLOBEX for futures or SMART for stocks.&nb= sp; Primary exchange and multiplier are to be left blank for futures (new addition to the API v8.3).
The exit order frame includes detai= ls for attached OCA[22] orders. In normal trading situations, an entry will be covered on both sides by a stop loss order and= one or several limit orders (up to 3 fractional exits). Stop orders can either be fixed or trailing[23]. A unique price is used for al= l stop orders[24]. OCA orders will be described in de= tails later in this document.
An option has been added to force e=
xit on
End-Of-Day, specified by a set time (local exchange time + time offset).
Volume alerts can be used to signal= low volumes or sudden bursts in volume (as reported by IB).
BETA VERSION: levels of Verbose and Debug loggin= g may change until final release.
As its name suggests the “Tra= nsmit orders to IB” checkbox allows orders to be stopped at the TWS for confirmation. One could think= of using it to for instance distribute signals to remote TWS consoles (through= the IP address attached to the port number), where the recipient user would vet= the final decision on the TWS itself.
It is therefore not quite an alternative to paper trading with the IB demo account (account: edemo, pass= word demouser). When using the pap= er trading option, orders are not generated at all but are displayed in the st= atus window and recorded in the log file. As such this cannot emulate fills.&= nbsp;
Please note that the IB demo accoun= t does not provide accurate market data. It is most recommended to log in and open a paper trading sub-accoun= t on the IB web site.
Most events are recorded in a log f= ile stored in a C:\JTS sub-folder.
For example: “C:\JTS\IB_DIREC= T_Log\IB_Log_1_210405.txt” will contain details for Session 1 on April 21st, 2005.= p>
A specific order log file is also c= reated in the folder “C:\JTS\IB_DIRECT_LogTrade\”.
For your information, all settings = recorded when closing the “Settings” form, are stored in the HKEY_LOCAL_MACHINE, SOFTWARE section of the Registry under the IBDn key (n being the session number) under the following sub-keys:
Ø Connect
Ø DefaultSettings
Ø LastOrders
We have now described most of the program’s user interface. We are now connected to IB. It is time to trade with it…=
If the program has been run at leas= t once, just to check the various forms, the connection to the IB TWS, as well as t= he ticker, then all settings have now been stored in the registry. Subsequent uses of the program will possibly require less attention as all previous settings will be restored automatically.
=
The ticker has been already briefly described in the introduction. Bid/Ask/Last Trade price and volumes are displayed in real time. Time = of the last ticker update and accumulated volume in the last minute bar are also s= hown (dark red background boxes). = One generally avoids trading when volume per minute drops below 1000 (ES e-mini= ).
Clicking on the ticker bar can be u= sed as a simple shortcut for limit entries. The selected price is set to be used in = the next limit order (entry or exit), and Entry Type changes to Bid/Ask Limit (= for Bid/Ask price) or Limit (for 1 Tick down or 1 Tick up). The Entry Type list box gives the = same entry/exit options, but also includes the Stop-Limit entry/exit. Please note that the price itself = is not recorded at that point. If Bid or Ask is updated before the order button is pressed, the last current price will be used.
Clicking on “Last” reve= rts to “Market” order type. It is recommended= to do so, as one may sometimes have to exit quickly from an adverse position. Alternatively, the System Menu inc= ludes an option to always return to market type order after a stop or limit entry= .
If the ticker is not active, double-clicking the ticker opens the “Settings” dialog.<= /p>
I= B_Direct is connected, ticker and order settings are defined, and the = ticker is running. Everything is now= ready to place an order.
The order buttons have already been described. Placing an order is therefore quite straightforward. &nbs= p; We however recommend to prac= tice placing orders with the IB demo account for a while to become familiar = with the order status and other messages received from IB.
Let’s assume an order[25] is sent to IB. In this first example below, it is= a “BUY 2 ES 1147.75 LIMIT”. Prices have started moving up, so we may consider increasing the lim= it price[26] in case we anticipate= the order not to be filled.
=
(Layout may change in final release)
If the current entry/exit pending o= rder is STP, LMT, LIT, MIT or STOP-LIMIT, and has not been filled yet, price[28] can be updated. Pressing the “S/L Entry̶= 1; button displays a modeless[29] form on which such price(s) can be modified using the slider control. Changing Order Type (1 TICK LMT on previous screenshot) also displays the “S/L Entry” price setting dialog.
The required entry price can be now= set, with or without closing the dialog. The pending order can also be cancelled altogether here too (“= red cross” button).
Obviously, this price adjusting fea= ture is not applicable to a market order which is (meant to be) instantaneously fil= led. Users who want to experiment STOP-= LIMIT orders should refer to the IB documentation to make sure which the right trigger method may be used (may = not be applicable to GLOBEX). A w= ord of caution is needed at this point: stop orders are not always native orders on the exchange being trader. Al= though this should work just as well on simulated stop orders, discrepancies may o= ccur (actually often on the IB demo accounts).&= nbsp; The STOP-LIMIT trigger method can be set in the Extended Attributes settings.
Changing a LMT price has no effect = on a STOP order. Reversely, changi= ng a STP price has no effect either on a LIMIT order.
Please note that this setting can be applied to both entries and exits. It must be used with caution for reversals. A reversal to short is made of an = exit long followed by a sell short. A Bid/Ask limit reversal will therefore built as a Sell Ask followed by Buy B= id which may be difficult to fill, and relatively inefficient for a reversal w= hich is usually meant to be quickly executed.
Lastly, it is possible to set a lim= it exit order by clicking a price on the ticker, pressing the buy exit or short exit button and possibly adjusting it later as described above. It is however recommended to inste= ad use attached exit orders for that purpose (see below).
This may sound obvious, but it is c= lear that only STP or LMT or LIT or MIT or STOP- LIMIT unfilled orders can be cancelled, as MKT orders are executed immediately (cancellation is not synonymous to closing a position). <= /span>The “Cancel” button applies to primary orders (i.e. not attached stop/limit orders).
Please note that order cancellation= may take some time to show on the TWS and on IB_Direct.
Stop loss and Limit target orders c= an be attached to the primary order (see “Settings”), and it is always most advisable to do so.
In the current version of IB_Direct, up to 3 stop and 3 limit orders can be generated. The 3 stop orders are set at the s= ame price, and are each linked to a corresponding limit order in a separate OCA group. This allows keeping the right balance (current position) in open orders, i.e. when the 1st limit is hit and filled the attached stop is cancelled immediately. Please note that being an OCA grou= p, everything is handled at IB servers, so this is quite safe to use should anything happen locally.
Price can be adjusted anytime while= not filled by pressing the “S/L Exits” button, which displays a modeless dialog. Order update= s are generally carried out within a fraction of a second. Updating exit levels is the main t= rading tool to maximize profit (limit) and minimize risk (stop) while in position.=
Unfilled attached orders cancel eac= h other when one is filled (OCA), or are all cancelled on normal exit/reversal.
Here is an example where an entry o= rder has been filled and 2 limit orders have been generated with their corresponding stops (i.e. 2 OCA groups). Th= e 3rd Limit order area has been disabled since irrelevant.
=
(Layout may change in final release)
The sliders have a set increment eq= ual to the tick size, which is quite appropriate for futures. Each order can be adjusted separat= ely, in case an overall update would in certain cases reset the position of other stop or limit order(s) in the order book.
In the example above, the user sele=
cted to
have fractional exits (1 stop order, and 2 limit target exits), so the 3
Each individual button on the right= -hand side validates your choice. T= he other buttons (top right) either update your exit orders or just close the dialog. It is likely that upd= ating exit orders does reset the position in the order book, hence it is recommen= ded to avoid doing so unnecessarily.
OCA orders as the name entails will= have all orders in the same OCA group cancelled when one is filled. If the order is however partially filled, the rest of the group disappears, and yet there is no reason to ass= ume the remaining contracts or shares will ever be filled. This may lead to imbalance in the = open position. Extreme caution must therefore be exercised here, particularly when the trading is slow or when volume traded is low.
NOTE: API 8.5 now offers different OCA
types. The feature is impleme=
nted
and is offered for beta testing.
On some occasions, it may be desire= d (or needed) to force the cancellation of an order, for instance to let the last limit o= rder “run”, or the order clean-up failed (OCA error), or any other reason.
To do so, just right-click the Open= Orders List 1 and cancel open orders one by one:
=
It is recommended to first call for= a status refresh to better associate order ids with the corresponding order.<= /span>
Every attempt has been made to rele= ase this program free of “bugs”. As you have surely understood by now, this program relies on an API which is anything but stable (errors 202 and 505 are still trapped pending updates from IB). In addition, testing it using the demo server has not always been entirely satisfactory = (simulated stops are sometimes not operational).
A lot of effort has been put to ens= ure that information is always saved into the registry in case of momentary PC failu= re, disconnection. The program sh= ould be able to recover from all situations.&nb= sp; On normal program exit, recorded information for open positions and pending order is cleared. Tes= ting and feedback will be very much appreciated.
There is a possible remaining issue= with partial fills, which has until now also been difficult to test fully. I will try my best effort to ensure trading with I= B_Direct is always as safe as possible, with due consideration that it= is impossible to cover all eventualities. It has been for instance found duri= ng testing that the connection to IB may drop for any odd reason (IB server or Internet connection). Upon au= tomatic reconnection, IB sends a message “Data maintained” whereas orde= rs have in fact disappeared. It is therefore imperative to always m= onitor open positions. IB_Direct is in my opinion a valuable tool in the direction of automated trading. However, we are still miles away from having the PC trade for you while sipping a daiquiri watchi= ng a beautiful sunset…
Happy trading,
bruno voisin
It is not possible to ensure 100% guaranteed error-free order management. There may be r= are cases where orders will have to be modified or cancelled directly on the TW= S.
Even if IB_Direct always tries = to always keep everything in check on the TWS, discrepancies may happen, and s= hould be reported to me. There is a= lways a slight chance of a bug creeping up in the code, or more likely the user environment may be not tight enough. In such event, it is recommended to cancel the order on the TWS (cli= ck-right and close position for instance), and clear all registry settings.= p>
=
Errors will be very rare. Please try and replicate the error= on the IB paper trading account at least twice, then send a detailed log file = to support@foretrade.com . It may be a bug, but in most cases= , it will be some misunderstanding of the program (poor documentation…) or some issue with the messaging system in IB. This program relies entirely on IB sending the right information at the right time…
Other reported issues or clarificat= ions:
Ø
[1] Recorded in the HKEY_LOCAL_MACHINE, SOFTWARE section of the Registry=
[2] Remote TWS can be accessed via their IP address (a port may have to be open= ed to access it through a firewall).
[3] Since API v8, IB_Direct now also=
caters
for Advisor
accounts. This will allow trading many more accounts through “umb=
rella”
accounts (max 15 per non-professional advisor). In order to keep the UI simple and=
easy
to use, the Advisor function (contract allocation, monitoring individual
accounts, etc…) have however not been fully coded in IB_Direct yet (due to lack of demand), but the fun=
ctionalities
are there.
[4] Please note that the number of connected TWS consoles cannot be changed once the main dialog is loaded, but accounts can be momentarily deactivated on t= he main dialog form if so desired.
[5] Log on to the IB web site for det= ails (exchange fees etc)
[6] Technically IB_Direct will accept simple ma= rket orders without an active IB ticker, but this is certainly not the recommended usag= e.
[7] Please note that news bulletins and
logging
[8] Price changes color if it goes up, down, or stays unchanged.
[9] CAUTION: if button control is disabled, and orders can be inadvertently repeated by pressing an order button twice (or more). Pressing the wrong button, like ex= it long for a sell short may also have adverse consequences. IB should differentiate both entri= es (technically it is a SELL for a exit long, and a SSHORT for a sell short) but testing on= the IB demo account proved that it does not always do it…
[10] This calls for status update for ALL open orders, including changes made directly on the TWS.
[11] This applies to the primary order, i.e. normal entry or exit, but not the attached OCA exits, which are handled separately.
[12] This slight difference may seem subtle, however one must take in considerat= ion that the TWS may not always be local to IB_Direct. IB_Direct can be used to dissemina= te signals to one or several remote TWS console(s). In addition, irrespective of its location, the TWS may stop all orders for confirmation.
[13] The Info window will pop up automatically unless this option is disabled in program settings. That window= is set to be displayed on top of other windows.
[14] A
remote TWS is generally used to separate order management from charting.
[15] Client Id may or may not be merged with Session No in a future version.
[16] The Status window stays on top of other windows. It can however be minimized. It must be active = to record events (even if minimized).
[17] Order Ids are stored in a JTS sub-folder.&= nbsp; Hence they should keep being incremented. It is possible to reset the counte= r by deleting that folder (named “darykq” in current API releases).<= span style=3D'mso-spacerun:yes'> Deleting that folder will probably= also reset all your TWS default settings.
[18] Double clicking the Disconnect button also clears port settings
[19] IB will try and restore the connection. No action needed.
[20] Please note that all orders are valid “DAY” by default, which is the common choice for day-traders. Position traders may want to change that setting to “GTC” (Good Till Cancelled). Other choices are available. See IB H= elp file for details.
[21] Some settings have not been coded, like GAT (Good After Time). Please refer= to the documentation for details.
[22] One Cancels All
[23] A trailing order is a sliding stop order following positive price movement.= span>
[24] For simplicity, a single price is used for all exit limit orders. This may change in future versions= , but since a stop loss order should be a “risk of ruin” order and no= t a trading tool per se, this has considered sufficient.
[25] Sending an order to IB generates immediately a series of follow-up events a= nd messages. IB_Direct repeats a status request to IB after 5 seconds.
[26] Data here shown is incorrect. This is a flaw or limitation from the IB demo accounts, to prevent users from getting actual market data for free…
[27] Primary order means normal entry/exit as opposed to attached OCA exit order= s.
[28] Technically, order size can also be updated, but this has not been allowed = in this version of the IB_Direct program.
[29] A modeless form does not capture the focus. The user can leave it open and clic= k back to the main form. It is actua= lly recommended to do so until the order is filled.
IB_Direct Quick Guide &= nbsp; &nbs= p; &= nbsp; &nbs= p; &= nbsp; &nbs= p; 6/23/2006