TSim+ Automated Trading
TSim+ supports automatic trading. Orders are sent to TSim+ in a file which must be named
auto.tsm and located in the
c:\program files\tsimplus directory (or the directory TSim+ has been installed in if different). The order file is a plain ASCII text file, containing the order command terminated with a carriage return and linefeed. By utilising a text file interface, TSim+ can accept orders from many different sources, such as eSignal, WealthLab, SierraChart (via the Excel link) etc.
From version 2.3, TSim+ creates a return file when an order is executed. The file is called
auto.out, and is located in the same folder as the input file. The file is created when an order is filled, so a command that generates multiple fills (eg CLOSEALL) will see the file overwritten multiple times, leaving the last fill in the file. The format is described below.
To enable Auto mode, select Automatic from the Mode menu (or press F7). The TSim+ title bar will display
(Auto) whilst in Auto mode. As soon as Auto mode is entered, TSim+ will start polling the application directory for the
auto.tsm file (the directory is polled every 300ms). Therefore it is a good idea to check that there are no 'old' auto.tsm files hanging around before you switch to Auto.
Alarms have the same effect on Auto orders as manual ones. Alarms do not disable trading if any positions are open, thus there is no danger of an alarm preventing an exit order being processed.
You can still place manual orders whilst in Auto mode.
Auto mode works in both Simulation and Live modes.
Of course, automatic order execution is only half the battle when setting up an automated trading system, you also need a mechanical system to actually trade! There are some good ideas in The Encyclopedia of Trading Strategies, and Robert Pardos book Design, Testing, and Optimization of Trading Systems is the one to read if you are interested in developing your own strategies. Alternatively you could bypass all that and go with a proven system such as that offered by NetPicks.
Automatic Order Options
Start Time / End Time: This is set from the Config screen (File...Settings from the TSim+ menu) Automatic orders are only accepted between the times set here. If you do not set any times, or set the start and end times to the same value, no auto orders will ever be processed (this may be desirable to prevent automatic orders being processed should auto mode be invoked inadvertently). Enter the hours in the first box and minutes in the second box, in 24 hour format.
Max Contracts Open: This works on a Per Symbol basis; for example, if set to 2, with two NQ contracts already open an auto order to open another NQ contract would be rejected, but such an order to open an ES contract, for example, would be accepted.
Other Auto Options: Users of previous version of TSim may be aware that there were options for points target and maximum loss. From Version 2 these have been disabled due to the introduction of multiple symbol and position handling. They may be reintroduced to a later version in a different guise. I'm open to suggestions on how to work that one!
Order Entry File (auto.tsm)
CMD = Command
TYPE = Order type
SYMBOL = Symbol to trade (must exist in the TSim+ symbol list)
QTY = Quantity of contracts to trade (must be between 1-9)
LIMIT = Limit or Stop price (leave blank for market orders)
STOP = Offset of stop price from fill. Leave blank or 0 for no stop
TARGET = Offset of target price from fill. Leave blank or 0 for no target
-One command per file only.
-TSim+ will delete the file as soon as the command has been either executed or rejected.
-Auto orders are detailed in the TSim+ Log File.
-Auto orders will be rejected if they are not in the correct format.
-All commas should be included in the file. Where a field is not relevant it should be left blank.
Return File (auto.out)
ACTION = BOUGHT or SOLD
QTY = Fill quantity
SYMBOL = Symbol traded
FILL PRICE = Price traded at
Supported Commands at v2.3.0
PLACE = Place new order
CPLACE = Cancel all pending orders, and place new order
XPLACE = Close all open positions, cancel all pending orders, and place new order
CLOSEALL = Close all open positions, cancel all pending orders
CANCELALL = Cancel all pending orders
TRAILON = Switch on Trailing Stops (for subsequent Auto Stops)
TRAILOFF = Switch off Trailing Stops (for subsequent Auto Stops)
Supported Order Types at v2.3.0
BUYMKT = Market Buy
BUYLMT = Limit Buy
BUYSTP = Stop Buy
SELLMKT = Market Sell
SELLLMT = Limit Sell
SELLSTOP = Stop Sell
Automatic Trading File Examples
= Sell 2 contracts of symbol ESTX50 at market. Place a stop order 5 points from the fill price. No target limit order.
= Close all positions, cancel all pending orders, place new Buy Limit order for 1 contract of symbol ES at price 980. Place a stop order 2 points from the fill price, and a target limit order 4 points from the fill price.
= Close all open positions at market, cancel any pending orders
Automation Of Stock Orders
New in version 2.3 is the ability to auto-trade stocks without first having to set them up in the symbol editor. In order to do this, prefix the stock symbol with an asterisk, eg:
The above order would buy 100 Amazon shares at market, placing an auto-stop 20 cents away, and an auto-target 40 cents away from the fill price.
When auto orders entered in this manner, the same assumptions are made for the symbol as when manually trading in stock-entry mode, ie they are assumed to be US Stocks traded through IB Smart routing, with a tick size of 0.01, a price per point of 1, and a commission charge of 0.01 per share per side. If the stock you enter is configured in the Symbol Editor, the configured settings will override these defaults.