Daily SeasonalityDay trading trend filter indicator designed to hep get better entries or exits based on historical opens and closes each hour.
This indicator is NOT designed as an entry or exit signal. The purpose behind it is to give you statistical information about how likely certain times of day are either bullish , bearish or neutral and use that to confirm or reject other trading signals.
For example you might be anticipating a breakout based on your strategy or another indicator but see that the next few days are usually bearish and re-evaluate entering the trade.
The Daily Seasonality indicator calculates the percentage of candles per day of the week that had a higher close than open.
Default settings are:
- a look-back of 52 weeks (1 year).
- extreme bullish ( bright green) above 74%
-extreme bearish ( bright red) below 25%
- bullish (green) above 55%
- bearish (red) below 45%
- neutral (white) exactly 50%
- no trend (gray) 46% - 54%
All of these are updatable via the settings.
This indicator is designed to work only on the Daily timeframe.
Filter
{Gunzo} Vertical Horizontal Filter (Trading ranges)Vertical Horizontal Filter indicator is a tool that can be used to identify market conditions (ranging or trending). It measures if the price is going vertical (uni-directional) or horizontal (non-directional).
OVERVIEW :
The Vertical Horizontal Filter is a technical analysis indicator created by Adam White in 1991. He described it in the “Issues of Futures” magazine for the first time. The indicator is only composed of one line that measures the level of trend activity.
If the VHF line is increasing, we consider that the trend is getting stronger (up-trend or down-trend). Otherwise, if the VHF line is decreasing, we consider that the trend is weakening (going sideways or even ranging) as the market is getting calmer
CALCULATION :
The level of trend activity is calculated as the ratio between the distance from the highest to the lowest value (on the last N days) and the movement of the closing price.
VHF = ( highest (high) – lowest (low) ) / sum( close – previous close)
SETTINGS :
VHF length : Length of the vertical horizontal filter (28 or 18 recommended)
VHF source : Source of the vertical horizontal filter (close recommended)
VHF smoothing length : Extra smoothing applied on the VHF line to filter noise (1 or 6 or 9 or 14 recommended)
Display ranging market rectangles : Display rectangles on the chart around the area where VHF is decreasing (ranging market)
Display trending market rectangles : Display rectangles on the chart around the area where VHF is increasing (trending market up or down)
Minimum rectangle size : Hide rectangles that are smaller than X candles
Display signal line : Display circles at the bottom of the chart with the raw VHF direction (green if increasing /red if decreasing)
Display VHF tops and bottoms : Display triangles if the VHF line is reaching a new high or new low over the last 100 candles. When consecutive triangles appear, it may be a sign that the current market conditions are ending. Green triangles mean the possible end of the ranging market and red triangles mean the possible end of the trending market.
VISUALIZATIONS :
This indicator has 3 possible visualizations :
Rectangles : the rectangles are drawn on areas where the VHF is decreasing (red) or increasing (green) for a minimum number of consecutive candles. The first candles of an area may not be representative of the market conditions as the VHF line is still in extreme values but going slowly in the opposite direction. The market conditions (ranging or trending) get stronger with the VHF line keeping the same direction.
Signal line : The signal line is the VHF raw data : the red circle is a decreasing VHF line, and the green circle is an increasing VHF line.
Tops and bottoms : The tops and bottoms are signals indicating that the VHF line is reaching extreme values, there is a high probability that the market conditions are going to change after that.
USAGE :
This indicator can be used as a filter for strategies based on other technical analysis indicators.
If you are using trending indicators like moving averages, you should consider using them only when the market is trending. You can use VHF increasing to confirm that the market is not ranging.
If you are using oscillating indicators like stochastic or commodity channel index, you may prefer using them when the market is ranging as trending indicators may not be useful. You can use the VHF decreasing to confirm that the market is ranging.
Ehlers Distance Coefficient Filter [CC]The Distance Coefficient Filter was created by John Ehlers and this is one of his more unknown moving averages. It works well because in an uptrend or downtrend it behaves more like a trailing stop system but it also deals with issues like pullbacks pretty quickly. I think it works well with the default values but let me know if you find a more profitable system. Buy when the indicator turns green and sell when it turns red.
Let me know if there are any other indicators you would like to see me publish!
Volume, Momentum and Volatility weighted moving averageMoving averages are filters on price data. This moving average creates a filter which factors in:
- the price RSI or it's Momentum
- the volume RSI
- the RVI or Volatility
Each factor is put through a least squares filter to smooth them first.
Then the factors are used to build a coefficient for an exponentially weighted average.
The chart above shows a comparison of standard average types with this script.
This is useful if you are looking for a moving average based trigger and do not wish to react to candle noise price action.
LSMA CrossoverThis is a simple script designed to help filter out bad trades. LSMA is a trend king and by using the 21,200 and 1000 length lines traders can get a clear view of where price action is travelling. This indicator is the perfect companion to the LSMA Wave Rider indicator. Once a pullback is discovered (price action crosses under blue or white line) Traders can use LSMA Wave Rider to locate perfect entry point.
Least Squares Moving Average follows these rules:
When price crosses over it signals a bull trend.
When price crosses under it signals bear trend.
When price stays close or on the line sideways action is to be expected.
The direction of the line shows the direction of the trend.
Here is an example of finding good trades. Price action pulls below white or blue line.
Another example of what a pullback looks like.
This example shows how to find trend using crossovers.
Another example how trend can be found but by using line direction.
LSMA Wave Rider can be found here:
Ehlers NonLinear Filter [CC]The NonLinear Filter was created by John Ehlers and this one of his more unknown filters that work very well as a trendline and moving average. This is one of my favorites along with the instantenous trendlines that he created. Buy when the line turns green and sell when it turns red.
Let me know if there are any other indicators you would like to see me publish scripts for!
John Ehlers - The Price RadioPrice curves consist of much noise and little signal. For separating the latter from the former, John Ehlers proposed in the Stocks&Commodities May 2021 issue an unusual approach: Treat the price curve like a radio wave. Apply AM and FM demodulating technology for separating trade signals from the underlying noise.
reference: financial-hacker.com
Percentile Rank Market FilterA simple script to filter bull and bear markets by using percentile rank filter. Using market regimes to filter by bull/bear/sideways markets helps to understand how your strategy will
behave in various market regimes and allows you to avoid unprofitable regimes and only trade in profitable ones.
The idea of market regime filtering is used in the most successful technical algorithmic trading strategies, as one should always design a trading strategy with a particular market in mind according to trading legend, Larry Connors
Feel free to use this script in your strategies to improve your profits and lower drawdowns.
Historical Volatility Percentile FilterThis indicator provides a simple market regime filter for Historical Volatility. Depending on the strategy that you are using, it is useful to know how your strategy will perform at different
ranges of volatility, as this can greatly impact your performance. For instance, some of my long-only mean reversion strategies will only take trades where the volatility percentile is not extremely high, as this can often indicate fundamental changes in the security or the start of a big market correction. Some strategies may work better when volatility is higher
Feel free to use the following code along with your strategies to help improve performance and reduce the volatility of your gains in the long term.
Fourier Analysis and Filtering [tbiktag]This tool uses Fourier transform to decompose the input time series into its periodic constituents and seasonalities , in other words, its frequency components . It also can reconstruct the time-domain data while using only the frequency components within a user-defined range (band-pass filtering). Thereby, this tool can reveal the cyclical characteristics of the studied market.
USAGE
The source and the size of the input data can be chosen by the “ Dataset Source ” and “ Dataset Size ” options. Price, volume, or some technical indicator (e.g., RSI, MACD, etc.) can serve as a source of the input data.
“ Action ” defines the type of the plot that will be displayed. Two options are available:
- Fourier Analysis
If selected, the frequency spectrum of the squares of the Fourier coefficient magnitudes is displayed. The zero-frequency component is on the right. Since the magnitudes of half of the coefficients are repeated, the graph displays only half of the frequency components.
The squared magnitude of a given frequency component is a measure of its power , that is, its contribution to the total variance of the dataset. Thus, by analyzing the frequency-domain spectrum, one can identify the most prominent seasonalities and then visualize them by using the " Band-pass Filtering " option (see below). Note that the zero component stores information about the amount of data, so it is naturally higher when the data is not centered at zero.
By activating the " Info about Frequency Component " option, the user can display information about the power and frequency of the selected Fourier component.
- Band-pass Filter
This option reconstructs and plots the dataset in the time domain, blocking frequency components outside of the cutoff frequencies (defined by the input parameters “ Upper Cutoff ” and “ Lower Cutoff ” input parameters in the “ Band-pass Filter Properties ” section).
FURTHER READING
In general, Fourier analysis has a long history of attempted applications for analyzing price data and estimating market cycles. For example, see the paper by John Ehlers
www.mesasoftware.com
and also some tools available here on TradingView, such as:
“Function: Discrete Fourier Transform” by @RicardoSantos
“Fourier series Model Of The Market” by @e2e4mfck
“Ehlers Discrete Fourier Transform” by @cheatcountry
Thus, I tried to make this tool versatile and user-friendly so you all can experiment with your own analysis.
Enjoy and don't hesitate to leave your feedback in the comments below!
The Bayesian Q OscillatorFirst of all the biggest thanks to @tista and @KivancOzbilgic for publishing their open source public indicators Bayesian BBSMA + nQQE Oscillator. And a mighty round of applause for @MarkBench for once again being my superhero pinescript guy that puts these awesome combination Ideas and ES stradegies in my head together. Now let me go ahead and explain what we have here.
I am gonna call it the Bayesian Q Oscillator I suppose. The goal of the script is to solve an issue both indicators on their own suffer from. QQE signals are not new and often the problem has always been false signals for them. They are good for scalping but the difference between a quality move and a small to nearly nonexistent move following a signal is not so clear. Kivanc made his normalized version to help reduce this problem by adding colors to his histogram type verision that would essentially represent if price was a trending move or in a ranging structure. As you can see I have kept this Idea but instead opted for lines as the oscillator. two yellow line (default color) is a ranging sideways area and when there is red or green it is trending up or down. I wanted to take this to the next level with combining the Bayesian probability oscillator that tista put together.
The Bayesian indicator is the opposite for its issue as it is a probability indicator that shows which candle or price movement is more likely to come next. Red rising means possibly down move soon and green means up soon. I will not go into the complex details of this indicator but will suggest others take a look at his and others to understand the idea behind them. The point I am driving at is that it show probabilities or likelyhood without the most effecient signal device to match it. This original was line form and now it is background filled colors.
The idea. is that you can potentially get some stronger and more accurate reversal signals with these two paired together. when you see a sell signal or cross with the towering or rising red... maybe it is a good jump potentially. The same for green. At the same time it is a double added filter effect from just having yellow represent it is ranging... but now if you get a buy signal (example) and have yellow lines (example) along wi5h a red rising or mountain color background... it not only is an indication of ranging, but also that there is potentially even a counter move coming based on the probabilities. Also if you get into a good trade and see dual yellow qqe crosses with no color represented by the bayesian background... it is possible it might only be noise.
I have found them to work decently in the 1 hour timframe. Let me know your experience.
I hope everyone takes a look at the originals to understand them. Full credit goes to those guys for this to be here. Let me know how it is working out for you.
Here are the original links.
bayesian
Normalized QQE
Exotic SMA Explorations Treasure TroveThis is my "Exotic SMA Explorations Treasure Trove" intended for educational purposes, yet these functions will also have utility in special applications with other algorithms. Firstly, the Pine built-in sma() is exceedingly more efficient computationally on TV servers than these functions will be. I just wanted to make that very crystal clear. My notes elaborate on this in the code blatantly.
Anyhow, the simple moving average(SMA) is one of the most common averaging filters used in a wide variety of algorithms. "Simply put," it's name says a lot about it. The purpose of this script, is to demonstrate variations of it's calculation in a multitude of exotic forms. In certain scenarios our algorithms may require a specific mathemagical touch that is pertinent to our intended goals. Like screwdrivers, we often need different types depending on the objective we are trying to attain. The SMA also serves as the most basic of finite impulse response(FIR) algorithms. For example, things like weighted moving averages can be constructed by using the foundational code of SMA.
One other intended demonstration of this script, is running multiple functions for comparison. I have had to use this from time to time for my own comparisons of performance. Also, imbedded into this code is a method to generically and recklessly in this case, adapt an algorithm. I will warn you, RSI was NEVER intended to adapt an algorithm. It only serves as a crude method to display the versatility of these different algorithms, whether it be a benefit or hinderance concerning dynamic adaptability.
Lastly, this script shows the versatility of TV's NEW additions input(group=) and input(inline=) upgrades in action. The "Immense Power of Pine" is always evolving and will continue to do so, I assure you of that. We can now categorize our input()s without using the input(type=input.bool) hackTrick. Although, that still will have it's enduring versatility, at least for myself.
NOTICE: You have absolute freedom to use this source code any way you see fit within your new Pine projects. You don't have to ask for my permission to reuse these functions in your published scripts, simply because I have better things to do than answer requests for the reuse of these functions. Sufficient accreditation regarding this script and compliance with "TV's House Rules" regarding code reuse, is as easy as copying the functions in their entirety as is. Fair enough? Good!
When available time provides itself, I will consider your inquiries, thoughts, and concepts presented below in the comments section, should you have any questions or comments regarding this indicator. When my indicators achieve more prevalent use by TV members, I may implement more ideas when they present themselves as worthy additions. Have a profitable future everyone!
Efficient Trend Step Mod (v.3)This is a version 3 of my mod of the script by alexgrover - Efficient Trend Step.
The logic is based on calculation of Kaufman's efficiency ratio (ER):
ER = Direction / Volatility
where:
Direction = ABS (Close – Close )
Volatility = n ∑(ABS(Close – Close ))
n = The efficiency ratio period.
This version features volatility and volume filter and custom performance module.
Intraday SeasonalityDay trading trend filter indicator designed to hep get better entries or exits based on historical opens and closes each hour.
This indicator is NOT designed as an entry or exit signal. The purpose behind it is to give you statistical information about how likely certain times of day are either bullish, bearish or neutral and use that to confirm or reject other trading signals.
For example you might be anticipating a breakout based on your strategy or another indicator but see that the next few hours are usually bearish and re-evaluate entering the trade.
The Intraday Seasonality indicator calculates the percentage of candles per hour that had a higher close than open.
Default settings are:
- a look-back of 90 days.
- extreme bullish (bright green) above 74%
-extreme bearish (bright red) below 25%
- bullish (green) above 55%
- bearish (red) below 45%
- neutral (white) exactly 50%
- no trend (gray) 46% - 54%
All of these are updatable via the settings.
This indicator is designed to work only on the 1 hour timeframe.
To use the indicator set your local timezone offset in the indicator settings.
*Due to daylight savings and certain timezones changing throughout the year there is a timezone override in the indicator settings if the indicator doesn't pick up the correct local time.
Monthly SeasonalitySimple indicator designed as filter so you can easily see how the currency or asset performed during each month historically.
Can used to identify a possible month to enter or exit a trade in. For best results use in combination with another indicator or candle pattern to signal an entry in a historically bullish month
*This indicator is designed to be used only on the monthly chart.
Bandpass Filters v.02
This is an alternative way to do bandpass filtering. I Still need to update it to support moveable frequency bands. The lowBandpass() is just a 'trick,' as it simply subtracts the highBandpass() from the close data, so it is not really accurate in that it removes the low frequencies, just in a rather less-than-ideal manner.
The "spectrum" of the dataset to filter will always be from 0 to 100, so think of filter boundary as %. So, a boundary of 40% means: 40% of the low-frequencies have been removed from the original data to make the red graph, and 40% of the high-frequencies have been removed from the original data to make the green graph.
This came about after reading the excellent tutorial on signal processing in Pine Script (www.pinecoders.com), as the techniques listed there did not do exactly what I was looking for.
Here is a low-pass graph
Here is a hi-pass graph
[NLX-L2] Hurst Exponent Signal Filter- Hurst Exponent Signal Filter -
The Hurst Exponent Signal Filter is meant to be used with an external signal source, this can be any indicator with a signal plot output (-1 Sell / 1 Buy)
It filters out a lot of noisy signals and improves the performance of many indicators.
- Example: How to Use -
1. Add a trend Indicator like Trend Index MTF to your chart
2. Add an indicator with a signal plot like Fishers Stochastic Center of Gravity to your Chart and select the Trend Index MTF with Type L1 in the Settings as Signal Source
3. Add this Hurst Signal Filter to your Chart and select the Fishers Stochastic Center of Gravity with Type L2 in the Settings as Signal Source
4. Add the Backtest Module to your Chart and select the Hurst Signal Filter with Type L2 as Source
- Alerts for Automated Trading -
See my signature below. Contact me for the Alert module.
Computing FIR Filters Using Arrays [WMA Example]Over the years, many FIR filters have been proposed by the Pine community, with the standard way of computing them being `for` loops. The arrival of arrays allows for a new, more efficient way to compute them.
This script provides a template showing how you can compute FIR filters using Pine arrays.
FIR Filters
FIR stands for "Finite Impulse Response", and is associated with types of filters whose impulse response reaches a steady state.
FIR filters are calculated using convolution, or more simply put, using a weighted sum between a set of filter coefficients and past input values over a finite window.
In Pine, FIR filters are generally computed inside a `for` loop executing three processes:
1- Computing the coefficients.
2- Summing all the computed coefficients.
3- Performing the weighted sum between the inputs values and the computed coefficients.
Then we divide the result of our weighted sum by the sum of the coefficients obtained in step 2.
Because the computations inside the `for` loop execute on each bar, execution time can be significant when the calculation of coefficients is complex. This is where arrays are handy, as we can compute the coefficients just once, store them into an array, and use them in a weighted sum without the need to recalculate them over and over. This drastically reduces the computation time required to calculate a FIR filter.
The new `array.sum()` function helps eliminate step 2, thus further decreasing computation time.
How to Use This Template
All you need to do is to put the code that computes your coefficients in the first `for` loop (variable `w`). If the code that computes your coefficients contains more than one line, just make sure your final coefficient is placed in variable `w` (or change the `value` argument in `array.push()`). Another option is to declare a function that computes the coefficients and use it instead of variable `w`.
Look first. Then leap.
Ehlers 3 Pole Butterworth Filter V2 [CC]The 3 Pole Butterworth Filter was created by John Ehlers (Cybernetic Analysis For Stocks And Futures pgs 196-197) and this indicator is a moving average that also works well as a trendline. Buy when the indicator line turns green and sell when it turns red.
Let me know if you would like me to publish other indicators or if you want something custom done!
Ehlers 2 Pole Super Smoother Filter V2 [CC]The 2 Pole Super Smoother Filter was created by John Ehlers (Cycle Analytics For Traders pg 32) and this follows the price very closely and very useful because it is consistent with uptrends and falls sharply during a sudden downtrend so it should be able to help you stay more profitable. Buy when the indicator line turns green and sell when it turns red.
Let me know if there are other indicators you would like to see me publish or if you want something custom done!
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).
Bollinger Bands Breakout StrategyBollinger Bands Breakout Strategy is the strategy version of Bollinger Bands Filter study version, which can be found under my scripts page. The strategy goes long when price closes above the upper band and goes short signal when price closes below the lower band.
Bollinger Bands is a classic indicator that uses a simple moving average of 20 periods, along with plots of upper and lower bands that are 2 standard deviations away from the basis line. These bands help visualize price volatility and trend based on where the price is, in relation to the bands.
The strategy doesn't take into account any other parameters such as Volume / RSI / Fundamentals etc, so user must use discretion based on confirmations from another indicator or based on fundamentals. The strategy results are based on purely long and short trades and doesn't take into account any user defined targets or stop losses.
The strategy works great when the price closes above/below upper/lower bands with continuation on next bar. It is definitely useful to have this strategy or the Bollinger Bands filter along with other indicators to get early glimpse of breach/fail of bands on candle close during BB squeeze or based on volatility .
This can be used on Heikin Ashi candles for spotting trends, but HA candles are not recommended for trade entries as they don't reflect true price of the asset.
The strategy settings default is 55 SMA and 1 standard deviation for Bollinger Bands filter, but these can be changed from settings.
It is definitely worth reading the 22 rules of Bollinger Bands written by John Bollinger if interested in trading Bollinger Bands successfully.