I would like to use a more advanced Bollinger indicator, where I can show one middle band and up to 4 upper / lower bands instead of the normal 1.
Ideally this indicator will also, when applied to other indicators (rather than an instrument itself), show an option to use the indicator that is already in the target display panel, and also have customizable price markers.
It is possible to use the standard Bollinger indicator in NT7, but it is time-consuming to set up / change.
The other approach that would achieve a similar result might be a generic add-in so as to be able to show oscillator vertical scales in dual form - 1) the normal scale, and 2) normalized to the number of standard deviations from the mean (the mean ie.0 would also be shown) - then the period for calculating the mean and SD's could be something set in the add-in panel.
Anyone know of something like this - or something close ?
Need to add some plots to the original Bollinger Bands.
I am afraid that you will need to select the input series for the indicator manually when you apply it to a chart. Custumizable price markers can be coded, you would need to specify what you want to have customized.
Not clear what you mean. Any indicator can be normalized and displayed relative to a scale of standard deviations, but how do you want to display a scale in dual form. If you display two scales, you will have two indicator lines on that panel as well.
Not sure what you're looking for, but I have something similar modeled that I've been watching/modifying for the past few weeks that is 'similar' to what the OP described, although probably not exactly.
That black line in the middle is the 0 standard Deviation. Then on each side of it is the first, second and third standard deviations.
Just modeling Bollinger bands themselves is a straightforward task and plotting Deviations on either side of the mean is easy. As FT suggested, applying that to a specific indie is pretty straightforward once adding it to the chart without going through custom programming.
What I was trying to do was to plot ROC instead of scaled as a percentage, in units of Standard deviation. What I ended up doing was putting up the ROC indicator in a new panel, and then using 4 BB indicators, set to 1, 2 3 and 4 SDs, with a very long period so that the 0 line was substantially flat.
The issues I had were 1) that to change the ROC period, you have to change it in 5 places - in the ROC indicator, and AFAIK in the input series drop-down in each of the 4 BB indicators.
So through the above kludge, I have approximately what I am looking for, but it's pretty inelegant, and given I am to programming as fish are to bicycles, that is the best I am going to get unless someone has already done something similar.
If I were able to plot ROC (or any other indicator) in measures of SD, then I could if I want have 2 panels, one ROC in % and the other in SD measures, and then do the standard NT7 trick of selecting the plot in the second ROC panel and dragging it into the first, in which case the second scale will be placed on the LHS of the panel, and I can then see both plots in different colours. The other thing that can then be done if the scales are normalized in SDs is to have ROC plots in the same panel but with different periods.
@Fat Tails - what I originally had in mind was a way of selecting whether the scale is in its original units or is displayed in SDs - hence the idea of an add-in to avoid having to modify the code for every indicator. No idea whether this is even possible, but thought it worth a mention - SD scaled presentation might be useful to other people for other indicators / oscillators as well as ROC.
@ forrestang Sounds like your indicator would be a great start for my purposes - any chance of getting hold of it ? And how easy is it to add another BB ?
My indie is 'still under construction' at the moment. There are some other things going on with that with behind the scenes that I am sorting out with regards to what I want to see on the chart.
But if you just want an indicator that will plot Bollingers with the standard deviations where you input a fixed length, I can create one of those really quickly for you so that you see that on your chart.
The ROC normalizes momentum by dividing through price. As instruments have different volatility, and as percentage changes depend on the bar period selected, you will not observe any uniform behaviour for all instruments and timeframes. You are absolutely right, if you want to use volatility to normalize price action. You have the choice between the average true range - this is what I personally prefer, because it is faster to calculate - and the standard deviation.
Normalizing means to divide the indicator value by the average true range or standard deviation and then display the result as a multiple. The point here is to find an appropriate look back period. Do you want to include price action of the night session or just use volatility observed during the day session? One solution that I have often adopted is to use the average true range over the entire chart. This is fast to calculate and - more important - stable. It will not slow down the indicator for real-time performance, as the calculation can be done once per bar - first tick of bar - only.
For the standard deviation, it can also be done over the entire chart period, if a modified formula is used.
I do not genereally recommend this as an add-on, but it can be done as an add-on as well. However, the add-on will be limited to oscillators, as you need a fixed reference such as 0 (momentum, MACD) or 50 (Stochastics, RSI) for calculating the bands.
The following user says Thank You to Fat Tails for this post:
As is now, you would still have add it to the chart panel you want, apply the data series of whatever your target indicator is, and left justify it depending on how you want it displayed. And you won't have to change the period in so many different places.
The following 6 users say Thank You to forrestang for this post:
Oops - was n't watching the thread for a while .....
What you have is working nearly perfectly - I use daily charts a lot and if I have the data load set to 3650 days, and the ROC to say 10 days, if I set the period in the OverviewBB to be above about 2000 periods, the lines seem to disappear. I can survive with it as is but if it's a quick fix that would be great.
And if there were 4 BBs that would be really cool - that extra one can be useful sometimes. If it's too much effort no problem - and thanks very much for taking the time on what you have done.
@ Fat Tails
Appreciate the comments - my approach is a bit like yours - to set the SD period to the whole chart data load. The interesting thing about ROC as a % is that you see the offset and so can see the mean % increase per ROC period over the whole of the chart period.
If you want to compare ROC charts in the same panel, each with 2 different periods, by using the SD scale you can compare them more directly for variability. Horses for courses I guess. I'd not thought of using ATR for a similar purpose. You are way ahead of me Fat Tails - I was looking at using this for daily charts over 10 years for position rather than day or even swing. Going OT, I would be really interested to know how you use that type of chart - discretionary/automatic and how ? Maybe I can use what you are doing short term to help with much longer timeframes.
Something to keep in mind, the indicator needs a certain amount of data to begin calculations. Whatever 'Period' you input for the indicator, its needs a minimum of that many bars on the chart before it even begins calculating, this is there to avoid trying to calculate data based on a bar index that doesn't exist.
So that means if you input a period of 2000, you need a MINIMUM of 2001 bars on the chart before the indicator makes it's first calculation. So if you like to look at 3000 days with a 'Period' of 2000 for example, you know those FIRST 2000 bars, the indie WILL NOT perform any calculations as it needs at least that many bars to perform the bollinger calculation.
SO if you put 3650 days on your chart and set your 'Period' to 2000, you won't see any calculations for the indicator during those first 2000 bars. If you want to see the values for those bars, then you need more days loaded on your chart.
Try taking that into account and lemme know if the problem still persists. I'll add some more lines on it after you lemme know if you get things working the way you want.
The following 2 users say Thank You to forrestang for this post:
@forrestang - now tried the indicator out - works fine. Still a little confused about the short chart drawing because the standard BB indicator does n't have that behavior, but I can certainly live with it. Thanks very much and if you feel like adding a 4th band sometime that would be great
I think you probably have figured it out, but just in case.......
Well, for the 'short drawing,' think about it this way, if you were told to calculate a moving average based on 20 bars by hand, how could you calculate it if you only had 10 bars and not a full 20? You could fit an approximation in there, but your calculation WOULD NOT be an ACTUAL 20 period moving average. It would be a 10 bar moving average.
So what the study is doing, is WAITING until it has a minimum of whatever period YOU input as a PERIOD. Once it has that many bars + 1, that is when the study starts performing a calculation.
Here is the study with the 4th band added, renamed for simplicity.
The following 5 users say Thank You to forrestang for this post:
Exported using NT version 7.0.1000.27
This is a generalized version of the Bollinger Bands with a few options added:
- The midband can be selected from a moving median, a moving mode or 27 different moving averages.
- Midband and channels can …
It currently allows you to select between 12 moving averages. If you like I can make it 24.
The following 4 users say Thank You to Fat Tails for this post:
I disagree, yours has more bands, so it is not comparable. Also my indicator is quite old, I guess I will recode it, as I have made some progress in coding since. I always feel ashamed if I read what I have coded one year ago...
The following 5 users say Thank You to Fat Tails for this post:
was not aware that the indicator was available for review and download. But I do now so I will take a look. Thanks Fat.
BTW I was not aware that there where 24 types of ma to choose from. lol
I update all indicators in the download section, when I have recoded them. But I have a huge backlog now, it won't be tomorrow for the Bollinger Bands.
The following 3 users say Thank You to Fat Tails for this post:
You are always proud of your current work. The problem only occurs, if you review it a few days or months later and think "who is the stupid guy who had coded that piece of junk" - and then you discover it was yourself.
The following user says Thank You to Fat Tails for this post:
@forrestang - tested and looking good - many thanks.
I use it to catch spiky turning points - usually set the period on the 4 way BB to the same number of bars as are on the chart - working well.
@Fat Tails - if you ever fancy doing a normalized ROC indicator i.e. vertically scaled in standard deviation units, if it's really easy, then that would be a really cool addition at some point. (I would use that one as an input to the market analyzer)
Exported using NT version 7.0.1000.27
This is a generalized version of the Bollinger Bands with a few options added:
- The midband can be selected from a moving median, a moving mode or 27 different moving averages.
- Midband and channels can …
The following 6 users say Thank You to Fat Tails for this post:
The neutral color just refers to the slope of the lines. I had been annoyed by all these false slope and angle indicators, which do not correctly show momentum relative to the chart scales. I have therefore coded an indicator which shows a neutral zone (slope close to zero) across all instruments and timeframes. The steepness measured by this indicator is normalized. You can apply it to a daily chart of YM or a 1-min chart of 6E and will always get a correct result for the relative slope of the lines. Try to do that with anyone of the many angle indicators and compare the results.
The Bollinger Universal has the option to measure a neutral zone for each of the three bands, or you can set it to midbandslope. In that case it will measure the slope of the moving average, which is used as a midband.
A yellow midband means that there is no strong trend but indecision. Now when there is a squeeze, that means that the directional movement has come to a halt, so you may expect a yellow area. This is like an unstable equilibrium. The color that follows indecision will then show the direction of the short term momentum, which would be the direction to enter your trade.
The chart attached gives an example, I have set the Bollinger Universal to MidBandSlope. The indicator below is the standard Bollinger Squeeze (Bollinger Bands inside the Keltner Channels).
The following 8 users say Thank You to Fat Tails for this post:
I have not updated to V.4 yet. Do you reccomend that I do that?
I understand what you have provided and I think that will be very useful.
How am I to interpret a numerical setting for "Neutral Threshold"? A larger number creates a larger neutral colored region. I see slope as a percentage of atr but I am not sure what that means. Could you describe that for me please?
out loud on this. A bollinger band that was color coded based on the relative width between or the convergence/divergence of the bands would be a measure of short term relative volatility. That could also be used like the squeeze is to refine out periods of non-entry?
I always recommend to update to the latest version. Attention here, in case that there is a version conflict, you would need to first remove and then update all
I need to come back to the concept of slope. If you have a 10 tick move on a 5 min chart and you consider that steep, what would you consider steep on a 60 min chart? Certainly not a 10 tick move. The theoretical answer tells you that the equivalent would be close to a 10 * sqrt(12) = 35 tick move. The practical approach is to compare that move to the average bar size of the last xxx bars. The average true range just stands for average bar size.
Also it is important to understand that the slope of the moving average is a proxy for momentum. If you calculate the slope of a SMA it is the current value of the SMA minus the prior value, divided by a scale factor. The difference current value - prior value of a N-period SMA is identical with the N-period momentum divided by N. Slope therefore means N-period momentum divided by (N * scale factor).
The neutral threshold allows you to define what you consider flat. If you move that threshold up to 1000 the whole world will be flat. If you move it to zero, no slope is small enough to be considered flat. By selecting an appropriate number you can define a range for what is considered "weak momentum". This is experimental, you could for example set that value to 100.
The yellow areas cannot be described as a squeeze. Zero momentum can be created by too large moves that cancel out. A squeeze means that price has been sitting in a narrow range for some time, where narrow range is defined in terms of barsize.
The following 3 users say Thank You to Fat Tails for this post:
The squeeze compares N-bar volatility to intrabar volatility. It detects a situation where N-bar volatility is unusually low compared to intrabar volatility.
If you color code a Bollinger Band depending on the bandwidth (which is just the standard deviation), then you look at absolute levels of volatility, without comparing them to intra-bar volatility.
Low levels of absolute volatility mostly conincide with low levels of volatility relative to intra-bar volatility. A Bollinger Band indicator color coded on bandwidth would be something similar as the squeeze. If you compare the bandwidth to barsize, that is exactly the formula for the squeeze.
The following 4 users say Thank You to Fat Tails for this post:
Dear Fat,
Thank you again for your continuous contribution .... I would very much like to have your detailed "Slope Calculation" description .... As i have no programming knowledge, it is not possible to understand and interpret the code .... Please also make a reference to "neutral zone" ....
Waiting for your kind and detailed answer .... Thank you in advance.....
Best Regards
Dimitri
Slope is a geometrical concept which was used as a proxy for momentum. The geometrical slope depends on the vertical and horizontal scales used. The original idea was to look at momentum and to divide it by the number of bars (rise over run). If you use the slope of a moving average, you just need to compare the values of two consecutive bars, as the lookback period of the moving average is already taken into account.
Vertical scale value (not normalized): Price difference between the current bar's and the prior bar's value
Vertical scale value (normalized): Price difference between the current bar's and the prior bar's value divided by average bar true size over a longer lookback period
Horizontal scale value : 1 bar
A normalized formula for the slope would therefore be
I have seen concepts that use the ticksize instead of the average true range, but this is not very helpful. If you use ticksize, YM will always show steeper moves than ES, because its relative TickSize is smaller.
The indicator uses a variation of that definition of slope. Instead of the difference between current value and prior value of the MA it uses the difference between the current value and the average value of the two preceding bars. This also means that a correctional factor of 1.5 must be applied.
slope = (MA[0] - 0.5* MA[1] - 0.5* MA [2])/(average true range * 1.5)
which is a smoother version of slope. You can think of this as an artificial slope which applies to all instruments and timeframes.
The neutral threshold just measures that slope against a percentage. A value of 30 means 3%. This means that all slope value between -3% and + 3% are considered as insignificant (flat), which translates into a yellow color.
The following 3 users say Thank You to Fat Tails for this post:
Dear Fat,
Thank you for your detailed description ..... I am trying to find a solution into "calculating slope" ... the obtained results are not satisfactory ..... I will try your logic and calculations ....... I will let you know ....
Thank you again for all ....
Best Regards
Dimitri
The following 2 users say Thank You to dimitri for this post:
Thank you @Fat Tails for those great descriptions. I have a late start today and will enthusiastically focus on those posts after the coffee kicks in. On the most basic level I was looking for an improved typical squeeze type indicator with less lag that could be placed on the price field as I already have a good tenant in the sub-graph. Two sub graphs and IMO you start to queer up price action, which of course is and should always be king. I do enjoy the bpfsqueeze and the view I get from the Gaussian filter drawn histogram. I'm still trying to figure out what draws the signal/zero line though.
Be well Fat Tails and trade well.
The following 2 users say Thank You to wldman for this post:
@dimitri: My indicator is open source, you can simply copy the code and analyze it.
If you look at my definition of slope I take the vertical distance of two consecutive points of the moving average. This distance represents something like the average per bar momentum over the lookback period. I then divide that value by the average true range. This is the simple version.
The indicator basically does the same thing, but uses two prior points P1 and P0 to calculate the slope. This gets you a slightly smoother variation of slope.
The chart below shows a delta of 0.05 against an average true range of 0.134. Division gets me a slope of 37%. If the absolute amount of that slope is smaller than 3%, the moving average will be displayed as yellow if the threshold is set to 30 ‰ (which is 3%).
The following 2 users say Thank You to Fat Tails for this post:
don't mean to confuse things, and i follow the slope discussion with interest.. very interesting thought to use ATR to arrive at a "relative" slope that can be used between different instruments and still provide a usable reading..
here's my mathematical view - as i did give this a shot few weeks back before i saw the discusion on futures.io (formerly BMT) - hoping this approach may give some thoughts to fellow scripters. will try to avoid complex pure math stuff,
- we are not living in a linear world when looking at a chart of a future or stock price as it goes up & down, but rather in a relative/log-based .. where i'm more interested in a 1% decreasse or increase rather than the $$ value. while the absolute dollar value of that 1% will change depending on what the current price range is, the 1% itself remains the same. for me that means slope "rise" need to be based on percentatges change and not absolute $ value change..
calculating price change relative to ATR(length) is a very practical approach to work around things & convert rise to a relative/percentage, my worry is, ATR(length) is not a constant and will slightly change with volatility, but maybe then, i may want that factor being built into the result. just need to be aware of it.
- the MA is not a line, but a curve.. so in slope calc we need to use the "slope of a tangent of a curve" version and not the "line slope" version..
considering these 2 points in calculating slope produces an angle, and regardless of scale of chart, underlying price range, or change of ATR(length) due to price fluctuating during certain periods, the angle of slope will continue to be a usable metric.. then you can say, between +15 and -15 i'm not interested as it shows a weak move ..
i can share the script for ToS .. reason i don't use it, it was almost the same curve as the momentum study i use.. so went back to Momentum.
hope this helps add another perspective,
cheers, RedK
The following 2 users say Thank You to RedK for this post:
So @Fat Tails maybe square scaled charts would create a more perfect visual on this?
Thanks so much for the feature and for the explanation here. The preset setting of 30 represents 3% slope or something just less than 1:3 where there is 1 unit of "rise" to every 3 units of "run"?
I'm thinking that a squeeze like indicator could be created measuring the relationship between the slopes of two lines, in this case the bollinger and the keltner. Those are not totally non colinear, but I wonder if the same relationship could be viewed with value between two non colinears.
Hate to be so nerdy, but I do sit and ponder this type of thing all the time.
The following user says Thank You to wldman for this post:
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.
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,
cheers,
RedK
The following user says Thank You to RedK for this post:
Could you please provide a link to the indicator that retrieves the signals. I have no clue what it is doing.
The Bollinger Universal indicator has an additional smoothing feature. Also it allows to use different moving averages. I do not know how that other indicator calls it.
Sorry User error I somehow got median instead of SMA you would not think it makes that much difference but it does thanks for all your work on the forum.
The following user says Thank You to lblanks for this post:
@Fat Tails
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.
Rise-over-run
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.
The following 2 users say Thank You to Fat Tails for this post: