ninjatrader/utilities/tick-data-conversion/README.md

3.8 KiB

Poor Man's Guide to Historical Tick Data for NinjaTrader

This guide covers how to import historical tick data from Sierra Chart into NinjaTrader for cheap.

A 1-month subscription to Sierra Chart (and the Denali Exchange Data Feed), which is sufficient for the purpose of this guide, is ~$40.

Services such as Portara CQG cost ~$800 per instrument (e.g., S&P 500 E-Mini Futures).

Depending on how much data you require, this could save you thousands of dollars.

Motivation

Historical tick data is useful when backtesting strategies that depend on intrabar price movements (i.e., when OHLC alone is insufficient).

However, data providers provide only a limited amount of historical tick data.

For example, the default NinjaTrader Continuum data feed provides only a year's worth.

IQFeed, my current data provider, provides up to 180 days only.

In order to obtain more data, it must typically be purchased from a data vendor, but as we've seen, this can be very expensive.

Hence the desire to obtain historical data for a fraction of the cost.

Exporting Data from Sierra Chart

  1. Go to Global Settings > Data / Trade Service Settings.
  2. Make sure Intraday Data Storage Time Unit is set to 1 Tick and that the Maximum Historical Intraday Days to Download for 1-Tick Data is set to a period long enough to download all the data in the contract (doesn't have to be 730 days as shown in the screenshot, 45-60 days should be more than enough).
  3. Apply All changes.

Data / Trade Service Settings

  1. Connect to the data feed if not already (File > Connect to Data Feed).
  2. Go to File > Find Symbol.
  3. Enter the symbol for the contract you want to download data for.

Find Symbol

  1. Open Intraday Chart, then Close.
  2. Wait for historical data to download / chart to finish loading.
  3. Disconnect from the data feed (File > Disconnect).
  4. Go to Edit > Export to Intraday Text File.

Export to Intraday Text File

  1. Click save and wait on the export to complete.
  2. Repeat this process for as many contracts as you desire.

Converting Data to NinjaTrader's Expected Format

The exported tick data can be converted into the format that NinjaTrader expects by running the script convert_tick_data.py.

The script depends on pandas, so make sure the package is installed.

Make sure to specify the file exported from Sierra Chart as the input and name the output file accordingly.

The output file name matters, so refer to NinjaTrader's documentation on importing tick data for more information.

Important bit:

When using the NinjaTrader format, the name of the text file to be imported must be the NinjaTrader instrument name followed by a period and "Last", "Bid", or "Ask" depending on the data type. For example:

MSFT.Last.txt for Microsoft stock last price data

ES 12-09.Bid.txt for the S&P E-mini December contract bid price data

EURUSD.Ask.txt for the Euro/U.S. dollar currency pair ask price data

The script outputs the Last price.

Importing Data into NinjaTrader

  1. In the NinjaTrader control panel window go to Tools > Import > Historical Data.
  2. Select the desired Format (e.g., NinjaTrader (end of bar timestamps)), Data Type (e.g., Last), and Time Zone of Imported Data (e.g., UTC).
  3. Select "Generate 'Minute' bars from imported tick data" if you wish to do so (recommended).
  4. Click Import and select the output file(s) from the tick data conversion script.

Historical Data Import

  1. Finally, wait for the import to complete.

You will now be able to perform backtests (e.g., via the Strategy Analyzer) using the imported historical tick data.