Thinking Stuff's ATM

Automated Trading Machine (ATM) makes it simple to remove fear and greed from your trading. Automated trading is no longer just for the rich or nerdy. Our revolutionary software runs on your computer, using your trading rules, but none of your emotions. There's just one requirement - you know how to use a mouse.  Learn more...

Thinking Stuff's ATE

Automated Trading Execution (ATE) is where we run your trading systems for you on our servers. Your system can be exported from ATM, or written in plain English and we'll make it for you. We'll even backtest and suggest improvements if you want us to. This service essentially automates your automated trading.  Learn more...

Thinking Stuff's Groups

Join a group of like-minded individuals, and help each other to trading success. Once you join a group, you will have access to that group's trading systems, ideas, and feedback. And please contribute your own knowledge as much as possible. Or contact us to start your own group.  Learn more...

Charts

Video: Creating A Custom Indicator

This tutorial demonstrates how to create a custom indicator, which is then charted.

It assumes:

  1. You started ATM and opened a settings file.
  2. That settings file already has some price bars in it.
  3. ATM is sitting there ready to go.

This tutorial does these things:

  1. Charts some price bars.
  2. Adds an indicator to the chart - the LOW minus 0.3%
  3. Creates a custom indicator implementing the Chandelier Stop.
  4. Adds the Chandelier Stop indicator to the chart.

It's probably better NOT TO WATCH this video tutorial if you are new to ATM, and especially if you're not good with computers. Custom indicators are the hardest things to understand, and you are totally going to get the wrong impression about this software. ATM comes with a whole number of pre-made custom indicators, so most likely you will not need to create one of your own.

On the other hand, if you can understand this then the rest of the software will be a cinch.

Click here to watch the video, and use the browser's back button to come back. Or click here to open in a new window.
 

Video: Backtesting

This tutorial demonstrates how to create a trading system, and then backtest that system using historical price bars.

It assumes:

  1. You started ATM and opened a settings file.
  2. That settings file already has some price bars in it.
  3. ATM is sitting there ready to go.

This tutorial does these things:

  1. Creates a trading system.
  2. Creates a backtest configuration entry.
  3. Runs the backtest.
  4. Views the chart. We decide how the system might be made better.
  5. Edits the trading system.
  6. Runs the backtest again.
  7. Views the chart again to see if we did actually make it better or not.

There are several objective ways of determining if a price is trending or ranging, and the trading system we create in this tutorial was inspired by the Two Bollinger Bands method. For a stop loss we use the Chandelier Stop described in more detail here.

Click here to watch the video, and use the browser's back button to come back. Or click here to open in a new window.
 

See also:

Video: Loading Text Files And Creating Price Bars

This tutorial starts from a brand new settings file, loads a text file of historical tick prices, creates price bars from those ticks, and charts the price bars. The file in question was obtained from Gain Capital, but the theory is the same for text files from any source.

Note, however, that the file we used in this particular case was an older one. Gain Capital's newer files are slightly different. See the settings to use on the File Loader window.

This tutorial assumes:

  1. You started ATM, created a new settings file, opened it, and ATM is sitting there ready to go.
  2. You downloaded some text files containing historical prices.

This tutorial does these things:

  1. Loads the historical tick prices from the files.
  2. Creates 10-Minute bars from the ticks.
  3. Creates Hourly bars from the 10-Minute.
  4. Charts the 10-Minute bars.

A very similar process is described (in words) in this post.

Click here to watch the video, and use the browser's back button to come back. Or click here to open in a new window.
 

See also:

Obtaining And Using Historical Prices From DukasCopy

The files are available at http://freeserv.dukascopy.com/exp/. Also www.dukascopy.com/swiss/english/data_feed/csv_data_export/.

But you can't start the downloading of all the files and go and do other things - you have to export the data you want one-by-one. Scroll about 4/5 of the way down to get to the currencies available. They have |f| next to them. You can choose any format you like, but make sure you choose "Windows" in the "End line" field.

The good part is that they have data going back to 1986 for some currencies.

DukasCopy provides indicative data, which has no spread. During backtesting, make sure you add on a few pips in the "Commission" field to simulate the spread, otherwise your backtesting results will be overly optimistic.

The Currency Secrets website has covered the issue of indicative data in some depth, so I point you to their pages:

p.s. I think their conclusion is that as long as you add the spread, it should be ok.

I guess it's always better to use the prices from the broker you are going to use, if possible.

Once they are finished downloading, follow the rest of the instructions to load text files. DukasCopy historical prices are already in price bar format though. So you don't need to do the steps to create price bars, unless you want to create other price bars not provided by DukasCopy.
 

Loading Text Files And Creating Price Bars

The method described below works the same for any symbol/interval/broker. We will use the example of creating EUR/USD Hourly and Daily price bars from historical tick prices provided by Gain Capital.

These steps assume you have already downloaded the text files containing the historical prices to your computer. See here for instructions for:

Create the Data Manager entries

Here's a good explanation of what Data Manager entries do.
 

1. Create a Data Manager entry to store the tick prices

1a. In ATM, click "Price Data" > "Price data configuration"
1b. Click "Add"
1c. In the top box, choose EUR/USD, Tick, Gain Capital
1d. In the bottom box, choose the bottom option - "Just set up (or keep)..."
1e. Click OK.
 

2. Create a Data Manager entry to store the Hourly bars

2a. (Should still have the Data Manager Search window open).  Click "Add"
2b. In the top box, choose EUR/USD, Hourly, Gain Capital
2c. In the bottom box, choose the second option - "...shorter time-period..."
2d. Choose "EUR/USD, Tick, Gain Capital" from the list.
2e. Click OK.
 

3. Create a Data Manager entry to store the Daily bars

3a. (Should still have the Data Manager Search window open).  Click "Add"
3b. In the top box, choose EUR/USD, Daily, Gain Capital
3c. In the bottom box, choose the second option - "...shorter time-period..."
3d. Now you have a choice - you can either choose "EUR/USD, Tick, Gain Capital" from the list, just like you did with the Hourly bars. That would mean the Daily bars are also made from the tick prices. Or, you can choose "EUR/USD, Hourly, Gain Capital", to have the Daily bars made from the Hourly. It's up to your preference, but the second option would be far quicker.
3e. Click OK.
 

Side note #1:

Each Data Manager entry creates a file on your computer which will store the prices. If you look in your file system you should now see 3 new files: gain_32_tk.tsphd, gain_32_1h.tsphd, and gain_32_1d.tsphd, respectively.
 

Side note #2:

The number 32 is what we call the "FIP ID", or "Financial Product ID". It's a number only useful within the Thinking Stuff world. 32 equates to the currency with symbol "EUR/USD".
 
Now to get the price history from the text files into the ATM files. To do this, we first create a "file load task", then process the task.
 

Load the files

 
4. Create the file load task

4a. Click "Price Data" > "Price history file loader"
4b. Files to load - browse for and select the file(s) to load. Recommend to just choose 1 file if this is your first time.
4c. Fill in the "File format" and "Dates in the file(s)" fields as per these standard settings for your broker.
4d. Price data to be loaded - EUR/USD, Tick, Gain Capital
4e. Click "Add To List"
 

5. Process the task

5a. Still on the File Loader window, go to "The Task List" tab
5b. Click "Start Loading"
5c. Wait.
 

6. Confirm the task worked

6a. Go to the "Completed List" tab.
6b. Scroll all the way to the right to see the result - "Success" is good. Anything in the "Error Text" field is bad.
6c. Back to the Data Manager Search window.
6d. Right-click on the "EUR/USD, Tick, Gain Capital" entry. A little pop-up menu appears. Choose "Table Information (row count, etc)"
6e. The message that shows up should display a count greater than zero.
 
So now we have the tick prices. What comes next is creating the Hourly and Daily price bars. This time we create "interval creation tasks", then process the tasks.
 

Create the price bars

 
7. Create the interval creation tasks

7a. (Should still have the Data Manager Search window open). Click (normal left-click) on the "EUR/USD, Hourly, Gain Capital" entry to highlight it.
7b. At the bottom of that window, go to the "Bulk Price Bar Creation" tab.
7c. Click "Add To List"
7d. Click on "EUR/USD, Daily, Gain Capital" to highlight it.
7e. Click "Add To List"
 

8. Process the tasks

8a. Still on the Data Manager Search window, go to "The Task List" tab
8b. Click "Start Creating Price Bars"
8c. Wait.
 

9. Confirm the tasks worked

9a. Go to the "Completed List" tab.
9b. Scroll all the way to the right to see the result - "Success" is good. Anything in the "Error Text" field is bad.
9c. Back to the "Price Data Configurations" tab.
9d. Right-click on the "EUR/USD, Hourly, Gain Capital" entry. A little pop-up menu appears. Choose "Table Information (row count, etc)"
9e. The message that shows up should display a count greater than zero. Same for the Daily one.
 

Cleanse the prices

Not all text files are created equal. Some have minor errors which can throw out your backtesting results. The easiest way to check for these errors is to view the chart. Ridiculous prices are immediately obvious.
 

10. View the chart

10a. Click "Price Data" > "View charts"
10b. Fill in the search criteria.
10c. Click "Chart"
 

11. Cleanse the data

11a. If the chart looks fine then you're all done.
11b. If there are extreme spikes in the chart then it's possible there is some erroneous data in the text files. Follow these steps to perform the cleanse.
 

Obtaining And Using Historical Tick Prices From Oanda

[Note: these instructions for Oanda were written a couple of years ago. If you have more recent experience of obtaining their historical prices we would appreciate an update].

Oanda, through the FXTicks tool in their FXLabs section, offers tick data going back to January 1st, 2004. This is for five currencies only though - EUR/USD, GBP/USD, USD/CAD, USD/CHF, USD/JPY.

From the website:

In order to qualify for this service, you must have an FXTrade account with a balance of 1000 USD or more. Data may be ordered as far back as January 1, 2004, and as recently as two (2) months ago.

Steps to obtain the files:

  1. Go to Oanda to order the files.
  2. Fill in the form on that webpage. ATM can handle ASCII Text, CSV, and Pipe-delimited.
  3. Repeat step 2 for all currencies that you want the data for.
  4. Wait up to 2 weeks for Oanda to process your request. When they notify you, they will provide you with a website link to click.
  5. Click the link and download the file. Whether you use downTHEMall! or not is up to you.

Now you have the files downloaded to your computer. But they are huge! Seriously. They are going to be more manageable if you split them into smaller files. That's where Text File Cleaver comes in.

Start Text File Cleaver, select the file to cleave, and select the directory to put the small files in. Click the "Go!" button. Repeat that for each big file you downloaded.

Then follow the rest of the instructions to load text files and create price bars. But on the File Loader window, select the smaller files to load instead of the big file.
 

How To Use Indicators

There are 4 basic concepts that you need to know:

  1. There are Rules and there are Values. Rules decide when an action is allowed. They evaluate to Yes/True/Do or No/False/Don't. Values decide where that action will be done. They evaluate to a single price on the chart - the price where you want to place an order; the price where you want to move the stop loss or take profit.
  2. Relative Strength Index (RSI) is an example of an Indicator.
  3. RSI(14) though, is a line on the chart. It is the combination of indicator plus the parameters that creates a line. RSI(14) is a different line to RSI(20).
  4. Everything is a line. The close price is a line. Volume is a line. The entry price of a particular trade is a (flat) line. RSI(14) is a line. RSI(20) is another line.

Rules

To get a line into something that can become a true/false answer means that we must compare it. We compare it:

  • With a particular number - is Line 1 above 100?
  • With its previous values - is Line 1 going up?
  • With a different line - is Line 1 above Line 2?
  • With the entry price - is Line 1 above than the entry?

The first step then, is to choose what kind of comparison will be done. Here are the options:
 

Use the value of a line
  • Line 1 equals X
  • Line 1 is above X
  • Line 1 is below X
  • Line 1 is in a range
  • Line 1 is not in a range
     
Compare the value of a line to the line's previous values
  • Line 1 is rising
  • Line 1 is falling
  • Line 1's value is the least of the last X values
  • Line 1's value is the most of the last X values
     
Compare the value of a line to the value of a different line
  • Line 1 is equal to Line 2
  • Line 1 is above Line 2
  • Line 1 is above Line 2 by more than X
  • Line 1 is above Line 2 by less than X
  • Line 1 is below Line 2
  • Line 1 is below Line 2 by more than X
  • Line 1 is below Line 2 by less than X
  • Line 1 is apart from Line 2 by more than X
  • Line 1 is apart from Line 2 by less than X
     
Compare the value of a line to the trade's entry price
  • Line 1 is above the trade's entry price
  • Line 1 is above the trade's entry price by more than X
  • Line 1 is above the trade's entry price by less than X
  • Line 1 is below the trade's entry price
  • Line 1 is below the trade's entry price by more than X
  • Line 1 is below the trade's entry price by less than X
     

Those last ones can only be used for non-entry rules.

Anyhow, with one of those selected, all that's left is to fill in the details for Line 1 (and Line 2 if applicable).

A common entry rule is "the close of the bar is above the simple moving average". The close price is just a line, and so is the average, so you would use "Line 1 is above Line 2" - Line 1 is the close, and Line 2 is the average. When this is true the signal is given.
 

Values

Values are easier, because you don't need to bother with the options above. You just create a line and that is the value. E.g. put a take profit at the entry price plus 50 pips, the stop loss at a simple moving average, etc.
 

More Options

You are given these very basic options to modify a line:

  • Line + X
  • Line * Y
  • (Line + X) * Y
  • (Line * Y) + X

Negative numbers can be used for X and Y.

What these settings allow you to do are to add/subtract a certain number of pips or percentage. For example:

  • Close price plus 5% would be: Close * 1.05
  • High plus 50 pips would be: High + 0.0050 (for EUR/USD)

If you need more than these basic options, you can create a custom indicator.
 

Indicators which normally consist of more than 1 line

If you think of the Bollinger Band indicator, you normally think of 3 lines - upper, middle, and lower. But for our purposes, those are actually 3 different Indicators:

  1. Bollinger Band Upper Line
  2. Bollinger Band Middle Line
  3. Bollinger Band Lower Line

And this is true for any indicator which normally consists of more than a single line.
 

Indicators which normally wouldn't be considered Indicators

How can candlesticks be "a line"? Well, at its simplest, a bar either fits a candlestick pattern or it does not. Candlesticks are therefore in a true/false form. But that doesn't fit into the "everything is a line" theory. So instead of thinking in terms of true/false, change it to 1/0.

Most of the time, a candlestick pattern will not be present. The "indicator" value stays at zero. When the candlestick pattern appears, the indicator spikes up to 1. Then back down to zero when the pattern is gone.

What was just described is simply an oscillating indicator, with values ranging between 0 and 1. That's now a line which can be used like any other line. So the basic concept is to replace true/false results and anything similar, with numbers. 0/1. 1/2. -100/100. It doesn't really matter as long as they are numbers.

So let's say we use 0 (zero) for when the candlestick pattern is not there, and 100 when the candlestick pattern is there. To make a rule that uses that candlestick pattern, use "Line 1 equals X" - Line 1 is the candlestick, and set X to 100. When this is true the signal is given.

It turns out candlesticks are actually a little more complex than true/false, anyway. The following are possible:

  • the candlestick pattern is present in a bullish way (result: 100)
  • the candlestick pattern is present in a bearish way (result: -100)
  • the candlestick pattern is not present (result: 0)

Further, there are a couple of candlestick patterns that give five values: 200, 100, -100, -200, zero. You should chart the candlestick you are interested in to see its possible range of values. And that's the beauty of treating everything as a line - you can chart and visualise all indicators and see how they behave.

Note: peak and trough (and swing) calculations, "Current Pattern" and "Previous Pattern" are also treated as oscillating indicators:

  • Higher Peak = 2
  • Higher Trough = 1
  • Lower Trough = -1
  • Lower Peak = -2
     

When The Day Starts

A trick with the dates is to be aware of the start time for that broker's "Day". This affects Daily bars only.

With Gain Capital the start time is 5:00pm New York time. Or more correctly, the end of their day is 4:59:59pm.

So what you might think of as the Daily bar for November 2nd, actually starts at 5:00pm on November 1st.

What it means is if anywhere in ATM (backtesting, charts, view data, etc) you choose a "From" date of "01-Jan-06 00:00:00", the Daily bar starting at "31-Dec-2005 17:00:00" (the bar you think of as that for January 1st, 2006) will not be included. And most likely you did actually want to include that bar.

Similarly, choosing a "To" date of "31-Jan-2006 23:59:59" will include the Daily bar that starts at "31-Jan-2006 17:00:00" (the bar you think of as that for February 1st, 2006). And most likely you did not want to include that bar.

Where the start of the day is midnight GMT, there is no such problem.
 

ATM File Extensions

*.tsatm - settings file

*.tsphd - price history file

*.tssys - exported trading system

*.tsiba - exported alert

*.tsind - exported custom indicator

*.tscht - exported saved chart
 

# Bars To Load

When you add or edit a rule or value, sometimes you will be asked to fill in the "# Bars To Load" field. This value is used to determine how many price bars should be retrieved.

Less bars means faster processing, and so ATM tries to retrieve the minimum possible. When something like a simple moving average (SMA) is used, it's pretty easy to work out how many bars are required - if it's SMA(20) then ATM retrieves 20 bars.

But for other rules, e.g. those involving "previous SMA swing low", it's not possible to mathematically calculate the number of bars that will be required. Maybe the previous SMA swing low occurred 30 bars ago. Maybe 40. It's in these situations that you'll need to enter the value yourself. Choose a value big enough so that enough bars are going to be retrieved to do the calculation, but small enough so as not to slow ATM down.