The distinction that interests me is the relationship between two non co-linears, perhaps relative to price. I'n that context I'd seek a pattern that can be anticipated or duplicated. So unlike MACD where the "CD" is between two MA's, this idea would look at the relationship between say volatility and volume, or between two timeframes, and then be overlaid on price.
Not to digress too much but I think the situational evaluation for the trade entry/exit metric should be based on relationships between readings, not just readings. In that, I think, you gain some insight especially in determining the risk/reward of a potential entry.
Last edited by wldman; September 15th, 2012 at 09:44 AM.
Reason: add time frame
The relative/ log-based approach is necessary for longer timeframes. As long as you apply indicators to intraday charts the linear approximation is good enough. I do not use logarithmic scales on an intraday chart, but would definitely use it on a monthly chart.
When trading stocks the absolute percentage reflects the amount invested and is proportional to the downside risk. When trading futures you would use leverage to adjust your position to the volatility of the underlying. In this case it is better to adjust slope to volatility.
In the end when coloring an indicator, what I really want to achieve is to get alerted to a situation where price moves sideways. If I was to use a correct mathematical approach I would calculate all deltas of the moving average over a lookback period of a year, then show the (near-Gaussian) distribution of those slopes and just take out 5 percentiles ot each side of the zero-slope and consider this as flat. This is because I do not use slope as proxy for value but for a sideways market condition.
Thank you for pointing to this problem. Originally I had used an approach which calculates an average true range over the entire chart period. In that case the value is less arbitrary and less fluctuating than the ATR(20), which I have used in this indicator. The only problem with the ATR is that it evolves slowly, and that the final values will then depend on the lookback period of the chart. I know that ATR(20) is not a perfect solution, but that some improvement is possible here.
One problem is that with intraday charts volatility is low prior to the session start, so the ATR(20) used for the first bar of the session is not really relevant. What I should do is either
-> calculate the average true range over 5 consecutive trading days
-> or produce an estimation of the average true range by calculating it from the daily range
The second option is not so difficult. I would load the last year of daily data, then calculate the average range per day, and then divide it by the square root of the average number of bars per day. For example, if I have a 5 minute chart of ES, then the number of bars per day are 267(Monday), 279(other days), which results in an average of 276.6 bars, I would therefore divide the average daily range by sqrt(276.6) = 16.63 to obtain my normalization factor for slope.
If I was to use an adaptive approach - as I do now for simplicity's sake - I would rather opt for using implicit volatility than historical volatility. Implicit volatility could be calculated by studying intraday seasonality and use a volatility function calculated from the DayOfWeek/TimeOfDay.
A tangent is only available for continuous functions. Approximating a tangent with a secant is not a crime.
Does your script also achieve the prupose for which I have produced the code that is
-> to produce a practical solution for ALL instruments and ALL timeframes to identify the middle percentiels in the distribution of slope,
-> if it achieves the purpose the yellow (neutral) zones should be as frequent on a daily chart of YM as they are on a 1-minute chart of EURUSD ?
@FatTails, i don't think it does or it attempts to come close to what you're doing.. it is a very basic calc of slope that i worked on for a while.. with focus on stocks, and i would rarely look at 1min or 5min charts ..
i was just sharing how I approached the methematica problem of calculating slope on a price chart.. and the key 2 thoughts i had to work around.. your approach is mouch more comprehensive and i admire the amount of effort you put into it.. this is really valuable to all of us,
The following user says Thank You to RedK for this post:
Dear Fat, using your logical approach to calculate the slope .... we can go on, by using Trigonometry ....
So we can now "calculate the X axis" (which in charts is "time series") .... using the "slope value" and the "Delta (which is the Y axis or price...)". Now by using the Tangent formula = X/Y or X=Tan*Y ....
Having now the "new conventional value" of X, we can start a very serious research with this value ....
At this point, i have to declare that i am using Metastock and i am not a programmer ... Manually (it is very hard ....with all PC's and technology around ...) i have tried to see how the "X" value is performing in following logic ....
It seems to have an interesting result ....
The Logic is : Starting from a ZERO point which can be a Highest High or a Lowest Low .... we add the "X" with the "X of previous bar" ... when it is applied ....
If anybody can spend his precious time to code it and show the chart results ..... (as explained i have no any programming skill ...) it will be very very much appreciated ...
Any geometrical approach will not help you but lead you directly to a bunch of problems. Let me repeat the basics.
Slope is a visual proxy for momentum, which works if scales are invariant and if you use it for a single time frame. When chart books for daily charts were printed, with always the same horizontal scale and the same vertical scale, this was possible.
We are not interested in slope, but we are interested in the relative change of the value of the moving average between two consecutive bars.
"steep" means that it is changing faster than usual
"flat" means that it is not changing or that the changes are very small compared to average change
Steepness on a 5 minute chart is not the same as steepness on a 60 min chart. On a 60 min chart the change of the MA value should be sqrt(12) times larger than on a 5 min chart. This means that we need to take into account the timeframe of the chart, if we wish to continue to use the concept of steep and flat. Taking into account the timeframe is achieved by comparing the change in the values of the MA to the average bar size. If the change is a full bar, it is very steep. If it is a small fraction of that bar it is flat.
The concept of "rise-over-run" replaces the geometrical concept of the slope. Rise-over-run is the change of a linear regression slope or a moving average over 1 bar. Rise-over-run is not normalized over instruments and timeframes, so with similar settings rise-over-run will not identify flat periods. Normalization can be achieved
- via dividing by average volatility
- by populating a large array with all available MA differences over the chart lookback period and calculating percentiles (this is similar to the approach for market profile)
You cannot achieve this with any trigonometric approach.
Last edited by Fat Tails; September 17th, 2012 at 03:13 PM.
The following 2 users say Thank You to Fat Tails for this post: