Spread by//Every spread & central tendency measure in 1 script with comfortable visualization, including scrips's status line.
Spread measures:
- Standard deviation (for most cases);
- Average deviation (if there are extreme values);
- GstDev - Geometric Standard Deviation (exclusively for Geometric Mean);
- HstDev - Harmonic Deviation (exclusively for Harmonic Mean).
These modified functions will calculate everything right, they will take source, length, AND basis of your choice, unlike the ones from TW.
Central tendency measures:
- Mean (if everything's cool & equal);
- Median (values clustering towards low/high part of the rolling window);
- Trimean (3/more distinguishable clusters of data);
- Midhinhe (2 distinguishable clusters of data);
- Geometric Mean ( |low.. ... ... .. .... ... . . . . . . . . . . . .high| this kinda data); <- Exp law
- Harmonic Mean { |low. . . . . . . . . . . . . . .. . . .high| kinda data). <- Reciprocal law
Listen:
1) Don't hesitate using Standard Deviation with non-mean, like "Midhinge Standard Devition", despite what ol' stats gurus gonna say, it works when it's appropriate;
2) Don't check log space while using Geometric Mean & Geometric Standard Deviation, these 2 implement log stuff by design, I mean unless u wanna make it double xd
3) You can use this script, modify it how you want, ask me questions whatever, just make money using it;
4) Use Midrange & Midpoints in tandem when data follows ~addition law (like this . . . . . . . . . . . . . . . . . . . . .). <- just addition law
Look at the data, choose spread measure first, then choose central tendency measure, not vice versa.
!!!
Ain't gonna place ® sign on standard deviations like one B guy did in 1980s lmao, but if your wanna use Harmonic Deviations in science/write about/cite it/whatever, pls give me a lil credit at least, I've never seen it anywhere and unfortunately had to develop it by myself. it's useful when your data develops by reciprocals law (opposite to exponential).
Peace TW
Mean
Harmonic MADsNo, it's not a new saturation plugin for your fruity loops.
...
These are Mean Average Deviations calculated from Harmonic Mean.
...
In my previous research I tried to develop "Harmonic Average Deviations", since applying stdevs on Harmonic Mean calculated from reciprocals ain't make sense. Din't work out, prolly cuz by definition stdevs doesn't like negatives. So in the end I ended up using Mean Average Deviations, and turned out it works great. Generally market data doesn't distribute normally, so t's a great tool, now weird kurtosis won't be a problem.
[R&D] Harmonic deviationsI'm publishing it for research purposes & welcome any ideas and/or explanations whether it's actually possible or nah to do what I'm doing right now.
...
Idea is simple - if we can do Harmonic Mean, can we do Harmonic Standard Deviations? It should be the same logic, the only difference is instead of actual datapoints we gotta use reciprocals.
In reality I've found smth really curios, it's possible to get these Harmonic Standard Deviations, however, somewhy, depends on your timeframe, u gotta do final sqrt different amount of times. And looks like... the market reacts to these levels.
That's why in the script settings there is a menu where you can choose how many times to perform sqrt operation.
Pls check it out, play with it, see maybe you'll see smth interesting.
Harmonic Moving AverageI was legitimately surprised no1 has already coded it out on TradingView, but you guys can copypaste & include it in Pine 5 if your see this xd
Here is it.
I've checked and double checked everything, the calculations are right, it can be proved by plotting mean, geometric mean & harmonic mean together and noticing that geometric mean will be always between Harmonic mean, which is always below, and Mean, which is always above.
...
Other central tendency measures are also here as well for usability.
Ehlers Zero Mean Roofing Filter [CC]The Zero Mean Roofing Filter was created by John Ehlers (Cycle Analytics For Traders pg 80) and this is a much more reactive roofing filter compared to Ehler's Roofing Filter which I also added for reference. Buy when the indicator rises over 0 and sell when the indicator falls below 0.
This was a special request so let me know if there are other indicators you would like to see me publish or if you want something custom done!
Time Range StatisticsA good amount of users requested a text box showing various price statistics, the following script returns various of these stats in a user-selected range, and include classical ones such as a central tendency measurement (mean), dispersion (normalized range) and percent change, but also include less common statistics such as average traded volume and number of gaps. The script also calculates the correlation between the closing price and another user-selected instrument.
The script is currently the longest one I ever made and took some efforts, as I wasn't satisfied with the statistics to be originally included. Big thx to Gael for the enormous feedback and the idea of the normalized range, to user @Cookiecrush for the feedback ( without ya I would have posted something bad you know umu ? ), and Lulidolce for the support, friendship is magic!
Selected Range
The setting Start determine the bar at which the range starts, while End determine at which bar the range end. To help you select these values, the current bar number (bar index) is displayed at the right of the indicator title in blue.
The setting evaluate to last bar will use a range starting at Start and ending at the last bar, as such you can use a full range by using Start = 0 and select evaluate to last bar
The range is highlighted by an area on the chart. By default Start = 9000 and End = 10000, you might not have this amount of data in your chart, as such use the displayed bar index to select Start and End, then set the settings as default.
Displayed Statistics
The statistics panel is displayed on the right side of the last bar, the panel has 3 sections, a title section who shows the symbol ticker, timeframe, and overall trends represented by a chart emoji, the overall trends are determined by comparing the number of higher highs with the number of lower low.
Below are displayed the date ranges with time format: year/month/day/hour:minute.
The second section shows the general statistics. The first one is the mean, also represented by the orange line in the chart, the blue line displayed represent the highest price value in the range, while the red one represents the lowest price value.
The second stat is the normalized range, and determine how spread is the price in the user-selected range, why not the standard deviation? Because the standard deviation might return results varying widely depending on the scale of the closing price, you could get measures such as 0.0156 or 16 or even 56 depending on the instrument, as such using a normalized range can be more appropriate as it lays in a range of (0,1). Lower values indicate a low degree of price variation. Note that I still want to find another measure in the future.
The percentage change (or relative change) indicates at which percentage the price has increased or decreased, and is calculated by subtracting the closing at bar Start with the price at bar End , divided by the price at bar End , the result is then multiplied by 100.
The average traded volume calculate the mean of the volume in the selected range, I used the same format used by the original volume indicator for clarity.
Finally, the last stats of the section is the number of gaps, this stat is by default hidden. An up gap is detected when the open price is superior to the previous high, while a down gap is detected when the open price is inferior to the previous low, this allow to only retain significant gaps.
The last section of the indicator panel shows the correlation between the closing price and another instrument, by default GOOG, this correlation is also calculated within the user-selected range. Positive values indicate a positive relationship, that is the two instruments tend to move in the same direction. Negative values indicate a negative relationship, both instruments tend to move in a direction opposite to each other. Values closer to 1 or -1 indicate a stronger relationship, while values closer to 0 indicate no relationship.
In Summary
The script shows various stats, each calculated within a user-selected range, in general one would be more interested in how these stats might evolve with time, but checking them in a custom range can be quite interesting.
Thx for reading. umu
Rolling deviationsSometimes the market data follows normal distribution, in these cases it is more appropriate to utilize mean-based statistical techniques. This script plots the special case of seven-number summary with 1st, 2nd & 3rd standard deviations below and above the mean.
It also has "Log-space" switch which should be checked while using logarithmic scale.
The next version with minor visual improvs might arrive soon
Range StrengthRange Strength is a super simple indicator designed for the mean reversion (range trading) strategy, it shows you how strong the market is ranging or trending. When the indicator is positive (green color) the market is a range mode, when the indicator is negative (red color) it is in a trending mode.
It's best used together with our Buy Sell Bands indicator to identify entry and exit signals within the range, ideally only taking trades when the Range Strength indicator is showing positive (green) readings.
How Is It Different From Other Indicators?
- Designed specifically for the mean reversion (range trading) strategy
- Shows one simple reading and graphical representation of range strength
- Identify the best times to take mean reversion trades versus trend trades
- Works well in conjunction with the Buy Sell Bands indicator to validate entry & exit signals
- Can be applied to all markets and timeframes
How To Use The Indicator?
1) Visit our website URL shown below this description and signup
2) We will then grant your TradingView username permission to use our indicators
3) Go to your Indicators window, then the Invite-Only section and add our indicators to your chart
4) Our indicators will then show on every chart you now look at
5) You can set up alerts to be notified in real time of trading signals from our indicators
6) Read our user manual for all the best tips on how to use our indicators as part of a range trading strategy
7) Feel free to reach out to us for personal one-on-one help with getting setup
What Markets and Conditions Does It Work Best On?
All markets cycle between trending and ranging modes, and the key to successfully using our indicators is identifying when the market is in or about to go into a range trading mode, and as such it can be applied to all markets and timeframes.
Some markets and timeframes trade within ranges more predictably than others, for example Forex, Cryptocurrencies, and Futures on the 15 minute timeframe during the US night session can work well due to the lack of price sensitive news creating lasting trends. With Stocks & ETFs on the 5 minute timeframe during the midday session on large cap blue chip stocks with no recent news releases can show strong range trading environments to use our indicators in.
In addition to single markets, you can also use our indicators on pair charts, for example Coca Cola(KO) versus Pepsi(PEP), you can do this by entering KO/PEP inside your TradingView chart quote box and it will bring up a pair chart. Our indicators will show buy and sell signals right on the pair chart just like any other single instrument chart. You can get very creative with what type of pairs you can come up with.
Our indicators are primarily designed for day trading and swing trading, however they can also be used for position trading and investing by identifying technically oversold and overbought range levels that are based on current and past volatility around a dynamic average price, for this we recommend using a weekly chart to identify longer trading opportunities.
As always indicators should be used as part of a trading strategy to assist in making decisions, you can't just blindly follow every signal they produce, you should always seek to compliment technical trading signals with additional analysis to reduce your risk and increase your odds of making a winning trade.
Examples Of Use On Various Markets and Timeframes
GBP vs CHF Forex Pair 15 Minute Chart
Tesla Stock 1 Minute Chart
Bitcoin vs USD Crypto Pair 15 Minute Chart
Micro E-Mini SP500 Futures 1 Minute Chart
Mastercard vs Visa Stock Daily Pair Chart
To gain access to the Range Strength and Buy Sell Bands Indicators visit our website shown below.
Happy Range Trading :)
Buy Sell BandsBuy Sell Bands is a super simple indicator based on the mean reversion (range trading) strategy that shows you exactly where to buy, sell and close trades on every chart, market and timeframe.
It's best used together with our Range Strength indicator to identify when the market is in a range mode, this is the best time to take the entry signals from the Buy Sell Bands.
How Is It Different From Other Indicators?
- Designed specifically for the mean reversion (range trading) strategy
- Upper and lower bands are based on current and past volatility
- Aren't as sensitive to "squeezes" after periods of contracted volatility
- Works well in conjunction with the Range Strength Indicator to confirm entry signals
- Helps identify good "pair trading" opportunities
- Can be applied to all markets and timeframes
How To Use The Indicator?
1) Visit our website URL shown below this description and signup
2) We will then grant your TradingView username permission to use our indicators
3) Go to your Indicators window, then the Invite-Only section and add our indicators to your chart
4) Our indicators will then show on every chart you now look at
5) You can set up alerts to be notified in real time of trading signals from our indicators
6) Read our user manual for all the best tips on how to use our indicators as part of a range trading strategy
7) Feel free to reach out to us for personal one-on-one help with getting setup
What Markets and Conditions Does It Work Best On?
All markets cycle between trending and ranging modes, and the key to successfully using these indicators is identifying when the market is in or about to go into a range trading mode, and as such it can be applied to all markets and timeframes.
Some markets and timeframes trade within ranges more predictably than others, for example Forex, Cryptocurrencies, and Futures on the 15 minute timeframe during the US night session can work well due to the lack of price sensitive news creating lasting trends. With Stocks & ETFs on the 5 minute timeframe during the midday session on large cap blue chip stocks with no recent news releases can show strong range trading environments to use our indicators in.
In addition to single markets, you can also use our indicators on pair charts, for example Coca Cola(KO) versus Pepsi(PEP), you can do this by entering KO/PEP inside your TradingView chart quote box and it will bring up a pair chart. Our indicators will show buy and sell signals right on the pair chart just like any other single instrument chart. You can get very creative with what type of pairs you can come up with.
Our indicators are primarily designed for day trading and swing trading, however they can also be used for position trading and investing by identifying technically oversold and overbought range levels that are based on current and past volatility around a dynamic average price, for this we recommend using a weekly chart to identify longer trading opportunities.
As always indicators should be used as part of a trading strategy to assist in making decisions, instead of just blindly following every signal they produce you should always seek to compliment technical trading signals with additional analysis to reduce your risk and increase your odds of making a winning trade.
Examples Of Use On Various Markets and Timeframes
GBP vs CHF Forex Pair 15 Minute Chart
Tesla Stock 1 Minute Chart
Bitcoin vs USD Crypto Pair 15 Minute Chart
Micro E-Mini SP500 Futures 1 Minute Chart
Mastercard vs Visa Stock Daily Pair Chart
To gain access to the Buy Sell Bands and Range Strength Indicators visit our website shown below.
Happy Range Trading :)
Bars above/below EMACount of previous bars above or below a chosen Exponential Moving Average. Typically price reconnects with well defined EMAs regularly. If the price has been above/below an EMA for too long, you can expect a reconnect in a short order and bet on mean reversion strategies.
Mean Absolute Deviation BandsThe other way to build bands around price that uses Mean Absolute Deviation instead of Standard Deviation.
MAD is also a measure of variability, but less frequently used. MAD is better for use with distributions other than the Gaussian.
MAD is always less than or equal to Standard Deviation and the resulting bands are more tighter for the same parameters if we compare it to Bollinger Bands.
If you use band stops this can be useful.
London Breakout with MDX Trailing StopThis indicator aims to aid in using the regular London Breakout strategy, as well as improve on it by adding a trailing stop based on the Mean Deviation Index.
The London Breakout strategy (according to my personal understanding) basically sees the morning before London open as the accumulation or distribution range for large buyers or sellers, and assumes the market will break either above that mornings high or below that mornings low when they start to move price. It is mostly used to trade stock indices and forex.
This indicator plots the morning high and low for each day. The green line is the morning high, and the red line is the morning low. If price moves above the green line (the morning high) it fills that area with a green color. If price moves below the green line (the morning low) it fills that area with a red color. This makes the breakouts easy to spot.
The background color of the chart turns green when the MDX is above 0 (price is more than X times ATR above the mean) and a breakout above the morning high has occurred, and stays green until the opposite happens.
The background color of the chart turns red when the MDX is below 0 (price is more than X times ATR below the mean) and a breakout above the morning high has occurred, and stays green until the opposite happens.
The default for X above is 1.0, but this can be changed in the settings by changing "ATR Multiplier".
The background is always neutral during the morning session since the morning high and morning low are not established yet.
A trailing stop is shown when price is more than X times away from the mean and a breakout has occured. The distance is set using the MDX. The trailing stop uses a separate ATR multiplier though, to make the signal and trailing stop MDX values different, if one likes. The default ATR multiplier for the trailing stop is 1.25, but this can be changed is the settings by changing "ATR multiplier for trailing stop".
When the high or low of a candle breaks the trailing stop, it is moved further away, indicating you have been stopped out, but gives opportunity to use it if you enter again (so it doesn't just disappear).
As an added bonus, take profit levels have been added based on the mornnig range. The take profit distance is set by multiplying the range with a factor. The levels are then plotted that distance from the morning high and morning low.
MDX:
Mean Deviation IndexThe Mean Deviation Index (MDX) is used to see how much price is deviating from the mean. This indicator takes both volatility and mean deviation in consideration.
It uses the standard deviation of the ATR to filter an EMA, and uses this as the mean. It then only plots > or < 0 if price is more than one x ATR away from the mean. If index is positive, the background turns green, meaning price is more than 1 x ATR above the mean. If the index is negative, the background turns red, meaning price is more than 1 x ATR below the mean. This setting can be changed by changing the setting "ATR Multiplier", but the default is 1 x ATR.
There are two main ways to use this index.
1. Use it aggressively to find trends (by combining it with other indicators) by entereding each time the background changes color to green for longs or red for shorts.
2. Use it spot breakouts, waiting for a pullback, and then entering on the next move in the same direction. In this context for a short, you wait for the background color to turn green, then wait for the index to pull back, and then enter once it starts moving up again.
Mean Street V1script for mean reversion conditions - tweak-able based on the volatility of the asset its used on, and the time frame
Forecasting - Simple Mean MethodThis is a continuation of my series on forecasting techniques. The idea behind the Simple Mean method is to somehow extend historical mean to the future. In this case a forecast equals to last value plus average change.
Mean Reversion IndicatorThis is a mean reversion indicator that anticipates a local trend reversion. Basically, it is a channel with the mid-line serving as a moving mean baseline. Each of the two curves run up and down within this channel bouncing off from the top and bottom bounds. Touching the bounds serves as an indication of a local trend reversal. The reversal signal is stronger when there exists a resonance (symmetry) in the two curves. The background histogram shows a Karobein oscillator that contributes support or resistance for the signal.
Return to the Mean OscillatorThe Return to the Mean Oscillator shows the spread between the selected mean study and the actual close in price.
In this first version, I'm including the All-Time Historical Mean, which is the evolution of the mean value of that asset since its inception.
By using this indicator we are able to see if a particular market is trading above/below historical mean value.
The Mean value equals zero in the oscillator scale.
Therefore, we can use this indicator to clearly identify 'Return to the Mean' moves.
Note: Tradingview limits the number of candles we can use on each time frame.
Depending on the deepness of historical data, it is possible that the mean value could miss old data and therefore plot different levels for each timeframe.
That is especially true for markets with a long history or when we calculate it for intraday time frames.
In case of doubt, refer to the mean value at higher time frames.
Return to the MeanThe Return to the Mean plots reference values that price action tends to revisit each cycle.
In this first version, I'm including the All-Time Historical Mean, which is the evolution of the mean value of that asset since its inception.
By using this indicator we are able to see if a particular market is trading above/below historical mean value.
Moreover, we can use this indicator to anticipate powerful 'Return to the Mean' moves.
In addition to the All-Time Historical Mean, I'm planning to add alternative 'return to the mean' studies to this indicator.
Note: Tradingview limits the number of candles we can use on each time frame.
Depending on the deepness of historical data, it is possible that the mean value could miss old data and therefore plot different levels for each timeframe.
That is especially true for markets with long history or when we calculate it for intraday time frames.
In case of doubt, refer to the mean value at higher time frames.
Escape VelocityThis script is meant to calculate the Escape Velocity from the mean. According to Investopedia "Mean reversion is theory used in finance that suggests that asset prices and historical returns eventually return back to the long-run mean or average level of the entire data set."
Escape Velocity is the lowest velocity which a body must have in order to escape the gravitational attraction of a particular planet or other object, in this case the mean. It is recommended that you use a moving average with the same length as the ones that you decide to use for this indicator.
Escape Velocity= sqrt((2*Gravitational Constant * Mass)/Distance from the mean)
The Escape Velocity is in red and the velocity of price is in green. When price velocity (green) is positive and greater and than escape velocity (red) and price is above the mean, this would indicate that price is breaking away from the mean (bullish). When price velocity is negative and less than escape velocity and price is below the mean, this would indicate that price is breaking away from the mean (bearish).
Seasonality-Buschi
English:
This script shows the price development over the last year (default: green) and mean prices over the last three (default: light green), six (default: orange) and nine (default: red) years and is therefore at least some kind of approach towards true seasonality.
Thanks to user "apozdnyakov" for providing most of the code!
Deutsch:
Dieses Skript zeigt den Kursverlauf über das letzte Jahr (Standard: grün) und die durchschnittlichen Verläufe über die letzten drei (Standard: hellgrün), sechs (Standard: orange) und neun (Standard: rot) Jahre und stellt damit zumindest eine Annäherung zu einer echten Saisonalität dar.
Dank an User "apozdnyakov", der den Großteil des Codes zur Verfügung gestellt hat!
TRI Mean OscillatorThe Mean Oscillator shows the spread between the historical mean and the actual close price.
By using this indicator we are able to see if a particular market is trading above/below historical mean value.
The Mean value equals zero in the oscillator scale.
Therefore, we can use this indicator to clearly identify 'Return to the Mean' moves.
Note: Tradingview limits the number of candles we can use in each time frame.
It is possible that the mean value could miss old data.
That is especially true for markets with a long history or when we calculate it for intraday time frames.
Credit for this idea goes to Brian Beamish www.therationalinvestor.com
TRI Mean MachineThe Mean Machine plots the evolution of the mean value of that asset since its inception.
By using this indicator we are able to see if a particular market is trading above/below historical mean value.
Moreover, we can use this indicator to anticipate powerful 'Return to the Mean' moves.
Note: Tradingview limits the number of candles we can use on each time frame.
It is possible that the mean value could miss old data.
That is specially true for markets with long history or when we calculate it for intraday time frames.
Credit for this idea goes to Brian Beamish www.therationalinvestor.com