Trade Simulation


Introduction

Sierra Chart provides a Trade Simulation feature which simulates the acceptance, management and filling of Trade Orders, and tracking of Trade Positions internally in Sierra Chart. This simulates trading as if you were connected to a live trading account.

Detailed trading results are provided and can be analyzed through the Trade >> Trade Activity Log.

The Trade Simulation Mode feature also works during a chart replay.

This feature can be used when connected to a Data only service and can be used when connected to a Trading service when you do not want to send orders to your Trading service and instead want to have them simulated.

All trading functionality in Sierra Chart is supported when using Sierra Chart Trade Simulation Mode.

Using Trade Simulation

  1. To use the trade simulation feature, simply select Trade >> Trade Simulation Mode On on the menu and make sure it is checked. If trade simulation mode is active, then there will be a check mark by this menu command. If it is not active, then there will not be a check mark by this menu command.
  2. When Trade Simulation Mode is enabled, then on the title bar you will see the word [Sim], indicating Sierra Chart is in Trade Simulation Mode.
  3. Select Chart >> Chart Settings, on the menu. Verify that the Tick Size is set properly for the symbol. The Tick Size represents the smallest increment that the symbol trades in. For typical stocks, use .01. For mini S&P futures (ES), you usually will use .25. Normally the Tick Size is set properly from the Global Symbol Settings.
  4. Press OK.
  5. Make certain you are connected to the real-time data feed by selecting File >> Connect to Data Feed. This is necessary to receive real-time prices.
  6. When in Trade Simulation Mode, all trading functionality in Sierra Chart works normally with one exception, and that is orders are not sent to your trading service and are instead are simulated within Sierra Chart.
  7. An order that you submit, will be processed within Sierra Chart. If Sierra Chart is not running, then the order cannot fill if it has not already filled while Sierra Chart is running.

Trade Simulation When Using a Remote Data File

When you have opened a chart that is updated by a remote copy of Sierra Chart, then there is a setting that needs to be set for Trades Simulation Mode to work properly. For more information about opening a chart from remote copy/instance, refer to Multiple Services.

For Trade Simulation Mode to work with chart data from another copy of Sierra Chart, it is necessary to enable Global Settings >> General Settings >> Use Non-Chart Data from Remote Instances.

This is not issue when you are performing a Chart Replay.

Multiple Trade Simulation Accounts

Newer versions of Sierra Chart supports multiple Trade Simulation Accounts.

The number of trade simulation accounts is set through Global Settings >> General Trade Settings >> Number Simulation Accounts. Specify a number between 1 to 400.

The main reason for multiple simulation accounts is that if you are performing back testing with different parameters, you can run each back test in a separate trade simulation account and have all of the back testing results saved in each individual account, for review within the Trade >> Trade Activity Log.

You can also run multiple trading systems at the same time and perform manual trading for the same symbol, with real-time data, if each of them is using a different simulated trading account.

Select the Trade Account on the Trade Window for the chart or Trade DOM as shown in the image below.

Using Trade Simulation During Replays

Trade Simulation Mode is fully supported when Intraday charts are replayed. Only Intraday charts can be replayed. Therefore, to use Trade Simulation Mode during a replay means you can only use an Intraday chart. Not a Historical Daily chart. Follow the steps below to use Trade Simulation Mode during chart replays.

  1. Select Chart >> Chart Settings, on the menu. Verify that the Tick Size is set properly for the symbol. The Tick Size represents the smallest increment that the symbol trades in. Normally the Tick Size is set properly from the Global Settings >> Symbol Settings.
  2. Press OK.
  3. Replay your charts following the instructions on the Replaying Charts page.
  4. To enter an order, you simply enter orders as you normally would using any of the methods for order entry. You are also able to modify and cancel orders using the standard methods in Sierra Chart.

Additional Steps When Replaying Multiple Charts or Trade DOMs

  1. Replaying Multiple Charts: When you are using Trade Simulation Mode during replays and you are replaying more than one chart for the same symbol you are trading, then you need to follow these additional steps. Otherwise, if you do not, then the Last trade price on the charts and Trade DOMs replaying for the same symbol, will not always match.
  2. The Session Times in Chart >> Chart Settings in all of the charts that are replaying for the symbol you are trading, must be identical or they need to be 0:00:00 to 23:59:59.
  3. Set the Days to Load setting under Chart >> Chart Settings for any other charts or Trade DOMs being replayed to be the same or greater than the chart you are controlling the replay from. Important: This is especially true for Trade DOMs.
  4. You must also have started replaying all of the charts by using For All Charts in Chartbook on the Replay Control Panel window. You cannot start the replays individually.

Trade Simulation Accuracy and Bid/Ask Prices During Replays

This section explains Trade Simulation accuracy when replaying a chart. This also applies to Auto-Trade system Replay Based Back-Testing because Auto-Trade system Replay Based Back-Testing is performed by replaying a chart.

This section also explains how Bid and Ask prices are determined during replays and for Bar Based Back Testing.

When a chart is updating with live market data, the Bid and Ask are determined by the live market data feed. In this case, the Bid and Ask prices are never simulated.

Orders are filled based on Bid and Ask, and Last trade price data. For complete information about how the different order types are filled, refer to the How Orders Are Filled section.

During a replay, there are two different methods by which the Bid and Ask prices are determined.

The first method by which the Bid and Ask prices are determined is from the actual prices that existed in real time. For many of the supported Data and Trading services, when using an Intraday Data Storage Time Unit of 1 Tick, the actual Bid and Ask prices during a replay are set to what they actually were during the real-time trading. This data is available from June 23, 2014 when using newer versions of Sierra Chart. To take advantage of this feature, select Global Settings >> Data/Trade Service Settings. Set the Intraday Data Storage Time Unit to 1 Tick.

If you make a change to the Intraday Data Storage Time Unit setting in the Data/Trade Service Settings window, then you will need to re-download the data in the Intraday chart by going to the chart and selecting Edit >> Delete All Data And Download. This only needs to be done once for each symbol.

In the case of the first method, to determine if you actually have the historical Bid and Ask prices, go to a chart and select Edit >> Edit/Download Data - Intraday chart. When looking at individual data record, if the Open is 0 and the Number of Trades is 1, then the High and Low represent the Ask and Bid prices respectively.

In the case when the actual Bid and Ask prices are stored with every trade, an ACSIL study can access the actual Bid and Ask prices during a replay with sc.Ask and sc.Bid.

The second method by which the Bid and Ask prices are determined is they are derived from the High, Low, Close/Last values of the underlying data records read into the chart from the Intraday data file during a chart replay.

There is a special algorithm used to determine the Bid and Ask from these values (explained below). The Bid and Ask will always be 1 tick apart. Each of the High, Low, Close/Last values from the underlying data records are processed individually.

The High, Low, Close/Last data record values are processed individually during a replay. The Low is processed first if the Close is closer to the High compared to Low, or the High is processed first if the Close is closer to the Low compared to the High.

In the case of a Bar Based Back Test, the Bid and Ask prices are determined from the Open, High, Low, Close values of the chart bars. The order in which these are processed from the chart bars is explained in the Bar Based Back Testing Notes section.

As these prices are being processed, Sierra Chart checks if the current price, whether this is the Open, High, Low, or Close/Last, has moved up, down, or stayed the same compared to prior Open, High, Low, Close previously processed.

If the price has moved up compared to prior price processed (one of the Open, High, Low Close values), then it is assumed that the trade occurred at the Ask price. The Ask price will be set to this current price and the Bid price will be set one tick lower.

If the price has moved down compared to the prior price processed, then it is assumed that the trade occurred at the Bid price. The Bid price will be set to this current price and the Ask price will be set one tick higher. If there is no change with the current price compared to the prior price processed (one of the Open, High, Low Close values), then the Bid and Ask remain the same.

Keep in mind that the High, Low, Close/Last values we are referring to here are from the underlying data records in the Intraday data file in the case of a chart replay. Not the bar values necessarily. However, they are the bar values in the case of a Bar Based Back Test.

The time frame of the data records in the file could range anywhere from 1 tick to 1 minute. A smaller time frame per record will give you the most accurate simulation results, although back testing will be slower.

The time frame of the data records in the file depends upon the Data or Trading service you are using and a setting. Select Global Settings >> Data/Trade Service Settings. Set the Intraday Data Storage Time Unit to 2 seconds or less for the greatest accuracy.

If you make a change to the Intraday Data Storage Time Unit setting in the Data/Trade Service Settings window, then you will need to re-download the data in the Intraday chart by going to the chart and selecting Edit >> Delete All Data And Download.

Once you re-download the Intraday data for a symbol in one of the charts, you do not have to do it for other Intraday charts of the same symbol. Since all charts of the same symbol share the same data file.

When the Bid and Ask prices need to be estimated, the actual values will not represent what they necessarily were in real-time. Therefore, trade simulation results during a replay will differ compared to actual live market conditions.

Increasing Spread Between Bid and Ask Prices

This information applies to Intraday charts only. If you want to have the Bid and Ask be more than 1 tick apart during a replay or during back testing, then follow the instructions below:

  1. Select Global Settings >> Data/Trade Service Settings.
  2. Set the Intraday Data Storage Time Unit to 1 Second.
  3. Press OK.
  4. Go to the Intraday chart and re-download the data with Edit >> Delete All Data and Download. This will ensure the data records in the Intraday chart data file are of a 1 second timeframe each.
  5. Select Chart >> Chart Settings.
  6. Increase the Tick Size. If you make it twice the actual Tick Size, then this will result in the Bid and Ask being 2 ticks apart.

How Orders are Filled

This section explains how the different order types are filled in Trade Simulation Mode. The Last, Bid, and Ask prices are used for this.

In the case of when using Trade Simulation Mode with real-time market data, the Bid and Ask are provided by the data feed. In the case of a chart replay, they are calculated and the method by which they are is explained in the Trade Simulation Accuracy and Bid/Ask Prices During Replays section.

To ensure no market data is missed when evaluating simulated orders for fills during real-time market data updating, make sure the Global Settings >> Data/Trade Service Settings >> Number of Stored Time and Sales Records is set high enough. To be safe, you may want to set this to 10000. The higher the number, the more memory used if you track a lot of symbols in real-time within Sierra Chart.

Each Time and Sales record stores either a Trade or a Bid and Ask update. The number of records needs to be high enough to hold the records between each chart update. The chart update interval is set through Global Settings >> General Settings >> Chart Update Interval.

Select Window >> Current Quote Window, to view the current Bid and Ask prices.

When an order fills in Sierra Chart Trade Simulation Mode, the current Bid, Ask and Last trade prices at the time of the order fill are logged with the order Fill entry in the Trade >> Trade Activity Log >> Trade Activity tab. Look at the Order Action Source field. Example:

[Sim]XAUUSD Trade simulation fill. Bid: 1071.90 Ask: 1072.40 Last: 1072.15

This is very useful information to know exactly what the Bid, Ask and Last trade prices were at the time of the fill to know exactly what triggered the order fill.

If you believe there is a problem with the Bid and Ask prices, then you need to determine the reason for this or provide support some simple background information about what you are doing in order for us to provide some help.

Market Orders

A Buy market order will be filled at the Ask price. A Sell market order will be filled at the Bid price. Market orders are always filled immediately. If the Bid and Ask prices are 0, then a market order will fill at the last trade price.

Limit Orders

Limit orders are filled based upon the Bid and Ask prices.

A Buy Limit order will only be filled when the Ask price is equal to or less than the limit price. And it will be filled at the Ask price when this condition is met.

A Sell Limit order will only be filled when the Bid price is equal to or greater than the limit price. And it will be filled at the Bid price when this condition is met.

During a bar based back test, a resting Limit order will not fill at a price better than the Limit price if the bid and ask prices processed are beyond the Limit order price and have triggered the Limit order price. Instead the order will be filled at the Limit order price, which can be a worse price than the processed bid and ask prices. This happens in order to simulate smooth price movement in the case where when running a bar based back test, not every price tick is necessarily available.

Stop Orders

A Buy Stop order will only be filled when the current Last trade price is equal to or greater than the Stop price. And it will be filled at the current Ask price when this condition is met. In the case where the Bid and Ask prices are higher than the last trade price, then the Buy Stop order will be filled at the last trade price +1 Tick.

A Sell Stop order will only be filled when the current Last price is equal to or less than the Stop price. And it will be filled at the current Bid price when this condition is met. In the case where the Bid and Ask prices are lower than the last trade price, then the Sell Stop order will be filled at the last trade price -1 Tick.

During a replay the Bid and Ask prices are estimated if there is not tick by tick data, or actual if there is tick by tick data. Refer to Trade Simulation Accuracy and Bid/Ask Prices During Replays.

During a bar based back test, a resting Stop order will not fill at a price which is more than 1 tick away from the Stop price if the Bid and Ask prices processed are beyond the Stop order price and the Last trade price has triggered the Stop. So the order will be filled at the Stop order price +/- 1 Tick, which can be different than the processed Bid and Ask prices. This happens in order to simulate smooth price movement in the case where when running a bar based back test, not every price tick is necessarily available.

Stop-Limit Orders

A Stop-Limit order consists of both a Stop order and a Limit order. First the Stop order is effective and and triggers according to the Stop order rules above.

After the Stop order has been triggered according to the Stop Order rules, the order then becomes a Limit order and the Limit order fills according to the Limit order rules above.

It needs to be understood, that a Stop order is triggered by the Last trade prices and the Limit order is filled according to the current Bid and Ask prices. You need to be aware of this in order to understand the behavior that you see.

Market If Touched Orders

A Buy Market If Touched order will only be filled when the current Last trade price is equal to or less than the Trigger price. And it will be filled at the Ask price when this condition is met.

A Sell Market If Touched order will only be filled when the current Last price is equal to or higher than the Trigger price. And it will be filled at the Bid price when this condition is met.

Midpoint Price Chart Bars and Fill Prices

Some symbols with some Data or Trading services will provide only Bid and Ask prices. There are no last trade prices. By default, for this type of data, the price range of the bars in the chart will only be based upon the average of the Bid and Ask prices. This is known as the midpoint price. Therefore, the High and Low values for a chart bar will not include the highest Ask or the lowest Bid during the timeframe of that chart bar.

For more information, refer to Forex/CFD Market Data and Data Recording Modes. It is possible to use a different Data Recording Mode with the symbol.

What this means, is that when an order fills, the fill price can very well be beyond the extreme High and Low for chart bar. Orders will fill at the Bid or Ask price which can be beyond the High and Low. This is important to understand.

Why Fill and Order Prices Can Be Wrong or Unexpected / Orders Do Not Fill When Expected

The following issues:

  1. Market orders are filling at prices away from the current price.
  2. When buying or selling at the Bid or Ask, the order price is at an unexpected price.
  3. Limit or Stop Orders are not filling when expected or fill unexpectedly.

Can be due to the following:

  • Invalid Bid and Ask data: It is not possible to have invalid Bid and Ask data during replays unless the Tick Size setting in Chart >> Chart Settings is wrong.

    When you are receiving real-time data from the connected Data or Trading service, the service could be providing invalid Bid and Ask data. To confirm this, select Window >> Current Quote Window.

    Look at the Bid and Ask prices. If they are significantly different than the Last trade price, then they may not be correct. In this case you may want to reconnect to the data feed by selecting File >> Disconnect and then File >> Connect to Data Feed.
  • The Bid and Ask prices are valid prices but are at values you do not expect. You can see the current Bid and Ask for the symbol of a chart through Window >> Current Quote Window. You can see what the Bid, Ask, and Last are the time an order fills since this information is logged. Refer to How Orders Are Filled.
  • Having an incorrect Tick Size and Price Display Format settings. These are set in Chart >> Chart Settings.
  • Misunderstanding about How Orders Are Filled. It is essential to understand how orders are filled. You may find that the order behavior that you are seeing is completely normal.
  • For an order to be evaluated for a fill, the following needs to be true:
    • The original chart the order was entered from needs to continue to be open while the order is in a working state (not with a Filled, Canceled, Error Status).
    • The original chart the order was entered from needs to have Trade >> Show Orders and Position checked while the order is still working, for the order to be filled.
    • The original chart the order was entered from needs to have the Trade Account set to the same Trade Account that was selected when the order was originally entered.
    • The original chart the order was entered from needs to be set to the same Symbol as when the order was originally entered.

Order Fills Do Not Match with Price Bars

If you notice that the price level that an order fills at on a chart bar is outside the high to low range of the chart bar, then this can be due to one of the following reasons:

  • The Bid or Ask prices caused the Limit order to fill. For complete details about this, refer to How Orders Are Filled.
  • If the order fill occurred when the chart is not replaying, then your computer's clock may not be set accurately since the order fills are time stamped using your local computer clock. Refer to help topic 38.

Viewing Open Orders and Order Data

Open orders can be viewed on a chart if Chart Trade Mode is on. To enable Chart Trade Mode, make sure there is a checkmark by Trade >> Chart Trade Mode On.

You can also view all of your orders through the Trade >> Trade Orders and Positions window. Select the Orders tab.

To sort the orders in the Orders list, click on a column header that you want them sorted by. For example, if you want all of the Open orders to be listed at the top, then click on the Status header once or twice and then they will be displayed at the top.

Viewing Positions and Current Profit/Loss

You can view your current simulated Trade Position for the symbol, on a chart, Trade DOM, or on the Trade Stats for Charts tab of the Trade >> Trade Orders and Positions window.

To view your current Trade Position for a symbol, on a chart or Trade DOM, make sure there is a check mark by Trade >> Show Orders and Position on the menu. This menu command applies to the active chart or Trade DOM. By default, this will be checked when you are in Chart Trade Mode. The Trade Position for the symbol will be displayed as a box and line on the chart or Trade DOM at the level of the Average Position Price. If you do not see the Profit/Loss value on the Trade Position line, then enable Trade >> Chart Trade Settings >> Position >> Display Profit/Loss on Position Line.

To view your current simulated Trade Positions in a central location, select Trade >> Trade Orders and Positions on the menu. Select the Trade Stats for Charts tab. Simulated positions begin with the text [Sim]. On that tab you will only see Trade Position and other trading related data for symbols that have charts open for them, and where those charts are maintaining an internal Trades list. The internal Trades list will be maintained in the chart if the chart is in Chart Trade Mode or in the case of Trade DOM window charts.

Account Balance

Sierra Chart Trade Simulation Mode does not maintain an Account Balance. The account balances that you see on the Trade >> Trade Orders and Positions >> Balances tab are only for the external Trading service you may be using.

As an alternative to not having account balance information in Trade Simulation Mode, we recommend using the Trades Tab on the Trade Activity Log for a listing of all of your trades and the cumulative profit or loss for those trades.

Trade Simulation When Disconnected from Server

Sierra Chart Trade Simulation Mode is a feature within the Sierra Chart software itself. The orders are filled on the client side (within Sierra Chart) according to the rules documented in the How Orders Are Filled section.

Therefore, when there are currently simulated Open orders entered from a chart that is not replaying, it is necessary for Sierra Chart to be connected to the data feed (File >> Connect to Data Feed) in order for the orders to fill.

When disconnected from the data feed or Sierra Chart is not running, the orders will not fill.

For additional information, refer to Why Fill and Order Prices Can Be Wrong or Unexpected / Orders Do Not Fill When Expected.

Automatic Enabling of Trade Simulation Mode

Trade >> Trade Simulation Mode On can only be enabled under the following conditions.

The user manually selects this command and places a check mark by it.

Sierra Chart is set to use a Data service selected through Global Settings >> Data/Trade Service Settings >> Service which does not support trading. When performing any kind of trading action such as submitting an order, Trade Simulation Mode will automatically be activated in this case.


*Last modified Thursday, 03rd November, 2016.