1
$\begingroup$

I trade on the FOREX market. Currently I am attempting to use the FLANN library (Fast Library for Approximate Nearest Neighbors) to find N similar situations to the current market state. I end up with a list of historic market points that are similar to my query point, and a value associated with each of these points that represents the "distance" away from my query point.

I evaluate my strategy's performance at those points, and (potentially) enter the market using the profit factor (gross gain/ gross loss) as my bet size.

However, since each of these points is a different distance away from my query point I should be weighing the profit/loss at these points differently.

Initially I thought that I would weigh them like this:

Weight = 1/Distance

The problem is that if 1 point is a close distance away from the query point (ex. dist = 10), and all other points are a larger distance away (ex. dist > 20000), then I am basing my bet entry size almost entirely on the 1 close point.

Currently I am attempting to normalize like this:

Weight = 1/log(1+Weight)

This gives me a more usable value, but it seems pretty arbitrary (why log and not ln?)

Does anyone have a better idea?

  • 1
    Sounds like you are doing [scattered data interpolation](http://en.wikipedia.org/wiki/Multi$v$ariate_interpolation#Irregular_grid_.28scattered_data.29) using [in$v$erse distance weighting](http://en.wikipedia.org/wiki/In$v$erse_distan$c$e_weighting). You $c$ould also look into [moving least squares](http://en.wikipedia.org/wiki/Moving_least_squares), [local regression](http://en.wikipedia.org/wiki/Local_regression), or other [radial basis functions](http://en.wikipedia.org/wiki/Radial_basis_function). Having no actual experience with this sort of thing, I can't comment any further.2011-09-08

1 Answers 1

3

The answer depends absolutely on how you define your 'distance', which in turn depends on what the factors of your market state are. You're right that transforming $d\to \log(1+d)$ is arbitrary. You could equally well use $d\to\sqrt{d}$ or $d\to\tanh(d)$ or any other function which is monotonic increasing and maps $0\to 0$.

However, before you try and do anything with variable weights, you should measure the generalization error from using constant weights and see how much you can improve on that by using variable weights. It's completely possible (in fact quite likely) that you will overfit your model by allowing more parameters, and that a simpler model will perform better. (Advice from another FX trader).

  • 0
    There are people who make money from algorithmic trading in many assets, of which FX is one (it's the biggest by volume and the most liquid, although the profit margins are tighter as a result). The diversity of models in use is pretty impressive. Some of them work pretty consistently, some only in very specific market conditions. I've not experimented with what the OP is trying to do, but it may well work. The proof of the pudding is in the eating (and in a carefully conducted backtest, of course).2011-09-08