Selasa, 01 Desember 2009

HSI System

I'd like to start by saying that the formatting of the text doesn't work very well, and I don't feel like sitting here screwing around with formatting.
Since the last post I've been working on a trading system aimed specifically at the Hang Seng HSI trading on the Hong Long exchange. While developing the signals and code to support the trading system I've also discretionary traded MHI, the mini version of HSI. In addition I've been chatting with Steve from California and Mr RiskAddict from Japan, as you can see in the chat window on the right. If you're interested in autotrading I suggest you visit Mr. Addict's blog. BTW, Mr Addict mentioned this trading system file, and I think you should read it.
My AFL code is organized into blocks like this;
Filters - setting available in the params window
  • allowable trading times
  • shorting and buying switches to allow me to turn ON/OFF shorting or buying
Backtest parameters including a ON/OFF switch in the params window

Systems
This is blocks of code that are the sub-systems that make up the entire system of auto trading code. In the params window I have the ability to turn the sub-systems ON/OFF as well as set the order type for each system individually. See screen shot below.

Plot
This code lets me turn ON/OFF the plotting of the signals and some moving averages.

Test
Code that allows an instant order to be sent out as well as a test for writing a cancel order to Bracket Trader (BT)

Bracket Trader Code block for writing the text file that BT reads. I just purchased BT, allowing me to add my own symbols and change the audio alerts.
Backtest plot and code
This chunk of code allows the plotting of backtest results and simulates scaling out with an initial order of 3 cars (contracts). The plotting code tells me why the position was exited, it shows different shapedigits depending on things like stopped out, trail hit, profit target, etc.

Title code

Debug code
Sends specific into to DebugView

The System
The actual "system" consists of a bunch of sub-systems which I'll explain briefly. Here's an interesting wrinkle though - if System 1 buys and has hit 2 targets and is trailing the 3rd car, then system 2 shorts, the short is ignored. Signals are only taken once I'm flat. I call this letting the profits run and I'm OK with that because I do get wrong signals.
The system buys 3 cars, has an initial stop, 3 separate targets and a trailing stop. Here is how it works for now, subject to change without notice;
Buy 3 cars
set initial stop at 15
1st target at 10
2nd target at 20
3rd target at 50
move stop to BE at 1st target
trail at 2nd target
While I've been watching this system fire off signals and debugging it in the fly it's been profitable on simulation but I don't trust it just yet (profitable doesn't count the buggy entry's at market when it shouldn't have fired off a signal but did). I still need to do a successful backtest. I have backtested but haven't been happy with the code result of scaling out, needs some work. I also need some data and I'm working on obtaining that. So far it all looks promising. If the system turns out to be 'not so good', I'll have code that I can simply insert another system, or add to it.
I am considering manually firing BT based on the codes, I'll try that on sim, I don't think I can match the speed of the auto system though, even with BT at my fingertips.
Sub-Systems
A brief description of each;
1 Find a trend and jump in
2 Find a channel, or a cycle, and jump in
3 Find the momentum and go the other way - fade it
4 Find a MA that has reverses and jump in
5 Find two indicators going the same way and jump in
Each one of the above has it's own set of filters, for example, #4 doesn't just blindly jump in, it looks for some other stuff.
I don't know if this post will help anyone, that isn't my intent. I needed to write it down to better digest it. If it helps you, great.

Related Posts Plugin for WordPress, Blogger...