NOTE: With the creation of the Thinking Stuff User Manual (available on the Download page), this Knowledge Base has become more of just an announcements area. So maybe not so interesting. Try the Blog instead.
|
|
Articles from
November 2006
v0.9.0 is going to be Release Candidate 1. It is expected to be released on the weekend of December 9/10.
Actually I hope it will be before that, but there has been some craziness on the farm recently that has taken me away from the computer.
Then there will then be a few weeks of heavy testing, some rapid releases to get rid of bugs as they are discovered, and my Christmas present to myself will be to release v1.0.
Astute readers will know that I said the same thing last year, but this time it will be true :-)
If you look at the Road Map, you'll see there's still plenty in the pipeline. This kind of software will never be "finished" - there will always be a new feature that I think of, or that are requested by others. And I suspect that is why the actual release of v1.0 will be in Christmas '06 rather than Christmas '05.
So, I drew a line in the sand, and v1.0 will be the result. Still plenty of features though. Once out, I'll then be able to concentrate on other things for a while. Like actually trading, looking for employment, exercising, showering, that kind of thing :-)
But rest assured that I will get to those other things in the Road Map.
Right now accounts are "attached" to trading systems, and when you do that you also specify the currency to trade in that account.
This is done on the "Accounts & Currencies" tab of the Trading Systems Update window.
In this way, one trading system can trade in multiple accounts and/or multiple currencies. E.g.:
- Account #1, EURUSD
- Account #1, GBPUSD
- Account #2, GBPUSD
In the next release, which will be v0.9.0, this is going to change. Instead of one trading system trading in potentially multiple accounts, one trading system will be able to trade in one account and one currency only.
The change made a lot of things in v0.9.0 a lot easier to do. When thinking about the impact of this change, I realised that:
- It's unlikely that most people are going to *have* more than one account, let alone trading the same system in more than one account; and
- Because of all the various settings, it's unlikely that people are going to be using the exactly the same trading system for more than one currency. Sure, you might use the same rules, but most likely you'd need to alter the periods used for moving averages, etc, in order to get that system to work with a different currency.
There are going to be exceptions to the above 2 points (I know one for sure - sorry Josh), and there is a workaround.
As of v0.9.0, the Accounts & Currencies details are now entered on the "Details" tab (which also doesn't exist until v0.9.0). And rather than attaching accounts and currencies, you just select one of each from a list. (These fields are optional, unless you want that trading system to auto-trade).
When v0.9.0 is released, your Accounts & Currencies setup is going to be wiped. You'll need to manually re-select your account and currency for each trading system you have auto-trading.
If you did have a trading system or two that has more than one account/currency attached, then use the "Copy" functionality to copy your trading system.
In the copied system, set the account and currency to something else. That's it. One trading system for each account/currency combination you had before.
The net effect on TS is nothing - it'll do the same trades as it would have done before, and it will take the same amount of time to do so.
- Changing a trade's status from Closed back to Open, click Save, none of the closing details (price, date, etc) are removed.
- Fixed this: "There was an error while attempting to send an Alert: Could not find the details for System with ID: ."
- Fixed this: "Object reference not set to an instance of an object." when trying to send a trading alert.
- Update licence to include SMS.
Manually entering the details for a new order is a bit of a hassle, especially when you just want to get that order placed NOW! NOW! NOW!
At the bare minimum, you have the entry price, the stop loss price, the number of units, and the currency.
Doing it through TS, you also need to enter the trading system and account to use.
It's a bit much. But, there is a way around it. You can use the Copy function provided by TS, which will open up the Orders Update window with all the same settings as the order being copied.
Click the Save And Close, or Send Order To Broker button, and you're done.
You'd probably want to change a couple of the settings before you send this new order off to the broker, but this shortcut gets you out of having to fill absolutely everything in absolutely every time you place an order manually through TS.
If you want, you can open trades manually, and then get TS to do the trade management part.
The first thing to do is create the limit or market order. You don't necessarily have to open the order through TS, but it will make things a little simpler.
TS always requires a stop loss, so if you place an order through your broker's platform without one, its details won't be downloaded.
Secondly, because your order was placed through your broker's platform, TS won't know which trading system it belongs to, so it will use the "Unknown" system.
If you use TS to open the order manually, both of these things get taken care of - TS will require that a stop loss is placed, and will also require you to specify the trading system.
Now, once the trade is opened, which will be immediately if using market orders, you download the transactions for that broker to ensure that the new trade is registered in the TS database.
Now go and edit that trade, and set the "Is handled by auto-trading" option. If you opened the trade using the broker's platform, also set the trading system that opened it.
Ensure that the trading system you specified is set to auto-trade. And kick off the auto-trading.
The trading system will see that it has an open trade, and do the trade management.
Something to look out for is the fact that for each trading system, TS can only handle one open Long order *or* trade at the same time, and one open Short order *or* trade at the same (but you can have both a Long and Short). If you create an order manually in the way specified above, and that order breaks this rule for the trading system, TS will have a heart-attack.
The question is then, when the trade that TS is doing the trade management for is closed, how to prevent TS from opening a new order?
There are two ways. First, you could create a Holiday that goes from 01-Jan-2000 to 31-Dec-2999. Attach that Holiday to the trading system, specifying that no new orders are to be placed within the holiday period.
Second, you could create the trading system without any Entry Rules, or with Entry Rules that taken together, could never be true. E.g.:
- Entry Rule - Close Above SMA(20)
- Entry Rule - Close Below SMA(20)
On the Command Centre you can set TS to periodically download your account and/or transaction information. The default setting is 10 minutes between each download.
Before each auto-trade, however, TS does this anyway. So it knows exactly what trades and orders are open, and exactly how much margin is available.
Therefore, keeping the default setting of 10 minutes should be just fine.
A trick with the dates is to be aware of the start time for that company's "Day".
With Gain Capital the start time is 10PM (GMT).
So what you might think of as the Daily bar for November 2nd, actually starts at 10PM on November 1st.
What it means is if anywhere in TS (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 22:00:00" will not be included.
Similarly, choosing a "To" date of "31-Jan-2006 23:59:59" will include the Daily bar that starts at "31-Jan-2006 22:00:00".
Oanda's start of day is midnight GMT, so there is no such problem with their data.
- Add Direction field on Alerts - Long or Short - so can use all rules (some rules, such as some of the Candlestick patterns, need a direction).
- More activity when auto-trading, including the last date used for calculations.
- As well as an email and a message on the screen, alerts can now also play a sound and/or send SMS messages.
- Can send alerts via SMS. Some countries/networks allow free SMS, while others require Clickatell account and the purchase of (fairly cheap) SMS credits.
- Can periodically send "Everything's Fine" SMS.
- Upgraded Npgsql dll to v1.0 (that's the thing which lets a .NET app connect to PostgreSQL). Was previously using RC3.
- Upgraded to latest Oanda API:
fxClient-VB-VS2003-2006-11-1.zip
- Now handles Oanda transactions with description 'Funds Withdrawn'
- Stop showing "duplicate key violates unique constraint" error during Oanda price data downloads.
- Code was preventing subscribed users from using Alerts, and allowing non-subscribed users.
- MACD calculations now using Exponential Moving Averages instead of Simple Moving Averages, to bring it in line with Oanda charts.
- Added link to Knowledge Base from Help menu.
- Fixed up the other links under the Help menu that were still pointing to old pages.
When auto-trading, the trading systems work out automatically the number of bars to retrieve in order to perform the calculations.
The less bars, the better the speed, so TS works out the absolute minimum number of bars required.
For example, to calculate a simple moving average of period 20, you need 20 bars. Simple.
For the MACD Histogram, which calculates two exponential moving averages, then the MACD equals the difference of those two EMAs, then the signal line is the exponential moving average of the MACD, and then the MACD Histogram is the difference of the MACD and the signal line, it's a little trickier. Don't worry about it, TS works it out.
But here's the thing - some indicators have a memory. That is, their calculations work out differently depending on how many bars you retrieve. TS always retrieves the minimum required, but you can override this on the "No Trading" tab of the Trading Systems Update window.
Exponential moving averages (EMAs) are one example. With EMAs, the first value is worked out exactly the same as a simple moving average (SMA). The next value is then worked out taking the previous value into consideration. And so on.
So let's say you have 25 bars in total, and want to calculate the 20-bar EMA. Retrieving only the last 20 bars, the EMA at position 5 is going to be calculated the same as the SMA.
But retrieve 21 bars, and the EMA for the bar now at position 6 will be calculated taking the previous value into account. It is not going to equal the SMA. And that's the whole point of this article - to make you aware of this kind of thing.
So if you look at a chart with an EMA plotted, it might be slightly different to the EMA that your trading system is using. Because when you chart, normally you chart a lot of bars. But TS is only going to retrieve the bare minimum.
The way to stop that difference from happening is to override the number of bars that the system uses, although I can't give you a generic number to use because it all depends on your other settings.
If you put the setting too few, TS will revert back to its own calculations.
As well as the Exponential Moving Average, the other indicators that have this memory are the MACD Histogram, which uses EMAs for its calculations. Also Parabolic SAR.
There could be more, please let me know if you know.
And if in doubt, just contact us.
I've added a couple more Educational Examples, and one more Real-life Example trading system.
The two new educational examples are under the headings:
- Using Pip Offset; and
- Trailing Stops.
And the new real-life example is under the heading:
- %b System #1 With Chandelier Stop
Even if you have a live Gain Capital account, which you need to have in order to use their API, your demo account will still expire every 2 months.
When this happens, just use the Live Help feature on their Contact Us page to get it re-enabled.
I don't recommend to send them an email.
Oanda's account structure is like this:
- Main Account
- Sub-Account #1
- Sub-Account #2
TS's account structure is like this:
- Account #1
- Account #2
- Account #3
So how do you set up Oanda sub-accounts in TS?
Firstly, set up your User in TS, using the Oanda username. Let's say the username is "Bob".
Now, each account or sub-account in Oanda has a different account number. You should create one TS account for each Oanda account or sub-account.
E.g. you have an Oanda account with username "Bob" and #123456789. That
account has a sub-account #987654321.
In TS, create your Oanda user "Bob". Then create one TS account, with user "Bob" and account number #123456789. Then create another TS account, with user "Bob" and
account number #987654321.
In summary, 1 Oanda account with 1 sub-account equals 2 accounts with the same User but different account numbers in TS.
When you set up your trading accounts in TS, there is an option to mark it as a "Real" or "Paper" account.
This has caused some confusion with "Real" and "Demo" accounts.
Here's the difference: Think of account types of "Real" and "Paper" in TS as "exists with a broker" and "exists in my
head for practice purposes".
So if the account exists with a broker,
even if it's a Demo account, it is in fact "Real".
"Paper" accounts will not be used for auto-trading, nor for downloading price, transaction, and account information from the broker.
An alarming number of people ask me how do they ensure that a new order will not be placed while a trade is open.
The "Different Stages of a Trade" section of the " Setting Up Trading Systems In Thinking Stuff" page has more information, but I thought I'd clear it up here as well.
A new Long order will be placed only if there is no existing Long order and no existing Long trade. It's the Long Entry Rules that determine if an order is placed or not.
If a Long order is in place, it will be modified if necessary. If the Long Entry Rules say that no order should be there, it will be cancelled.
If a Long trade is in place, the trade management rules and values take over. The Long Entry Rules are not needed anymore until it's closed. As I said, a new Long order will not be set while a Long trade is open.
But here's the thing - Long and Short are separate to each other. Just because a Long order or trade is open, it's not going to prevent a Short order being set. In fact quite often people want to have a Short order in place at the same spot as the Long stop loss. As the Long trade is exited, the Short trade is opened.
This creates the possibility that your Short trades will interfere with your Long, and vice-versa. Please read the "How to hedge?" section of the page mentioned above, even if you don't want to hedge.
The easiest way to get around this is to have one account for all Long trades, and a different, or sub-account, for all your Shorts.
When the Entry Rules allow an order to be placed, TS calculates the wanted entry price, the initial stop loss price, and the initial take profit price (if there is one).
At some stage you will probably use the "X Pips Above/Below the Calculated Entry" value for your stop loss or take profit. There are a couple of things I wanted to point out about these 2 values.
Firstly, as the name implies, it's above/below the *calculated* entry, which is not necessarily the *actual* entry. Most of the time the calculated and actual entry points will be the same. Gaps (unlikely but possible in currency trading) or a fast-moving price can mean you get some slippage, and the price you want to get in at is no longer available.
So you put you order in to go Long at 1.2000, with stop loss 1.1190, and take profit 1.2010. The broker accepts your order, but due to slippage your actual entry price turns out to be 1.2001. Well, the stop loss is still going to be at 1.1190 (entry price minus 11 pips), and the take profit is still going to be at 1.2010 (entry price plus 9 pips).
If you're using these values for trade management, they will use the *actual* entry price, because at that stage the actual entry price is known.
Secondly, the entry price for Long trades is the Ask price, and Long trades are exited at the Bid price. The entry price for Short trades is the Bid price, and Short trades are exited at the Ask price.
These values - "X Pips Above/Below the Calculated Entry" - will therefore be working off the Bid or Ask depending on the direction of the trade. The reason I point this out is because of the spread.
When you enter a trade, you are already a certain number of pips in negative territory. Let's say a spread of 5 pips. So if you want to set your take profit to the entry plus 10 pips, actually the price needs to move 15 pips before the take profit will be hit.
Similarly, if you put the stop loss 10 pips below the entry price, the price only has to move another 5 pips down for the stop loss to be taken out.
So 15 pips up and win 10 pips, 5 pips down and lose 10 pips. This is just how currency trading works (all trading actually, if you think of a commission in terms of pips), but I wanted to make it clear that these values do not take the spread into consideration.
I'm not sure how to describe this bug. On the one hand it was very small and easy to fix. On the other it prevented auto-trading from happening. Therefore it's the Big Little Bug release.
Download - See what changed - Purchase.
- Fixed a "object reference not set to an instance" error that prevented auto-trading.
On the Command Centre, there are 2 places for downloading prices from Oanda.
One is the "Price Downloads" tab and the other is the "Special Price Downloads" tab.
The latter downloads only the prices needed by active trading systems and active alerts. In this way, you can be sure that your active trading systems and alerts are getting fresh data to work off when they need to do their calculations.
You then use the Price Downloads section to download as much data as you want, so you can use it for backtesting later on.
Doing both is fine, and recommended, but it may sometimes lead to an error being displayed:
Problem encountered while downloading special prices from Oanda:
ERROR: 23505: duplicate key violates unique constraint "pk_zoanda_usdjpy_30s"
at ThinkingStuff.frmAutoTrading. bgwPriceOandaSpecial_RunWorkerCompleted (Object sender, RunWorkerCompletedEventArgs e)
This particular error was for USDJPY 30-Second bars.
The error comes about when both the Price Downloads and Special Price Downloads are downloading the same currency/interval at the same time. When they both start, neither thinks a particular bar has been entered into the database yet. One will do the insert before the other. The other will try to do the same insert, but now that bar is actually there.
The database doesn't allow a particular bar to be inserted more than once, so this error is shown.
Because the bar is already there, this is not a problem. Don't worry about it.
The regularity of this error will depend on how many currencies/intervals you are downloading. The more currencies/intervals you are downloading, the less likely both the Price Downloads and Special Price Downloads are going to be working on the same ones at the same time.
Download - See what changed - Purchase.
The main change in v0.8.4 is the addition of more file formats imported by the File Loader window, and output by the View Data window.
- "[OHLC] Of Last X Bars Clear of Entry" rule has a quirk. The Close of the current bar is checked to ensure it is above the entry price. If not this rule will return false, regardless of what the user set as the [OHLC].
- Now handles more types of Oanda transactions - Funds Added, Fund Withdrawal, Fund Desosit (sic), Fund Deposit (in case they fix the spelling), Change Margin, P & L Reset.
- When saving price data to a text file, include the currency. Also change the date format to yyyy-mm-dd hh24:mm:ss
- Have File Loader window handle Oanda tick data file formats.
- Have File Loader window handle file format that TS itself outputs.
On the Command Centre you can specify how often you want Auto-trading and/or Alerts to kick off.
Plus, on each individual Trading System and Alert, you can specify how often you want it to do auto-trading or alerting.
This article hopes to explain the relationship between the two settings. For brevity, I will just talk about Trading Systems, but it applies to Alerts also. The Command Centre window "Auto-trading" tab will be abbreviated to CCAT, and the Trading System window "Accounts & Currencies" tab will be abbreviated to TSAC.
Let's assume your system uses 1-Minute bars. 1-Minute bars is a very short time-frame, so I think you need to kick things off quite often.
If you imagine the scenario where on the TSAC you set your Trading System to run every 1 minute, and on the CCAT also set Auto-trading to kick off every 1 minute.
The first time Auto-trading kicks off at 12:00, a fraction of a second later it starts off your Trading System. So your Trading System is started at 12:00:00.001.
At 12:01, the next time Auto-trading starts, it is not going to start your Trading System. Because it is not 1 minute since it was last kicked off. It is 59.999 seconds.
At 12:02, the next time Auto-trading starts, it will start your Trading System. That's effectively 2 minutes since the last time.
Now let's change the CCAT setting to 5 seconds. The result is:
Auto-trading starts at 12:00. System is kicked off at 12:00:00.001.
Auto-trading starts at 12:00:05. Nothing to do.
Auto-trading starts at 12:00:10. Nothing to do.
Auto-trading starts at 12:00:15. Nothing to do.
And so on...
Auto-trading starts at 12:01. Nothing to do. It is "only" 59.999 seconds since it was last done.
Auto-trading starts at 12:01:05. System is kicked off at 12:01:05.001, effectively 1 minute and 5 seconds since the last time.
Most likely the next time through, that trading system will also be kicked off 1 minute and 5 seconds since the last time.
So, there is a creep forward effect. Your trading system is not trading every 1 minute as you specified, it is trading every 1 minute and 5 seconds. To get around it, maybe on the TSAC use the setting of 55 seconds instead of 1 minute.
This time at 12:00:55 there is nothing to do because it is 54.999 seconds since it was last done. But at 12:01, it is now 59.999 seconds (effectively 1 Minute) since the last time, our setting is 55 seconds, so the trading system is processed.
Now, I came to the value of 55 seconds by this formula:
How often I actually wanted the trading system to run minus How often auto-trading is kicked off.
That is, my wanted setting on the TSAC minus the setting on the CCAT.
And I thought about doing this automatically in the code, but that formula really only works if those two values fit nicely into each other. If you use a CCAT setting of 9 seconds, for example, then the formula would tell me to set the TSAC setting to 51 seconds. But actually that would result in the trading system doing auto-trading every 54 seconds. Not every 1 minute, and that instead would cause a "creep backward" effect.
In the end, armed with this knowledge about the possible creep forward or backward, you are just going to have make the best judgement about which TSAC setting is best based on your own CCAT setting.
For this particular example of using 1-Minute bars, I would do the following:
- On the TSAC, have your system do auto-trading every 55 seconds.
- On the CCAT, have it start Auto-trading every 5 seconds.
There is no harm in having a system which uses 1-Minute bars to do auto-trading more than once a minute. In fact this scenario is most likely unavoidable as you use longer and longer intervals such as Hourly or Daily.
Previous Page | Next Page
|