Median
Torben Median Evolved OscillatorExtending the Works of Torben Mogensen, on Torben Median
Median Filtering is an important technique !
The median filter is a non-linear digital filtering technique, often used to remove noise from an image or signal. Such noise reduction is a typical pre-processing step to improve the results of later processing (for example, edge detection on an image). Median filtering is very widely used in digital image processing because, under certain conditions, it preserves edges while removing noise (but see the discussion below), also having applications in signal processing.
Have taken two T-Medians
#1 of Length 13
#2 of Length 55
The Indicator plots the Relationship projection of Medians with the Closing Price as an Area Chart
Provision for Alerts
You get
> Green T-Median Alert
> Red T-Median Alert
Enjoy!
Torben Moving MedianThis method was pointed it out by Torben Mogensen.
It is certainly not the fastest way of finding a median, but it has the very interesting property that it does not modify the input array when looking for the median. It becomes extremely powerful when the number of elements to consider starts to be large, and copying the input array may cause enormous overheads. For read-only input sets of several hundred megabytes in size, it is the solution of choice, also because it accesses elements sequentially and not randomly. Beware that it needs to read the array several times though: a first pass is only looking for min and max values, further passes go through the array and come out with the median in little more time. The number of iterations is probably O(log(n)), although I have no demonstration of that fact.
What is Median Filtering
Median filtering is a commonly used technique in signal processing. Typically used on signals that may contain outliers skewing the usual statistical estimators, it is usually considered too expensive to be implemented in real-time or CPU-intensive applications.
Let us define the median of N numerical values by:
The median of a list of N values is found by sorting the input array in increasing order, and taking the middle value.
The median of a list of N values has the property that in the list there are as many greater as smaller values than this element.
How To trade
Trading is quite intuitive
Buy when the Price breaks-out the price which breaked the Torben Moving Median
Median CrossOver LevelsPlots levels representing the prices that the stock closed above its n-period moving median(default=100).
2 thickest lines represents the two most recent crossover levels.
Candles are colored green if the price is currently above its moving median and red if below.
Percentile Nearest Rank Using Arrays [LuxAlgo]The new array feature is extremely powerful, as it will allow pinescript users to do more complex things, or compute existing calculations more efficiently, it will also be possible to shine some light to some already existing functions, one of them being percentile_nearest_rank .
We have been working on this new feature with our pal alexgrover, and made this script which computes a rolling percentile using the nearest rank method.
Settings
Length: Window of the rolling percentile, determine the number of past data to be used.
Percentage: Return the current value if Percentage % of the data fall below that value, the setting is in a range (0,100).
Src: Input source of the indicator.
Usage
A rolling percentile can have many usages when it comes to technical analysis, this is due to its ability to return the value of three common rolling statistics, the rolling median, which can be obtained using a percentage equal to 50, the rolling maximum, obtained with a percentage equal to 100, and the rolling minimum, obtained with a percentage equal to 0.
When we use our rolling percentile as a rolling median, we can obtain a robust estimation of the underlying trend in the price, while using it as a rolling maximum/minimum can allow us to determine if the market is trending, and at which direction. The rolling maximum/minimum is a rolling statistic used to calculate the well known stochastic oscillator and Donchian channel indicator.
We can also compute rolling quartiles, which can be obtained using a percentage of 25 or 75, with one of 25 returning the lower quartile and 75 the upper quartile.
In blue the upper rolling quartile (%75), in orange the lower rolling quartile (%25), both using a window size of 100.
Details
In order to compute a rolling percentile nearest rank, we must first take the most recent length closing prices, then order them in ascending order, we then return the value of the ordered observations at index (percentage/100*length) - 1 (we use - 1 because our array index starts at 0).
MedianBandsHere I propose another simple S/R band technique, works on all TF and all securities, this is again one of the simplest forms of logic with a little tweak to tackle modern volatile markets.
It enables us to trade both mean reversion as well as breakout trades as it works in both trending and non-trending markets. You can even use pre-existing ranges as good position management markers.
It requires little to no intervention from the user. The white line is the opening price of the day, I'm a big believer of that so you will find it everywhere in my indicators. :3
Past performance is not assurance of the future performance and this is for educational purposes only.
The script will be protected to avoid theft but you can add to your favorites to use it as you please.
Enjoy~
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
Range identifier by medianThis study tries to highlight ranges
as they are defined by
TradingLatino TradingView user.
The study uses median values.
A range is defined as periods when the price does not move a lot.
Its default values are aimed at BTCUSDT pair and 4h timeframe.
HOW IT WORKS
For each of the bars a '5' median is calculated based on the 'highest of open and close'
For each of the bars a '5' median is calculated based on the 'lowest of open and close'
Thanks to the desviation setting both medians
have a tolerated maximum and a minimum
Condition 1:
The bar current 'highest of open and close'
needs to be between the respective tolerated
maximum and minimum
Condition 2:
The bar current 'lowest of open and close'
needs to be between the respective tolerated
maximum and minimum
If both conditions are met
then the bar is in a range
SETTINGS
Price range periods : How many previous periods are used to calculate the medians
Price range maximum desviation (%) ( > 0 ): Maximum positive desviation for range detection
Price range minimum desviation (%) ( > 0 ): Mininum negative desviation for range detection
Desviations should be both of them a positive number
WARNING
Despite the name indicator does not identify the entire range.
It identifies when you realise you are inside a range.
E.g. If a range length is 8 periods length this range indicator
will highlight only the last 6 periods of the range.
USAGE
If your strategy signals you an upwards trend
then you might use this range detector
to know when to exit your long position
Why?
Because most of the times
the price is found to be
in a range it goes down
FEEDBACK 1
My former attempt on calculating ranges
felt too much over complex that is why
I decided to implement it with medians.
It should be easier to modify if
I want to desviation inputs to be calculated
automatically in the future.
I'm interested on different approaches on how to detect ranges.
FEEDBACK 2
I have only used this identifier in BTCUSDT 4h timeframe.
Feel free to comment down below with your suggested settings
for your favourite pair and timeframe
PINE SCRIPT TRICK
This script simulates looping an string char by char
in pine script.
Rolling summaryStatistical methods based on mean cannot be effective all the time when attributed to financial data since it doesn't usually follow normal distribution, the data can be skewed or/and have extreme values which can be described as outliers.
In order to deal with this problem it is appropriate to use median-based techniques.
The most common one is called five-number summary/box plot, which plots median of the dataset, 25th (Q1) & 75th (Q3) percentiles (the medians of lower & upper parts of the original dataset divided by the original median), and whiskers calculated by taking range between Q1 and Q3, multiplying it by 1.5 and adding it to Q3 and subtracting it from Q1. The values which are outside the whiskers are considered outliers. Default settings of the script correspond to the classic box plot.
Seven-number summary can be also plotted by this script, by turning on 4 additional percentiles/Bowley’s seven-figure summary by turning on first 2 additional percentiles and changing their values to 10 and 90 respectively.
P.S.: Mean can be also turned in just to check the difference.
Recursive Median Filter by Jhon EhlersEN: Impulsive noise spikes or extreme price or volume data are not unusual in the financial markets and these extreme values can throw off your averaging calculations. Ehlers thinks, How can you set up a data filter to remove these extreme price movements? This Stocks & Commodities Contributing Editor shows you a way to handle this by using a filter that discards all data except the median value.
TR: Dürtüsel fiyat hareketleri, aşırı fiyatlamalar yada hacim artışları finansal piyasalarda olağan dışı değildir ve bu hareketler genelde ortalama hesaplarımızın savrulmasına sebep olur. Ehlers bu aşırı fiyat hareketliliklerinin neden olduğu ortalamalardaki bu savrulmanın nasıl kaldırıcağını düşünür ve medyan değer hariç tüm verileri silen bir filtre kullanarak bunu halletmenin bir yolunu bulur.
Recursive Median Oscillator by Jhon EhlersEN: Impulsive noise spikes or extreme price or volume data are not unusual in the financial markets and these extreme values can throw off your averaging calculations. Ehlers thinks, How can you set up a data filter to remove these extreme price movements? This Stocks & Commodities Contributing Editor shows you a way to handle this by using a filter that discards all data except the median value.
TR: Dürtüsel fiyat hareketleri, aşırı fiyatlamalar yada hacim artışları finansal piyasalarda olağan dışı değildir ve bu hareketler genelde ortalama hesaplarımızın savrulmasına sebep olur. Ehlers bu aşırı fiyat hareketliliklerinin neden olduğu ortalamalardaki bu savrulmanın nasıl kaldırıcağını düşünür ve medyan değer hariç tüm verileri silen bir filtre kullanarak bunu halletmenin bir yolunu bulur.
Moving Median Price by Atilla YurtsevenMoving Median Price is similar to Moving Average. However it uses the median instead of the mean. I believe that median is more important than the mean in some cases. Let me explain why:
There are 5 employees in a company. Their annual salary is $24,000,00. There's also a CEO of the company and his annual salary is $100,000.00. So if you calculate the mean to find the average salary using mean, you find $36,666.66. Well, nobody gets paid more than $24K but the CEO. Median helps us here. If you use median, the average salary is $24,000.00.
Keep in mind that you can use the median to find the average salary you pay per employee. You can still use mean for different purposes.
I have also added 2. Median to the script. You can enable or disable.
Disclaimer: I'm not an advisor and this script or the article is not financial advice.
Trade safe,
Atilla Yurtseven
Highs Lows (with offset) + Median with ATR bandsScript shows Highest and Lowest values (default 10) for given bars back with possible offset on time assis (default 3) with their Median Line + ATR bands around it (no offset here).
Trader Set - Moving StopThis the last tool I was working on for quite few weeks now. finally got it working. It's the only tool in my tool set that you can tweak how it looks because you can use three instances to show short length, medium length and long length trailing stops.
These trailing stops also can be used as support / resistance zones if you desire too.
Don't ask for getting access, the English version of the website and learning material is getting ready. The licenses for all of my tools will be available to purchase in the website. I will announce it in the comment sections.
If you are interested in my methodology, you can start joining my telegram channel and read more about it.
t.me
Trader Set - MTF Reversal Bar SignalsThis is Multi Tile Frame signalling of reversal bar strategy. Using this, you can easily Identify if you had a reversal bar signal in 1,2,3,4,5,10,15, and 30 minute based renko charts.
The more time frames get in sync with each other, the higher possibility for a more powerful signal.
The least you would need is for 1,2 and 3 minutes to have 2 out of 3 of them showing same signal.
Please don't ask for getting access, the licensing will be available for purchase soon in the website and I will announce it in the comment section.
Recursive Median Oscillator & Fisher Transforms RibbonThis is a composite indicator made up of:
- modifided (rescaled) version of evergets version of recursive median oscillator.
- 1996anoojpatels Futur modification of Ehlers Fisher Transform Ribbons Indicator
I think Ehlers attempts to minimise latency in indicators are extremely valuable and some of my most use trading tools. Thanks to all the authors whose iterations keep moving these indicators toward perfection. Here is my contribution.
MCI and VCI - Modified CCI FormulasFor private peeps only
- Takes a modified version of the CCI formula into 2 parts
VCI - Volume Channel Index (Yellow Histogram)
- Measures accurate accumulation and distribution levels and times
MCI - Modified Channel Index
- Measures (when compared to VCI) levels where clearly buys are interested vs not interested.
Example:
If VCI > MCI
- Shows buyer's are more than interested in buying, you've either hit a bottom or heavy resistance
if MCI > VCI
- Show's buyer's aren't interested and will most likely result in a dump/lower price
Great for monitoring accumulation and distribution, these auto buy and sells look for the transition points over 0, works on EVERY commodity/stock/FOREX/Crypto
Results are from trading 1 BTC x25 leveraging. Not all trades will get in if put in at limit, but it does survive with profits after the massive 0.075 fee (results shown are after fees)
[RESEARCH] Custom Median vs Built-in MedianI compared custom median (using the sorting solution by @apozdnyakov) with built-in median (using percentile_nearest_rank function)
If you see the zero line this means the solutions give the same results.
The best results was achieved on the odd lengths.
Conclusions:
1) Do not try to reinvent the wheel.
2) Always check the Pine Script docs to find already implemented solutions.
Ehlers Smoothed Adaptive MomentumEhlers Smoothed Adaptive Momentum script.
This indicator was developed and described by John F. Ehlers in his book "Cybernetic Analysis for Stocks and Futures" (2004, Chapter 12: Adapting to the Trend).
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.
Interquartile Range BandsInterquartile Range Bands script.
This indicator was originally developed by Alex Orekhov at his home.
The idea based on the interquartile range en.wikipedia.org
If price breaks out from the bands then it is `outlier` price.
After breakouts price always returns to its median.
Watch squeeze/expansion periods.
Anyway use it as a supplement to the other indicators.
I will glad to get your feedback.