Outliers Detector with N-Sigma Confidence Intervals (TG fork)Display outliers in either value change, volume or volume change that significantly deviate from the past.
This uses the standard deviation calculation and the n-sigmas statistical rule of significance, with 2-sigma (a value of 2) signifying that the observed value is stronger than 95% of past values, and 3-sigma 98.5% of past values, and so on for higher sigma values.
Outliers in price action or in volume can indicate a strong support for the move, and hence potentially more moves in the same direction in the future. Inversely, an insignificant move is less likely to be supported. And of course the stronger, the more support.
This indicator also doubles as a standard volume indicator if volume is selected as the source, but with the option of highlighting outliers.
Bars below significance can be uncolored (gray) to unclutter the visuals.
Differently to almost all other similar indicators, the background highlighting is dynamical, so that all values will be highlighted differently, not just 2-sigma or 3-sigma, but also 4-sigma, 5-sigma, etc, with a different value of transparency.
The dynamical transparency value can be calculated in two ways: either statically proportionally to the n-sigma but capped at 10-sigma, or either as a ratio relative to the highest observed sigma value over the defined lookback period (default: 300).
If you like this indicator, which is an extension of previously published indicators, please give some love to the original authors:
* tvjvzl :
* vnhilton :
This extension, authored by Tartigradia, extends tvjvzl's indi, implements vnhilton's idea of highlighting the background, and go further by adding dynamical background highlighting for any value of sigma, add support for volume and volume change (VolumeDiff) as inputs, add option to uncolor insignificant bars, allow plotting in both directions and more.
Outliers
Trapezoidal Weighted Moving Average and Bollinger BandsThis weighting method linearly weights a percentage of values from both the beginning and the end of the rolling window in order to minimize the effect of outliers entering and leaving the window.
Supertrend Ext1st it exactly looks like the original Supertrend indicator. But if you see the options, you can see it is totally different:
It uses my other indicator inside: Zero Lag Keltner Channels, so you can use smoothed ATR bands for calculation instead of the raw ATR. By default it's length is 1 so it works like the original Supertrend.
You can choose different sources and moving averages for Keltner Channel calculation
It can filter outliers in ATR calculation
The indicator code is in my TAExt library, so it can easily be used in custom strategies.
Trading Made Easy Pressure OscillatorAs always, this is not financial advice and use at your own risk. Trading is risky and can cost you significant sums of money if you are not careful. Make sure you always have a proper entry and exit plan that includes defining your risk before you enter a trade.
Those who have looked at my other indicators know that I am a big fan of Dr. Alexander Elder and John Carter. This is relevant to my trading style and to this indicator in general. While I understand it goes against TradingView rules generally to display other indicators while describing a new one, I need the Bollinger Bands, Bollinger Bands Width, and a secondary directional indicator to explain the full power of this indicator. In short, if this is strongly against the rules, I will edit the post as needed.
Those of you who are aware of John Carter are going to know this already, but for those who don’t, an explanation is necessary. John Carter is a relatively famous retail-turned-institutional (sort of) trader. He is the founder of TradetheMarkets, that later turned into SimplerTrading. Him and his company have a series of YouTube videos, he has made appearances on the MoneyShow, TastyTrade, and has authored a couple of books about trading. However, he is probably most famous for his “Squeeze” indicator that was originally launched on Thinkorswim and through his website but has now been incorporated into several trading platforms and even has a few open-source versions available here. In short, the Squeeze indicator looks to identify periods of consolidation and marry that with a momentum oscillator so you can position yourself in a quiet period before a large move. This in my opinion, is one of the best indicators an option trader can have, since options are priced both on time and volatility. To do this, the Squeeze identifies when the Bollinger Bands, a measure of price standard deviation, have contracted inside the Keltner Channels (a measure of the average range of a stock). This highlights something known as “the Squeeze”, when the 2x standard deviations (95% of all likely price movement using data from the past 20 periods) is less than the 1.5x average true range (ATR) of the stock over the same number of periods. These periods are when a stock is resting and in a period of consolidation and is generally followed by another large move once it has rested long enough. The momentum oscillator is used to determine the direction of this next move.
While I think this is one of the best indicators ever made, it is not without its pitfalls. I find that the “Squeeze” periods sometimes take too long to setup (something that was addressed by John and released in a new indicator, the Squeeze Pro, but even that is still slowish) and that the momentum oscillator was also a bit slow. They used a linear regression formula to track momentum, which can lag considerably at times. Collectively, this meant that getting into moves a few candles late was not uncommon or someone solely trading squeeze setups could have missed very good trade opportunities.
To improve on this, I present, the Trading Made Easy Pressure Oscillator. This more accurately identifies when volatility is reducing and the trading range is likely to contract, increasing the “pressure” on the price. This is often marked several candles before a “Squeeze” has started. To identify these ranges, I applied a 21-period exponential moving average to the Bollinger Bands Width indicator (BBW). As mentioned above, the Bollinger Bands measure the 2x standard deviation of price, typically based on a 20-period SMA. When the BBs expand, it marks periods of high volatility, when they contract, conversely, periods of low volatility. Therefore, applying an EMA to the BBW indicator allows us to confidently mark when volatility has slowed down earlier than traditional methods. The second improvement I made was using the Absolute Price oscillator instead of a linear regression-style oscillator. The APO is very similar to a MACD, it measures the difference between two exponential moving averages, here the 8 and 21 (Fibonacci EMAs). However, I find the APO to be smoother than the MACD, yet more reactive than the linear regression-style oscillators to get you into moves earlier.
Uses:
1) Buying before a bigger than expected move. This is especially relevant for options traders since theta decay will often eat away much of our profits while we wait for a large enough price move to offset the time decay. Here, we buy a call option/shares when the momentum oscillator matches the longer-term trend (i.e. the APO crosses over the zero line when price is above the 200-day EMA, and vice versa for puts/shorting the stock). This coincides with Dr. Elder’s Triple Screen Trading System, that we are aligning ourselves with the path of least resistance. We want to do this when price is currently in an increasing pressure situation (i.e. volatility is contracting) to make sure we are buying an option when premium and Implied Volatility is low so we can get a better price and have a better risk to reward ratio. Low volatility is denoted by a purple dot, high volatility a blue dot along the midline of the indicator. A scalper or short-term swing trader may look to exit when the blue dots turn purple signalling a likely end to a move. A longer-term trend trader can look to other exit scenarios, such as a cross of the oscillator below the zero line, signalling to go short, or using a moving average as a trailing stop.
2) Sell premium after a larger than expected move has finished. After a larger than expected move has completed (a series of blue dots is followed by a purple dot), use this time to sell theta-driven options strategies such as straddles, strangles, iron condors, calendar spreads, or iron butterflies, anything that benefits from contracting volatility and stagnating prices. This is useful here since reducing volatility typically means a contraction of prices and the reduced likelihood of a move outside of the normal range.
3) Divergences. This indicator is sensitive enough to highlight divergences. I personally don’t use it as such as I prefer to trend trade vs. reversion trade. Use at your own risk, but they are there.
In summary, this indicator improves upon the famous Squeeze indicator by increasing the speed at which periods of consolidation are marked and trend identification. I hope you enjoy it.
DataCleanerLibrary "DataCleaner"
Functions for acquiring outlier levels and acquiring a cleaned version of a series.
outlierLevel(src, len, level) Gets the (standard deviation) outlier level for a given series.
Parameters:
src : The series to average and add a multiple of the standard deviation to.
len : The The number of bars to measure.
level : The positive or negative multiple of the standard deviation to apply to the average. A positive number will be the upper boundary and a negative number will be the lower boundary.
Returns: The average of the series plus the multiple of the standard deviation.
cleanUsing(src, result, len, maxDeviation) Returns an array representing the result series with (outliers provided by the source) removed.
Parameters:
src : The source series to read from.
result : The result series.
len : The maximum size of the resultant array.
maxDeviation : The positive or negative multiple of the standard deviation to apply to the average. A positive number will be the upper boundary and a negative number will be the lower boundary.
Returns: An array containing the cleaned series.
clean(src, len, maxDeviation) Returns an array representing the source series with outliers removed.
Parameters:
src : The source series to read from.
len : The maximum size of the resultant array.
maxDeviation : The positive or negative multiple of the standard deviation to apply to the average. A positive number will be the upper boundary and a negative number will be the lower boundary.
Returns: An array containing the cleaned series.
outlierLevelAdjusted(src, level, len, maxDeviation) Gets the (standard deviation) outlier level for a given series after a single pass of removing any outliers.
Parameters:
src : The series to average and add a multiple of the standard deviation to.
level : The positive or negative multiple of the standard deviation to apply to the average. A positive number will be the upper boundary and a negative number will be the lower boundary.
len : The The number of bars to measure.
maxDeviation : The optional standard deviation level to use when cleaning the series. The default is the value of the provided level.
Returns: The average of the series plus the multiple of the standard deviation.
Outlier Detector with N-Sigma Confidence IntervalsA detrended series that oscilates around zero is obtained after first differencing a time series (i.e. subtracting the closing price for a candle from the one immediately before, for example). Hypothetically, assuming that every detrended closing price is independent of each other (what might not be true!), these values will follow a normal distribution with mean zero and unknown variance sigma squared (assuming equal variance, what is also probably not true as volatility changes over time for different pairs). After studentizing, they follow a Student's t-distribution, but as the sample size increases (back periods > 30, at least), they follow a standard normal distribution.
This script was developed for personal use and the idea is spotting candles that are at least 99% bigger than average (using N = 3) as they will cross the upper and lower confidence interval limits. N = 2 would roughly provide a 95% confidence interval.
ATR Without OutliersIt is an ATR indicator which filters out outliers.
Outliers are values which are higher than the standard deviation of the true range.
It may be better than normal ATR for stop loss, because it does not keep large values after pump or dump.
It is very useful for high volatile markets like crypto markets.
Zero Lag Keltner ChannelsThis is Keltner Channelz (KC) with Zero Lag Moving Average (ZLMA as base). It is smoother and has less lag than the original (EMA/SMA) variant.
It also can be used as a trend indicator and trend confirmation indicator. The upper and lower bands are green if it is an up trend, and red if a down trend. If both have the same color it is a stronger trend.
[RS]Function - Minkowski_distancecopy pasted description..
Minkowski distance is a metric in a normed vector space. Minkowski distance is used for distance similarity of vector. Given two or more vectors, find distance similarity of these vectors.
Filtered ATRThis script defines an average true range where extreme events are filtered out.
Extreme events are those bars with a true range larger than 3*sigma+average,
where average and standard deviation are estimated from the last 200 bars.
In this way the ATR is not altered by exceptional events (e.g. the flash crash of Jan 3rd 2019)
and can still be used safely for Stop Losses and Take Profits.
Hitting the like button is a free sign of gratitude, thanks.
Hampel FilterHampel Filter script.
This indicator was originally developed by Frank Rudolf Hampel (Journal of the American Statistical Association, 69, 382–393, 1974: The influence curve and its role in robust estimation).
The Hampel filter is a simple but effective filter to find outliers and to remove them from data. It performs better than a median filter.