Understand HSI using a programmatic approach — I

Chris Wong
Aug 8, 2017 · 4 min read

There are a lot of unofficial beliefs on HSI, including a bottom in May and peak in July.

Instead of backtesting for a particular one or two signals, I want to offer a programatic way of knowing how HSI behaves in the past decade. In the first episode, which is this article, I want to apply simple strategy, just to demonstrate my logic and how programs can be used to examine our trading ideas more objectively.

Before diving into the content, I want to highlight the fact that I am just testing HSI, not even its future or any derivative. So this article would be of research in nature. It does not and should not be directly implemented into a trading strategy unless you want to play dice.

So here comes the meat. Is HSI a trendy or a reversible index? This is a qualitative question, which we usually ask in conversation. A more investment-oriented one would be HOW MUCH? Now,

Long Strategy

This table lists the PnL of trend-following trading. The first row means to start buying after one up-move day. Buy in opening, sell at close, take the spread, that simple. The second row means to long only after two consecutive up days, take the spread of the 3-rd day. If it is an up day, then continue to long on the 4th day, until a down to break the trend, then recount the next up day as day 1, so on and so fro…

Clearly, to start buying on the 2nd to 7th day is a loser strategy, contrary to start buying after the very first upward move. However this strategy is a simple one considering the gain per trade (13p) and huge standard deviation, not to mentioned the drastic minimum and maximum gain compare to the average one.

Amazingly, there are many possible ways to make improvement revealed in this simple table. First, you would notice profit is generated mainly from the 2nd up days. As soon as you go long after HSI moves up for two consecutive days. Chances are, you would not make much money.

One-day Long Strategy

Bang! This is the PnL of longing only after the first up day, and just for ONE DAY. You get more profit but trade half of times, This buffs up gain per trade to 29p.

Second possible improvement is, to incorporate some shorting. From the first table, we observe start longing after 3rd to 7th up days seriously bankrupt you, lets test the effect.

One-day Long and Continuous Short Strategy

This is the PnL of two strategies, long after the first up move day for ONE DAY, start shorting after the up trend continues for certain day. The first row is to short after 2 up days, the second row is to short after 3 up days…etc.

It does not improve compared to long only, isn’t it? What if we only short one day?

One-day Long and One-day Short Strategy

Again the improvement is insignificant.

(Summary) — All we have considered, is just a pure switch of up/down. And we come up 30p gain per trade by simply long right after any upward day, for the next ONE DAY ONLY.

Lets add more complexity by considering the momentum. There are many innovative ways of measuring momentum. The simplest way to proxy momentum is by how much the close price is below the daily high. The closer these two prices are, the more bullish it is.

Convention would suggest the tighter the threshold, meaning that the closer the close price is to daily high the more likely the price on next day would shoot up. Practically, how tight should it be? I have tested the long threshold from 1 to 150 points. There are a lot of irregularity when the threshold is too small. The gpt only stabilizes at 50 and reach the peak at 94 points. So it means any day with a close price within 94 points of daily high is worth a shot.

Honestly I don’t like charting because it is simply not representative of the data. But to give you a visual favor I output a chart anyway. Standard deviation basically decreases as number of trades increases with threshold so I decided to keep them in the background.

Generally speaking, it is true that the looser the threshold, the more trade and profit you would have, but sacrificing the level of gain per trade. Having said that, picking the right sweet spot for each product requires programmatic testing.

Chris Wong
Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade