MrG's Custom Indicator - A call to arms, T2W unite!!

MrGecko

Senior member
Messages
2,778
Likes
789
OK folks, here's the crack.

GJ has started a thread designing an automated / mechanical system using technical indicators. Taking an interest in how he gets on, I threw a few ideas into the air to bash around; one of these was "how do you define a trend, and how can you measure it?".

Now, normally I am not one to take on indicators as part of a trade setup, but having recently switched to trading contracts with reliable volume, I have reconsidered this. As it happens, I am interested in Volume @ Price, its distribution, Market Delta, etc.. - none of that is going to be discussed here. However, I found myself asking the question above, and how you might be able to quantify the strength / development of a trend... Of course, not really knowing a whole lot about indicators, I have no idea of there is something that does this already - I think ADX has something to do with the strength of a trend (?), but I thought it a better idea to sit down with a pencil and paper and really think about it myself...

Which brings us on to this thread, the purpose of which is to answer a few questions:

1) How do you define a trend quantitavely?

2) How do you measure a trend quantitavely?

3) How do you turn that into tangible information?


Having thought a bit about it myself, I came up with the general principal of trigonometry and pretty basic physics (cue boo's and hisses), and sort of muddled around until I came up with something that could use as a framework for building a custom indicator. I have chosen to define a trend as the velocity of price over time (i.e. how many points does it move in 24 hours), because it seems the most intuitive measure of a trend that you can reflect in a number (remember, we are talking about quantitave measures, "higher highs and higher lows" isn't going to cut it); furthermore, it is pretty straightforward, and you can even find the "acceleration" with a bit more fun.

So, I have set myself the challenge of finding out how to measure "price velocity" and "price acceleration". As for going about how to actually do it, well I don't know yet. I have played around with some ideas (that didn't work), and also want to leave the page pretty blank to begin with (you'll see why later).

Getting down to it, you can see the attached diagram. The dashed dotted line represents a "smoothing"line, like an MA... I have approximated the change in the "smoothing line" with a right angled triangle, to give me a framework to go and play with the idea - you can see the edge of the triangle along the bottom (where Time will be on regular charts) as "Adj", the rightmost edge (where Price will be) as "Opp", and the edge joining up the two as "Hyp". Additionally, as was my original idea, you can see the angle theta (looks a bit like @) identified as well.

attachment.php


Now, to the crux: I would like to build some indicator that measure the velicoty of price, which in the diagram is approximated by the gradient (slope) of the "hyp" edge, or by the size of the angle @ - basically, how steep is the smoothing line. I present the problem here so that others can take the idea and put their own spin on it, perhaps go away and mess about with some ideas, and post their progress / thoughts / whatever on this thread. If enough people take the idea up and run with it, we might get a good discussion going of the results and their potential, and maybe even a few indicators that are useful.

So that's it - here is an idea I had for defining a trend in numbers, but haven't quite got a working model yet. If anyone has any thoughts or comments, please feel free to post them (this is why I want to leave the page blank) - the more ideas we get, the better we can evauluate what might work and what won't. Of course, there are no right and wrongs, so if you find that a method works for you but someone else disagrees, it just doesn't matter.

Right, going on a bit now, so I will leave you with some thoughts / experiences of my own so far:

# The indicator should be portable, going from stocks to FX, whatever - means relative price changes are important

# Given the above, there should be some inclusion of what constitutes a typical "unit" of price change PER ASSET - i mean, doing Ln returns on an FX chart is going to give you crazy results compared to a stock chart

# Using pixels on the screen to figure it out is just plain amateur

# You might like to calculate i tin many different ways - the gradient of the line, the size of the angle, the area of the triangle - all are representative of the same thing, the size of the "Opp".

# How do you determine what the threshold is for a trending market, instead of a rangebound one?

# can you combine velocity w/ acceleration to give entry signals as well?


Let's see if anyone takes a bite... I will post some more of my ideas later if there is any interest.


NOTE: Let's refer to the indicator as "Moving ratio Gradient" - codename MrG. That way, if it is absolutely f*cking brilliant and will make you stacks money all the time, I get a bit of internet fame too :cool: to see GJ's thread, click here
 

Attachments

  • MrG_T2W.png
    MrG_T2W.png
    70.1 KB · Views: 1,136
Last edited:
Squirrel, you mentioned being interested in Quantitative analysis didn't you?

Mate, there will probably be nothing more here than GCSE maths + statistics (and the stats is at a push!!!)
 
Squirrel, you mentioned being interested in Quantitative analysis didn't you?

Mate, there will probably be nothing more here than GCSE maths + statistics (and the stats is at a push!!!)

Don't get me wrong, I'm not complaining! I'll just need to do a bit of revision, but I'm game.
 
sorry, MrG, been done before. Gann et al.

Thanks for the tip-off mate, had a very quick look and I had imagined I'd use the angles / gradient in a slightly different way... off to search the net for a bit more on this Gann fellow!
 
:)Ironic that there's a whole long post about indicators and lots of things far too complicated for simple old me and then you get to the bottom and see MR G's signature

Shortcut the bulls!t and find serious posts here

Hope you find the answers mate
 
Gann :D I got a few links saved about him:

Tick-by-tick currencies, futures, stocks Day Trading Simulator- Learn to day-trade currencies, futures, stocks
The Gann Chronicles into the Future
Gann Angles 1

Also when searching for the holy grail and learning about Gann I discovered he got the methods behind the Gann Fan while on a journey to India and the fan being based on some old ancient Indian grid method :-0 so tried to learn a bit more about ancient Vedic maths whos methods might interest some maths fans :D (after hours of reading and searching nothing came of this holy grail quest btw)

but these maths methods help while shopping at Tesco :D

Vedic Mathematics in a Nutshell

Vedic Mathematics
 
This is old hat mathematically speaking. I use it already for correlating ftse index trend to stocks in ftse.

Calculating best fit trends

For a straight line the bigger m is the more ferocious your price change is likely to be in the trend.
 
Calculating the gradient isn't a problem. Calculating when a trend has started and will end surely is. Can use the above method or a few others to get the trend line, not really sure what you're getting at. Can the question be redefined for simpletons like me? What are you trying to achieve? Apart from market predictions.
 
MrG I have but A few suggestions from my own personal experience.

First I have studied Gann for over four years now and believe that most of what you are looking for can be taken from his TRUE use of angles on charts. To find how he used them I would recommend getting HIS writings and reading them. Most of his books can be gotten on the internet for free these days. You just have to look around.

After looking for a way to do basically the same thing that you seem to be wanting to do with your new indicator, I came to the conclusion that, as with all things trading you should keep it as simple as possible. i.e. If you can't make the calculations you want with basic math you are going overboard.
Of course the above statement is IMHO.

In the end I came to the conclusion that the things I wanted the indicator to tell me, ( I must have tried to make 15 different ones over the first two years) like is the market trending or is it range bound, I was still having to decide. How big does the value coming from the indicator need to be to be a trending market? I had to make that call only after studying a good bit of chart history with the indicator. Also when I changed the market I had to work it out all over again. On top of that the values were again different if the market was trending or range bound on larger time frames.
Then I started reading and learning about Gann.
I found that once I learned to draw the important angles on the charts that they did a BETTER job than any of the indicators I concocted ever did.
I still had to make my own decisions, but it was much easier to see and MUCH faster to find the important things to look for in each market with the angles.

I guess I could sum it up by saying: There is nothing new under the sun. No need to waste time on creating an indicator when some lines on a chart (or values in a spreadsheet for me) can tell you what you are wanting to know.

Best of luck to you how ever you choose to go about your trading!!

Jason
 
btw - I also modelled and calculated price acceleration and found it had limited value. and not for straight lines either although for any point on a curve the gradient is always a straight line.

I went through a period early in my learning where I applied all my mathematical knowledge to trying to model what was going on - fourier transformations for trying to find dominant frequencies, using gradients for all sorts of things, deriving price acceleration, strange ethereal **** with standard deviation for volatility outside of its normal use and finally concluded that most of it is noise and price action is where it's at.
 
Good points made all round so far...

I will describe the Idea I am working with currently:

1) Take the average range (either net range or absolute, I don'k know) and SD of the past X bars 9or smoothing line).. this is supposed to give us an idea of what a "normal" change in price is, its order of magnitude

2) Take the side "opp" and compare with the average +/- 1SD (or 2, whatever)

3) interpret this as some sort of gradient / angle / area (though not necessarily for a time of X bars, we might choose a smaller distance for the Adjacent)

This is a crude way of getting a "trendiness"... for example of Gradient (m in your case robster), a flat line has gradient 0, and a straight up line has gradient infinity

4) Then, either by backtesting some other method, identify which measures of our trend actually correlate with something we can recognise as a trend (say angle @ > 30 degrees or something)... we end up with a rolling angle @ over the past YY bars (given the typical move over XX bars), in order that we can input this into some simple boolean functions in an automated system - for instance, if @ < 30 degrees, define the conditions as "trendless".

5) I choose the +/- SD parts for a bit of a safety net - you might instead like to say that you measure the gradient / @ with a typical price "unit" of Avg + 1SD in an uptrending market, and interpret this as "if the typical unit of price change is below what we can reasonably expect given our sample data, the angle of our smoothing line is greater than or equal to our threshold, and using our parameters we define this as trending market conditions".

6) another thought I had was to collect the angle data and treat it as a mean reversion thing (which is where the acceleration comes in to play, I feel). By this I mean collecting a large sample and finding out how it is distributed - kurtosis, skew, and so on... (getting into deep water here though)

7) re: acceleration, I interpret this as nothing more than the rate of change of gradient, and have two ideas in mind

i - simple acceleration of gradient over a period of bars.. the rate of the change in the gradient over time... is it falling away? is the gradient getting steeper?

ii - gradients in series... very similar to i, but calculated slightly differently... I was thinking about comparing the gradients of three (or more) time periods going back - say from 0 - 10, 11 - 20, 21 - 30, 31 - 40... if the gradient each increases, that might be an indication of.. well, I dunno, something.

re: Gann - I have had a brief look at what he did, but I am looking to take a different route. It seems to me that Gann angles a) need a trend line to be plotted manually, and are b) arbitrary - where I am looking to go involves building some function of price (indicator) that can tall another function what the trend is doing... the result I have in mind is something that could work as a "black box" type system, taking in data, interpreting it in the way we design, and using this as a criteria on some other system.

re: re-inventing the wheel - I don't want anybody to get any misconceptions that I am off on a quest to uncover some never before noticed behaviour - we are talking about triangles, FFS. and of course, I suspect that I won't really find anything that adds significant value to anyones trading -

BUT (and this is the important part), there is absolutely nothing wrong with getting your hands dirty. If anything, it is preferable to stumble upon mediocre results than simply borrow other peoples - of all the people that use RSI, or Stochastics or whatever - how many do you think have an intimate knowledge and understanding of how they are calculated, and what exactly is being measured? Not many I reckon. So, it is better (IMO) to jump in at the deep end and start with a blank slate - if we truly understand what it is we are doing, we are in the best position to exploit it.

One last thing: Indeed take a look at the "Just charts no Chat" thread, that is how I do - and will continue - to trade; Being a devout cheese man shouldn't prevent me from taking an exploratory dip in the chalk... it's not necessarily about the destination, but the journey.
 
Good points made all round so far...

I will describe the Idea I am working with currently:

1) Take the average range (either net range or absolute, I don'k know) and SD of the past X bars 9or smoothing line).. this is supposed to give us an idea of what a "normal" change in price is, its order of magnitude

2) Take the side "opp" and compare with the average +/- 1SD (or 2, whatever)

3) interpret this as some sort of gradient / angle / area (though not necessarily for a time of X bars, we might choose a smaller distance for the Adjacent)

This is a crude way of getting a "trendiness"... for example of Gradient (m in your case robster), a flat line has gradient 0, and a straight up line has gradient infinity

You don't need to go through this agro if you use best fit method. Think about it. SD is Standard Deviation from the Mean and by it's very nature, best fit will tend towards the mean and steer away from fluctuations tending towards SD values.

Your main problem here is identifying what timeframe to work on for 'trendiness' whether you do it your suggested way, best fit, or any other method.

4) Then, either by backtesting some other method, identify which measures of our trend actually correlate with something we can recognise as a trend (say angle @ > 30 degrees or something)... we end up with a rolling angle @ over the past YY bars (given the typical move over XX bars), in order that we can input this into some simple boolean functions in an automated system - for instance, if @ < 30 degrees, define the conditions as "trendless".

30 degrees over 2 hours might end up as 20 degrees in 4hrs. The question again is timeframe and the fact that there is usually an angle of trigger and then it settles into a more consistent and shallower angle. As it comes to the top, angle further shallows, volatility normally increases at the same time and hence you should start to reduce position, probably by vol weighting it in some way, finally getting out. You should measure not just your trend acceleration but also its deceleration. All this stuff should tie in nicely with risk management.

5) I choose the +/- SD parts for a bit of a safety net - you might instead like to say that you measure the gradient / @ with a typical price "unit" of Avg + 1SD in an uptrending market, and interpret this as "if the typical unit of price change is below what we can reasonably expect given our sample data, the angle of our smoothing line is greater than or equal to our threshold, and using our parameters we define this as trending market conditions".

6) another thought I had was to collect the angle data and treat it as a mean reversion thing (which is where the acceleration comes in to play, I feel). By this I mean collecting a large sample and finding out how it is distributed - kurtosis, skew, and so on... (getting into deep water here though)

7) re: acceleration, I interpret this as nothing more than the rate of change of gradient, and have two ideas in mind

i - simple acceleration of gradient over a period of bars.. the rate of the change in the gradient over time... is it falling away? is the gradient getting steeper?

ii - gradients in series... very similar to i, but calculated slightly differently... I was thinking about comparing the gradients of three (or more) time periods going back - say from 0 - 10, 11 - 20, 21 - 30, 31 - 40... if the gradient each increases, that might be an indication of.. well, I dunno, something.

This is just correlation, similar to measuring MA's over different timeframes. You need more than 1 trend to make this work. I use 3. Ultimately though they are just confirming what's going on with the price. What you'll end up building is something that works but is quite laggy. If you're fine entering a bit late and exiting a bit late then it'll work. If you want to be on the nose, your method is flawed. It's also not very robust to choppy markets and prone to whipsaws.
 
Gann angles are entirely different as they vary depending on the scale of y-axis, making them complete bull****!

This is interesting...I think you'll find that tan theta is proportional to vol... you might be able to come up with some kind of model for skew from it...
 
Gann angles are entirely different as they vary depending on the scale of y-axis, making them complete bull****!

That's why you have to scale the chart so the "x" and "y" axes are related in proportion.
True Gann angles should not be measured by degrees on a chart unless one segment of the two(x and y axes) are both representing one unit of what is being measured.(Time and price.)
They should be measured ("1x" X "1y"), ("1x" X" 2y"), ("1x" X "y4") and so on. i.e
1 price unit = 1 time unit.
1 price unit = 2 time units.
1 price unit = 4 time units.

I will concede that this is not what MrG is looking for but please remember...
As disgusting as this is... One man's BS is another man's Bread and butter.
 
Just on a whistle-stop through this one, but regardless of the usefulness of any resultant indicator (the price itself gives enough of a visual clue, but I know what you’re really asking for Mr. G) the only real issue is one of deciding where you want your trend to be considered as starting (and finishing) or if indeed, no trend can be discerned. But even thelatter requires ‘knowledge’ of where it should be looking for start and end points. An obvious end point could be, though not necessarily the only, the last period.

As others have alluded to, the trend angle is going to be dependent upon your X and Y axis relationship, but independent of any ratio between them, it really is as simple as steeley has pointed out.

Unit of time / Units of price.

20 periods / $10 = a ‘gradient’ of 50c/period.

But I can conceive of a number of different curves that would yield that result, all with wildly different characteristics and some definitely less tradable than others. For instance, a gradual (!) $10 rise/fall over 20 periods is a statistically far more sustainable trend than no movement for the first 15 periods then a massive leap of $10 over the last 5.

The key is identifying from which point where you want to start (and stop) assessing your trend-ness.
 
Some sort of least squares method may mitigate that Tony? Thinking out loud here - my stats knowledge getting a dusting off.

It mitigates but only in the way any moving average mitigates. Tony has pretty much hit the nail on the head. Least squares is no better or worse than any other lagging indicator.

Personally I'd take a step back, and start thinking in terms of probabilities based on wave patterns and failure swings (and I dont mean waves based on ideas postulated by those charlatens elliot and gann :LOL:)

Interestingly enough MrG's original diagram shows the hypotenuse of his triangle intercepting a series of waves comprising of higher highs and higher lows, which perhaps could be incorporated into his model.

On a more practical note you could just forget about trend altogether and use momentum as a proxy
 
30 degrees over 2 hours might end up as 20 degrees in 4hrs.

Thanks for the excellent input Robster, I have earmarked the "Algorithmic trading experiences" thread as one to read over the weekend.

As per you point here, this is something I had hoped to negotiate my way around. The angle would only change if I kept the units the 'opp' side is being measured in the same... this is why I take the average over the past XX bars - scaling up or down a timeframe, I suspect, would in turn reduce the absolute size of a price "unit", therefore avoiding the situation you describe above.

As it comes to the top, angle further shallows, volatility normally increases at the same time and hence you should start to reduce position, probably by vol weighting it in some way, finally getting out. You should measure not just your trend acceleration but also its deceleration. All this stuff should tie in nicely with risk management.

This has suspected that something like this would be the case, it is encouraging to hear you found the similar results. I had considered a position size function that rose exponentially with the angle (even as crude as position size = f(sin(@)))

This is just correlation, similar to measuring MA's over different timeframes. You need more than 1 trend to make this work. I use 3. Ultimately though they are just confirming what's going on with the price. What you'll end up building is something that works but is quite laggy. If you're fine entering a bit late and exiting a bit late then it'll work. If you want to be on the nose, your method is flawed. It's also not very robust to choppy markets and prone to whipsaws.

Correlation of multiple TF's is not something I had thought about... and not quite the route I want to go down just yet. Intuitively it seems that is a step away from the price action, which we have all mentioned is really where it's at.

The least squares route is one I hadn't thought about, and is certainly worthy of further consideration, so I am grateful for the contribution. The Indicator is not intended to be used as a system in it's own right, but rather as a litmus test for the appropriacy of another system in the current market conditions (i.e. Is there a trend? If Yes, goto step 2, if not, end).
 
Top