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.

Jumat, 30 Oktober 2009

HSI / MHI Hang Seng

I've been searching the web for blog posts and forums to gain insight into the HSI. It seems some of the comments are dated. If you trade this I'd appreciate any feedback or information you can offer (what doesn't work, what works) from your experience. Here is what I have learned thus far;

It's technical intraday chart looks very technical and normal, the daily looks like its on crack, gapping all over the place. The opening gap break out seems to work well, gap and run. I've been using the first 5 to 8 minutes to gauge the direction and strength. Then I bottom fish and take the breakout for my position and let it ride. Last night worked perfect, huge gains, sold when the upwards trend line broke.

I also only trade the "morning session" up to about midnight EST, then its bedtime. The "afternoon session" seems to have a mind of its own, like a different day.

The first half of the morning session moves and trends, the second half can be choppy, the range (ATR) increases too. Just before each session closes the price goes nuts.

I've read that the market is heavily manipulated by technical traders? I'm not sure what that means, it looks like it has some structure on the 1 minute time frame.

Questions for you if you trade this;
  • What is your daily target (in points or dollars)
  • What is your daily loss limit?
  • Do you trade specific time of the market?
  • Do fibs work? I have noticed they work somewhat, good gauge of a pullback but I generally don't count on them.
  • Do pivot points work? My guess is not since the gaps are huge, perhaps weekly pivots?
So far the P/L is floating in the black a little above break even and that's OK with me. Since I'm new to the Asian market, I need to learn it before going to bigger positions.
Any input would be helpful for me as I am building my strategy and plan for trading this puppy.

I also open up the chat room just before the market opens, its been quiet. Anyone know of any chat rooms for the Asian market?

Selasa, 27 Oktober 2009

VWAP

Definition


"Volume Weighted Average Price. A measure of the price at which the majority of a given day's trading in a given security took place. Calculated by taking the weighted average of the prices of each trade. The method is used by institutional traders, who often break a given trade into multiple transactions."

Another definition

The VWAP for a stock is calculated by adding the dollars traded for every transaction in that stock ("price" x "number of shares traded") and dividing the total shares traded. A VWAP is computed from the Open of the market to the market Close, AND is calculated by Volume weighting all transactions during this time period.

VWAP, or Volume Weighted Average Price is a tool used by some traders, I first learned of it from Brian Shannon who trades stocks. This won't work for forex since there is no volume.

There are a few different ways of displaying this in Amibroker. It can be a simple line like a moving average, this is the most common way pro's use it. Amibroker has a function to display it behind price, look in the help for these two functions with examples;
  • PlotVAPOverlayA
  • PlotVAPOverlay
Here are a few ways tp lot it and some code to try out.

eTokes Blog post on VWAP
I suggest reading his post, as well as Brian's post on VWAP, links below. eToke used a vertical "study" line drawn on the chart. This might give you an error on your chart if there is no line drawn. Here is his code with a little fix for this problem (adding "Nz");


Plot VWAP starting at a horizontal study line (Study ID set to ST)

//VWAP since last change in sentiment
TurningPoint = IIf(Nz(Study(“ST”,GetChartID())==0,1,0));
BarsSinceLastTurn = 1 + BarsSince(TurningPoint==1);
StartBar = ValueWhen(TurningPoint==1, BarIndex());
RunVolume = Sum(V,BarsSinceLastTurn);
IIf (BarIndex() >= StartBar, MTVWAP = Sum (C * V, BarsSinceLastTurn ) / RunVolume,0);
Plot (MTVWAP,”MTVWAP”,colorPink, styleLine);

Other ways to plot VWAP

Plot VWAP starting at selector line

This is another way, it will display the VWAP starting from where your selector line is placed. I use it for short term trading to see where all the volume is, makes finding support / resistance a bit easier when working with breakout.

_SECTION_BEGIN("Selector Line VAP");
segments = IIf(SelectedValue(BarIndex()) == BarIndex(), 1, 0);
PlotVAPOverlayA( segments , 300, 50, ParamColor("Color", colorDarkGrey ), 6 );
_SECTION_END();

Plotted like a moving average

_SECTION_BEGIN("VWAP");
Bars_so_far_today = 1 + BarsSince( Day() != Ref(Day(), -1));
StartBar = ValueWhen(TimeNum() == 093000, BarIndex());
TodayVolume = Sum(V,Bars_so_far_today);
IIf (BarIndex() >= StartBar, VWAP = Sum (C * V, Bars_so_far_today ) / TodayVolume,0);
Plot (VWAP,"VWAP",colorOrange, styleThick);
_SECTION_END();


Other links on VWAP
VWAP link 1
VWAP link 2
Related Posts Plugin for WordPress, Blogger...