Mean reversionSimple mean reversion strategy.
Strategy aims to find three bullish or bearish candle pattern which ends with strong move. Position will be open until we get close above previous highs.
Strategy uses also simple moving average to filter short positions.
This strategy works well with QQQ and daily time frame but it seems to do fairly well intraday also.
User can modify moving average length and how strong is the move of the last candle.
This strategy is inspired a strategy by hackertrader. The original idea by QuantpT.
Meanreversion
LNL Keltner ExhaustionLNL Keltner Exhaustion resolves the constant issue of Bands vs. EMAs
With the keltner exhaustion wedges, you can easily see the keltner channel extremes witout using the actual bands. That way, you will know whether the price is outside of the keltner channels + you can use other indicators (such as EMAs) on chart without the bands so the chart does not look messy & hard to read.
Two Types of Wedges:
1. Green/Red Wedge - Price action is extended outside the regular band. More of a "profit taking" zone rather than "entry taking" (default set to 3.0 ATR factor).
2. Purple Wedge - Price action is extended outside of the extreme band. Chances are price will revert to mean soon (default set to 4.0 ATR factor).
Works great as a target tool with the squeeze setup or as an overall extension gauge.
Hope it helps.
Steven Primo's bollinger bands strategyHi, this strategy is taken from a video made by Steven Primo. You can look it up on YouTube if you want to know about it.
It is a mean-reversion strategy based on the Bollinger Bands, in which we wait for 5 consecutive closes above the upper band, and for a short-term top. Once it happens, we place an entry order on this top, with a stop at the nearest bottom before the movement started, and use the difference from the stop and entry point to determine the target. For shorting, it's the same process, but for the downside. From my testing, only long orders were profitable, but you can configure whichever you want.
It works well for directional markets with a low level of noise, as you can see with the BTCUSD chart. One of its caveats is the short number of occurrences, and the long stop loss and target. You can enable a trailing stop, but from my testings, it just made the results worse.
I made some modifications, like removing the MA requirement, since the entry point was above it almost all the time, and I forced the BB to use a log version of the prices, so that discrepancies are eliminated. You'll also notice that you can't select an extension that is lower than 100, and that is intentional, since you're not supposed to enter a trade in which you can lose more than what you can earn.
I chose not to implement any kind of risk management, but I might do that in the future. You can leave your suggestions in the comments.
LS Volatility Index█ OVERVIEW
This indicator serves to measure the volatility of the price in relation to the average.
It serves four purposes:
1. Identify abnormal prices, extremely stretched in relation to an average;
2. Identify acceptable prices in the context of the main trend;
3. Identify market crashes;
4. Identify divergences.
█ CONCEPTS
The LS Volatility Index was originally described by Brazilian traders Alexandre Wolwacz (Stormer) , Fabrício Lorenz , and Fábio Figueiredo (Vlad)
Basically, this indicator can be used in two ways:
1. In a mean reversion strategy , when there is an unusual distance from it;
2. In a trend following strategy , when the price is in an acceptable region.
Perhaps the version presented here may have some slight differences, but the core is the same.
The original indicator is presented with a 21-period moving average, but here this value is customizable.
I made some fine tuning available, namely:
1. The possibility of smoothing the indicator;
2. Choose the type of moving average;
3. Customizable period;
4. Possibility to show a moving average of the indicator;
5. Color customization.
█ CALCULATION
First, the distance of the price from a given average in percentage terms is measured.
Then, the historical average volatility is obtained.
Finally the indicator is calculated through the ratio between the distance and the historical volatility.
To facilitate visualization, the result is normalized in a range from 0 to 100.
When it reaches 0, it means the price is on average.
When it hits 100, it means the price is way off average (stretched).
█ HOW TO USE IT
Here are some examples:
1. In a return-to-average strategy
2. In a trend following strategy
3. Identification of crashes and divergences
█ THANKS AND CREDITS
- Alexandre Wolwacz (Stormer), Fabrício Lorenz, Fábio Figueiredo (Vlad)
- Feature scaler (for normalization)
- HPotter (for calc of Historical Volatility)
Oasis Trading Group Market Making Bot - Mean Reversion BandsThe OTG Market Making Bot was designed with mean reversion trading in mind. It uses advanced ATR and other volatility formulas to create a set of bands that price should stay within. If price is testing the upper or lower bands then it is "extended" and a mean reversion back to the midline is likely.
The indicator comes with two sets of reversion bands, by default they are set to two and three standard deviations away from the midline, these can be changed to your preference. The indicator will give you Buy and Sell arrows if the conditions are being met. The conditions can be as simple as price hitting the bands or with certain filters, the filters are as follows:
Volatility Filter: Based on your settings it will look at the Current ATR vs Historic ATR Average if the Current ATR is higher than the average it will not show the mean reversion Buy/Sell signals because the volatility is too high. This filter can be turned on and off in the settings.
Trend Filter: Based on your settings it will lookback a certain amount of candles to see if the current price action is ranging or trending. If the current price action is determined to be trending it will not show the mean reversion Buy/Sell signals because it wants to trade within a range. This filter cannot be turned off in the settings, but if you wish to see all the Mean Reversion Buy/Sell signals without any filters you can turn them on in the style settings.
Midline: The midline is color coded based on your Trend Lookback settings. If it determines that the market is ranging it will be colored Green, if it determines that the market is trending it will be colored Red. Green means you are safe to take Mean Reversion trades.
The indicator comes with multiple alerts for all the different Buy/Sell signals. These signals can come from the first set of bands, second set, or unfiltered.
This indicator is designed to be paired with the ATR Improved Indicator I have created which is open source, it can be found here.
Also, paired with the OTG Automated Trading Bot. The OTG Trading Bot is a trend following bot, it excels in trend trading but fails in range trading. This Mean Reversion bot was designed to compliment the OTG Bot perfectly.
The Oasis Trading Group Market Making Bot will be available as a free add-on to all OTG Trading Bot users.
If you have any questions feel free to let me know in the comments or DM me.
Trend Day IndentificationVolatility is cyclical, after a large move up or down the market typically "ranges" during the next session. Directional order flow that enters the market during this subsequent session tends not to persist, this non-persistency of transactions leads to a non-trend day which is when I trade intraday reversionary strategies.
This script finds trend days in BTC with the purpose of:
1) counting trend day frequency
2) predicting range contraction for the next 1-2 days so I can run intraday reversion strategies
Trend down is defined as daily bar opening within X% of high and closing within X% of low
Trend up is defined as daily bar opening within X% of low and closing within X% of high
default parameters are:
1) open range extreme = 15% (open is within 15% of high or low)
2) close range extreme = 15% (close is within 15% of high or low)
There is also an atr filter that checks that the trend day has a larger range than the previous 4 bars this is to make sure we find true range expansion vs recent ranges.
Notes:
If a trend day occurs after a prolonged sideways contraction it can signal a breakout - this is less common but is an exception to the rule. These types of occurrences can lead to the persistency of order flow and result in extended directional daily runs.
If a trend day occurs close to 20 days high or low (stopping just short OR pushing slightly through) then wait an additional day before trading intraday reversion strategies.
Mean Shift Pivot ClusteringCore Concepts
According to Jeff Greenblatt in his book "Breakthrough Strategies for Predicting Any Market", Fibonacci and Lucas sequences are observed repeated in the bar counts from local pivot highs/lows. They occur from high to high, low to high, high to low, or low to high. Essentially, this phenomenon is observed repeatedly from any pivot points on any time frame. Greenblatt combines this observation with Elliott Waves to predict the price and time reversals. However, I am no Elliottician so it was not easy for me to use this in a practical manner. I decided to only use the bar count projections and ignore the price. I projected a subset of Fibonacci and Lucas sequences along with the Fibonacci ratios from each pivot point. As expected, a projection from each pivot point resulted in a large set of plotted data and looks like a huge gong show of lines. Surprisingly, I did notice clusters and have observed those clusters to be fairly accurate.
Fibonacci Sequence: 1, 2, 3, 5, 8, 13, 21, 34...
Lucas Sequence: 2, 1, 3, 4, 7, 11, 18, 29, 47...
Fibonacci Ratios (converted to whole numbers): 23, 38, 50, 61, 78, 127, 161...
Light Bulb Moment
My eyes may suck at grouping the lines together but what about clustering algorithms? I chose to use a gimped version of Mean Shift because it doesn't require me to know in advance how many lines to expect like K-Means. Mean shift is computationally expensive and with Pinescript's 500ms timeout, I had to make due without the KDE. In other words, I skipped the weighting part but I may try to incorporate it in the future. The code is from Harrison Kinsley . He's a fantastic teacher!
Usage
Search Radius: how far apart should the bars be before they are excluded from the cluster? Try to stick with a figure between 1-5. Too large a figure will give meaningless results.
Pivot Offset: looks left and right X number of bars for a pivot. Same setting as the default TradingView pivot high/low script.
Show Lines Back: show historical predicted lines. (These can change)
Use this script in conjunction with Fibonacci price retracement/extension levels and/or other support/resistance levels. If it's no where near a support/resistance and there's a projected time pivot coming up, it's probably a fake out.
Notes
Re-painting is intended. When a new pivot is found, it will project out the Fib/Lucas sequences so the algorithm will run again with additional information.
The script is for informational and educational purposes only.
Do not use this indicator by itself to trade!
R3 ETF StrategyThis strategy is a modification of the “R3 Strategy” from the book "High Probability ETF Trading" by Larry Connors and Cesar Alvarez. This RSI strategy is for a 1-day time-frame and has these 3 simple rules:
Criteria:
The price must be above the 200 day moving average.
The 2-period (day) RSI drops 3 days in a row.
The 2-period RSI must have been below 60 3 days ago and below 10 today.
Entry and Exit:
If the 3 rules above are true, then buy on the close of the current day.
Exit on the day's close when the RSI crosses above 70.
How it works :
The Strategy will buy when the buy conditions above are true. The strategy will sell when the RSI crosses above 70. The RSI period/length, and RSI entry/exit criteria thresholds have all been coded to be adjustable with inputs.
Plots :
Blue line = 200 Day EMA (Used as Entry Criteria)
Disclaimer: Open-source scripts I publish in the community are largely meant to spark ideas that can be used as building blocks for part of a more robust trade management strategy. If you would like to implement a version of any script, I would recommend making significant additions/modifications to the strategy & risk management functions. If you don’t know how to program in Pine, then hire a Pine-coder. We can help!
Channel of linear regression of rate of change from the mean The indicator calculates the difference between the closing price and the average as a percentage and after that it calculates the average linear regression and then draws it in the form of a channel.
Preferably use it on 30 min or 15 min or 1 Hour or 2H time frames .
Exiting outside the upper or lower channel limits represents high price inflation, and returning inside the channel means the possibility of the price rising or falling for the average or the other limit of the channel.
Channel lines may represent places of support and resistance.
Nasdaq VXN Volatility Warning IndicatorToday I am sharing with the community a volatility indicator that uses the Nasdaq VXN Volatility Index to help you or your algorithms avoid black swan events. This is a similar the indicator I published last week that uses the SP500 VIX, but this indicator uses the Nasdaq VXN and can help inform strategies on the Nasdaq index or Nasdaq derivative instruments.
Variance is most commonly used in statistics to derive standard deviation (with its square root). It does have another practical application, and that is to identify outliers in a sample of data. Variance is defined as the squared difference between a value and its mean. Calculating that squared difference means that the farther away the value is from the mean, the more the variance will grow (exponentially). This exponential difference makes outliers in the variance data more apparent.
Why does this matter?
There are assets or indices that exist in the stock market that might make us adjust our trading strategy if they are behaving in an unusual way. In some instances, we can use variance to identify that behavior and inform our strategy.
Is that really possible?
Let’s look at the relationship between VXN and the Nasdaq100 as an example. If you trade a Nasdaq index with a mean reversion strategy or algorithm, you know that they typically do best in times of volatility . These strategies essentially attempt to “call bottom” on a pullback. Their downside is that sometimes a pullback turns into a regime change, or a black swan event. The other downside is that there is no logical tight stop that actually increases their performance, so when they lose they tend to lose big.
So that begs the question, how might one quantitatively identify if this dip could turn into a regime change or black swan event?
The Nasdaq Volatility Index ( VXN ) uses options data to identify, on a large scale, what investors overall expect the market to do in the near future. The Volatility Index spikes in times of uncertainty and when investors expect the market to go down. However, during a black swan event, historically the VXN has spiked a lot harder. We can use variance here to identify if a spike in the VXN exceeds our threshold for a normal market pullback, and potentially avoid entering trades for a period of time (I.e. maybe we don’t buy that dip).
Does this actually work?
In backtesting, this cut the drawdown of my index reversion strategies in half. It also cuts out some good trades (because high investor fear isn’t always indicative of a regime change or black swan event). But, I’ll happily lose out on some good trades in exchange for half the drawdown. Lets look at some examples of periods of time that trades could have been avoided using this strategy/indicator:
Example 1 – With the Volatility Warning Indicator, the mean reversion strategy could have avoided repeatedly buying this pullback that led to this asset losing over 75% of its value:
Example 2 - June 2018 to June 2019 - With the Volatility Warning Indicator, the drawdown during this period reduces from 22% to 11%, and the overall returns increase from -8% to +3%
How do you use this indicator?
This indicator determines the variance of VXN against a long term mean. If the variance of the VXN spikes over an input threshold, the indicator goes up. The indicator will remain up for a defined period of bars/time after the variance returns below the threshold. I have included default values I’ve found to be significant for a short-term mean-reversion strategy, but your inputs might depend on your risk tolerance and strategy time-horizon. The default values are for 1hr VXN data/charts. It will pull in variance data for the VXN regardless of which chart the indicator is applied to.
Disclaimer: Open-source scripts I publish in the community are largely meant to spark ideas or be used as building blocks for part of a more robust trade management strategy. If you would like to implement a version of any script, I would recommend making significant additions/modifications to the strategy & risk management functions. If you don’t know how to program in Pine, then hire a Pine-coder. We can help!
S&P500 VIX Volatility Warning IndicatorToday I am sharing with the community a volatility indicator that can help you or your algorithms avoid black swan events. Variance is most commonly used in statistics to derive standard deviation (with its square root). It does have another practical application, and that is to identify outliers in a sample of data. Variance in statistics is defined as the squared difference between a value and its mean. Calculating that squared difference means that the farther away the value is from the mean, the more the variance will grow (exponentially). This exponential difference makes outliers in the variance data more apparent.
Why does this matter?
There are assets or indices that exist in the stock market that might make us adjust our trading strategy if they are behaving in an unusual way. In some instances, we can use variance to identify that behavior and inform our strategy.
Is that really possible?
Let’s look at the relationship between VIX and the S&P500 as an example. If you trade an S&P500 index with a mean reversion strategy or algorithm, you know that they typically do best in times of volatility. These strategies essentially attempt to “call bottom” on a pullback. Their downside is that sometimes a pullback turns into a regime change, or a black swan event. The other downside is that there is no logical tight stop that actually increases their performance, so when they lose they tend to lose big.
So that begs the question, how might one quantitatively identify if this dip could turn into a regime change or black swan event?
The CBOE Volatility Index (VIX) uses options data to identify, on a large scale, what investors overall expect the market to do in the near future. The Volatility Index spikes in times of uncertainty and when investors expect the market to go down. However, during a black swan event, the VIX spikes a lot harder. We can use variance here to identify if a spike in the VIX exceeds our threshold for a normal market pullback, and potentially avoid entering trades for a period of time (I.e. maybe we don’t buy that dip).
Does this actually work?
In backtesting, this cut the drawdown of my index reversion strategies in half. It also cuts out some good trades (because high investor fear isn’t always indicative of a regime change or black swan event). But, I’ll happily lose out on some good trades in exchange for half the drawdown. Lets look at some examples of periods of time that trades could have been avoided using this strategy/indicator:
Example 1 – With the Volatility Warning Indicator, the mean reversion strategy could have avoided repeatedly buying this pullback that led to SPXL losing over 75% of its value:
Example 2 - June 2018 to June 2019 - With the Volatility Warning Indicator, the drawdown during this period reduces from 22% to 11%, and the overall returns increase from -8% to +3%
How do you use this indicator?
This indicator determines the variance of the VIX against a long term mean. If the variance of the VIX spikes over an input threshold, the indicator goes up. The indicator will remain up for a defined period of bars/time after the variance returns below the threshold. I have included default values I’ve found to be significant for a short-term mean-reversion strategy, but your inputs might depend on your risk tolerance and strategy time-horizon. The default values are for 1hr VIX data. It will pull in variance data for the VIX regardless of which chart the indicator is applied to.
Disclaimer : Open-source scripts I publish in the community are largely meant to spark ideas or be used as building blocks for part of a more robust trade management strategy. If you would like to implement a version of any script, I would recommend making significant additions/modifications to the strategy & risk management functions. If you don’t know how to program in Pine, then hire a Pine-coder. We can help!
Deviation BandsThis indicator plots the 1, 2 and 3 standard deviations from the mean as bands of color (hot and cold). Useful in identifying likely points of mean reversion.
Default mean is WMA 200 but can be SMA, EMA, VWMA, and VAWMA.
Calculating the standard deviation is done by first cleaning the data of outliers (configurable).
TradeChartist Actuator™TradeChartist Actuator is an extremely functional indicator that converts the price action volatility and momentum into a meaningful trading system (based on user defined Standard Deviation Factor), that consists of expanding/contracting Volatility Range Bands, Dynamic Trend Support/Resistance Bands and 2 types of Breakout Signals in a visually stunning design. The script also neatly packs in ZigZag & manual/automatic Fibonacci Retracement tools, option to filter the signals using an external filter and other useful extras like ™TradeChartist Dollar Candles and much more.
===================================================================================================================
™TradeChartist Actuator User Manual
█ Actuator Range Bands
Actuator Range Bands consists of a Mean line, an Upper Band and a Lower Band which are based on user defined Standard Deviation Factor (Default - 1.618, Min - 0.5, Max - 2). The 1.618 factor works extremely well as the unnecessary volatility data of the bands are eliminated by Actuator's logic. In my personal tests, 1.618 works consistently better than any other value in visually showcasing the true volatility range. By eliminating the unnecessary volatility data from the original non-stabilized bands, Actuator helps detect price momentum by detecting two types of breakouts.
Bands Breakout - Filtered
When the price breaks out of the upper or lower band after a trend, there is a strong possibility of a reversal especially when the volatility expansion/contraction takes place. This is detected using a built in filter with the Filtered Bands Breakout and the user can choose to use the closing price or High/Low price as the trigger for breakouts. This trade setup is very useful especially at zones where the Actuator Range Bands contract or squeeze after an expansion as shown in the OANDA:XAUUSD 1hr chart below.
Also, after a consistent expansion of the bands with price trending in the upper channel or the lower channel, users can spot good profit taking or Short trade opportunities with confirmation of overbought price and if possible a strong bear divergence as show in the BINANCE:LUNAUSDTPERP 1hr chart below.
It can be seen from the chart above that even though Actuator is designed to detect Extreme Bands Breakout using High/Low price, it is done with a little bit of filtering by the script logic and hence didn't generate a Bear signal at the lower band support zone.
Mean Breakout - Filtered
In most Mean Reversion models, mostly oscillators, the mean plays an important role in helping traders predict the price dynamic, but it also presents a challenge whether that mean will act as support or resistance so the trader can take a position that will have a high probability of success. Filtered Mean Breakout helps exactly to identify the price dynamic at the mean zone and helps reduce the dilemma. Actuator uses Volatility Trend and Momentum of the price action at mean to determine Bull/Bear breakouts. Following NASDAQ:AAPL 1hr chart shows an example of 2 instances of Filtered Mean Breakout detection, one bull and one bear and further area where no Breakout was detected in spite of price crossing the mean.
This Breakout type is really helpful in spotting early moves and also reduces the high volatility risk of Extreme Bands Breakout in some cases.
===================================================================================================================
█ External Filter
Actuator breakout signals can be further filtered using the feature of connecting an external signal as a trade filter.
External filter like RSI , MACD etc. can be used to filter breakouts by connecting to ™TradeChartist Actuator under ╔═══ 𝗣𝗹𝘂𝗴 𝗙𝗶𝗹𝘁𝗲𝗿 𝗵𝗲𝗿𝗲 ═══ 🔌 dropdown by enabling 𝐔𝐬𝐞 𝐄𝐱𝐭𝐞𝐫𝐧𝐚𝐥 𝐅𝐢𝐥𝐭𝐞𝐫.
To get the external filter to work, 𝐒𝐢𝐠𝐧𝐚𝐥 𝐓𝐲𝐩𝐞 must be set right. For plots that are non oscillatory like Moving Averages, Super Trend etc., choose type as Non Oscillatory and for Oscillators like RSI , CCI , MACD etc., choose type as Oscillatory .
For Oscillators, levels must be specified for 𝐎𝐬𝐜𝐢𝐥𝐥𝐚𝐭𝐨𝐫 𝐁𝐮𝐥𝐥 𝐅𝐢𝐥𝐭𝐞𝐫 𝐯𝐚𝐥𝐮𝐞 and 𝐎𝐬𝐜𝐢𝐥𝐥𝐚𝐭𝐨𝐫 𝐁𝐞𝐚𝐫 𝐅𝐢𝐥𝐭𝐞𝐫 𝐯𝐚𝐥𝐮𝐞, especially if the Oscillator doesnt have 0 as midline, like RSI . Even for 0 mid oscillators like CCI , filter levels like 100/-100 work effectively to filter noise.
Use 𝐁𝐮𝐥𝐥/𝐁𝐞𝐚𝐫 𝐁𝐚𝐜𝐤𝐠𝐫𝐨𝐮𝐧𝐝 𝐅𝐢𝐥𝐥 under Actuator Visuals section to paint the trade zones background. It helps visually see the effect of filters on the breakout entries and also the trade performance.
The following chart shows the Filter settings with ™TradeChartist Momentum Drift Oscillator connected to Actuator as Oscillatory signal with filter values 0.
The two example charts of 1hr BINANCE:BTCUSDT below shows the difference in Actuator signals based on Oscillatory signal from ™TradeChartist Momentum Drift Oscillator and the difference can be seen from the highlighted Bull/Bear Background Fill.
Without External Filter
With External Filter
===================================================================================================================
█ Dynamic Trend Support/Resistance Bands
In addition to Volatility Range Bands, Actuator also plots Dynamic Trend Support and Resistance bands that are more sensitive to price action and helps the user determine growing support/resistance which is indicated by coloured dots. These dots normally appear when the Support or Resistance stays at the same level for a few bars and change between Bull and Bear colours based on how the price interacts with them as shown below.
===================================================================================================================
█ Useful Trade Tools
™TradeChartist Dollar Candles
Dollar Candles help detect the volatility exhaustion prices and plots $ signs to help the trader take profits or move stop loss levels to secure gains. The $ signs do not appear for every trade zone, but whenever price hits a critical level, it shows up above price bar (for Bull trend) or below price bar (for Bear trend) in real time. Users can also set alerts for Dollar Candles with Once Per Bar setting. The Daily NASDAQ:TSLA chart below shows the Dollar Candles on both Bull and Bear trends.
It is important to note that taking pockets of profits on a leveraged trade position or moving up stop loss to maximize trend gains at $ candles will help increase Average Profitability Per Trade (APPT) .
Bull/Bear Background Fill
Bull/Bear Background Fill paints the trade zones in Bull and Bear colours. This helps visualize the difference in trade zones when testing various settings and also helps analyze past performance of Actuator Signals with or without the use of External Filter.
Entry Stop Loss Reference
Reference zone for stop loss has always been a tricky one for traders. Using a fixed percentage stop at entry may not be best during high volatility moves. Over the extensive period of Actuator testing, a simple solution to this problem was found. The previous trend's Range Bands Mean Line served as a perfect reference point for Entry Stop. Also while analysing this Mean line, it was found to be a perfect horizontal support/resistance line and also helped detect unproductive trades. The example 15m chart of NASDAQ:AMD shows how the Entry Stop Loss Reference performed.
Stop Line Touch Points plot orange touch points on the Stop Line whenever the price hits it during the trade.
Actuator Colour Bars
Actuator Colour Bars paints the Momentum Strength on the price bars. This helps visually see the price bars venturing into the Overbought or the Oversold zones. Also, this feature also helps spot divergences as higher highs or lower lows with less intense Bull/Bear colour than the previous high/low shows diminishing momentum as shown in the 1h chart of OANDA:GBPJPY below.
===================================================================================================================
█ ZigZag & Fibonacci Toolkit
Actuator plots developing and completed ZigZags based on Bull and Bear trend depending on the Breakout Type and Breakout Price from the settings.
Option to enable or disable 𝐙𝐢𝐠𝐙𝐚𝐠 𝐂𝐨𝐧𝐧𝐞𝐜𝐭𝐨𝐫 which can be helpful for Harmonic traders.
Option to display 𝐙𝐢𝐠𝐙𝐚𝐠 𝐇𝐢𝐠𝐡𝐬/𝐋𝐨𝐰𝐬 and 𝐑𝐒𝐈 𝐚𝐭 𝐇𝐢𝐠𝐡𝐬/𝐋𝐨𝐰𝐬 in one of two styles.
Two types of Fibonacci to choose from - 𝐀𝐮𝐭𝐨-𝐅𝐢𝐛𝐬 and 𝐅𝐢𝐛𝐬 𝐛𝐚𝐬𝐞𝐝 𝐨𝐧 𝐋𝐨𝐨𝐤𝐛𝐚𝐜𝐤.
𝐀𝐮𝐭𝐨-𝐅𝐢𝐛𝐬 option plots Auto Fibonacci levels based on Bull/Bear trend depending on user specified Breakout Type and Breakout Price.
𝐅𝐢𝐛𝐬 𝐛𝐚𝐬𝐞𝐝 𝐨𝐧 𝐋𝐨𝐨𝐤𝐛𝐚𝐜𝐤 plots Fibonacci levels based on the highest high and lowest low of the lookback period (𝐃𝐚𝐲𝐬 or 𝐂𝐚𝐧𝐝𝐥𝐞𝐬).
Fibonacci levels can be reversed by enabling 𝐑𝐞𝐯𝐞𝐫𝐬𝐞 from settings.
Enabling 𝐂𝐮𝐫𝐫𝐞𝐧𝐭 𝐏𝐫𝐢𝐜𝐞 𝐅𝐢𝐛 𝐋𝐚𝐛𝐞𝐥 displays the current Fib level of the developing price bar.
Option to customize Fib levels and colours.
4hr chart of BINANCE:BTCUSDT showing Auto Fibonacci levels, Zig-Zag with Trend High/Lows, Zig-Zag connectors with Fib Ratios and RSI at Trend High/Low prices.
Note:
If momentum doesn't slow down, the fibs can extend beyond 1 and may continue way beyond 4.618 fib level. These are quite rare depending on how distant the near high/low is based.
ZigZag and Fibonacci are good reference indicators and should always be used as confirmations rather than standalone indicators.
===================================================================================================================
█ Actuator Colour Scheme
Actuator employs 3 built in colour schemes namely Chilli , Flame and Sublime Grayscale and a versatile colour scheme Custom which enables the user to customise the colour combinations of the components of the Actuator script.
===================================================================================================================
█ Alerts
Alerts can be created for the following.
Actuator Bull Breakout Signal - Once Per Bar Close
Actuator Bear Breakout Signal - Once Per Bar Close
Actuator Long Dollar - Take Profit - Once Per Bar
Actuator Short Dollar - Take Profit - Once Per Bar
Actuator Stop Line Hit - Once Per Bar
Note: The script doesn't repaint, so the alerts can be used with confidence. To check this, users can do bar replays to check if the plots and markers stay in the same place.
===================================================================================================================
Best Practice: Test with different settings first using Paper Trades before trading with real money
===================================================================================================================
TradeChartist Mean Momentum Drift Oscillator (MMDO)™TradeChartist Mean Momentum Drift Oscillator (MMDO) is the Oscillator version of the ™TradeChartist Mean Momentum Drift Bands (MMDB) indicator with some added visual features to spot Momentum, divergences and Price action using ™TradeChartist Zone Visualizer model.
===================================================================================================================
Features of ™TradeChartist MMDO
==============================
Price zone detection using ™TradeChartist Zone Visualizer model.
No User input required.
3 Visual colour schemes - Chilli, Flame and Custom.
Clear Visualization of Overbought and Oversold zones.
Colour Bars based on Momentum strength.
MDDO highs and lows tracker helps detect divergences.
===================================================================================================================
Example Charts
1. MMDO used along with ™TradeChartist MMDB (Mean Momentum Drift Bands) on 4hr chart of BINANCE:BTCUSDT
2. MMDO on 1hr chart of OANDA:EURUSD to confirm Drift Bands breakout entries on MMDB
3. MMDO on 1hr chart of BINANCE:LUNAUSDT
===================================================================================================================
Best Practice: Test with different settings first using Paper Trades before trading with real money
===================================================================================================================
Outside DayThis strategy is taken from Perry Kaufman's book "Trading System and Methods".
You can enter on the direction of the candle, or opposite to it. I find that the opposite tends to yield better results in volatile assets, allowing a better reward to risk ratio. There is no stop loss in this strategy, only a fixed take profit and a time limitation.
34 EMA BandsThis is quite a simple script, just plotting a 34EMA on high's and low's of candles. Appears to work wonders though, so here it is.
There is some //'d code which I haven't finished working on, but it looks to be quite similar to Bollinger Bands, just using different math rather than standard deviations from the mean.
The bands itself is pretty self explanatory, price likes to use it as resistance when under it, it can trade inside it and it can use the upper EMA as support when in a strong upward trend.
Low-High-Trend StrategyWhen asked what the key to successful investing was, Warren Buffet famously said “buy low, sell high.” Was he onto something? Today I am sharing with the community a simple “buy low, sell high” strategy with an optional trend filter and take-profit target. I’ve found that this strategy works well in a variety of markets but has a higher tendency to out-perform buy & hold in markets that are ranging sideways.
How it works:
The strategy tracks the highest and lowest price over the last X number of bars (you select the look-back period). The highest price line is plotted in green and the lowest price line is potted in red. If the price crosses over the lowest price in the last X number of bars, then a buy signal is generated. Exit options include a take-profit % or selling when the price crosses over the highest price in the last X amount of bars. I.e. “Buy low, sell high.” An EMA is also plotted as a blue trend line, and there is an option to only trade if the price is above the EMA trend line.
Disclaimer: Open source scripts I publish in the community are largely meant to spark ideas that can be used as building blocks for part of a more robust trade management strategy. Even though this example script beats buy and hold over the back-test time-frame, I wouldn't advise using it as a stand-alone strategy without significant additions/modifications to the strategy and risk management functions. In this example the script is being used as a medium-term strategy with just 10% leverage over account equity, a $25k start balance, and back-testing 10+ years. Modifiable slippage and commissions are included in the model.
Green line = Highest price in the look-back period
Red line = Lowest price in the look-back period
Blue line = EMA Trend
Augmented Dickey–Fuller (ADF) mean reversion testThe augmented Dickey-Fuller test (ADF) is a statistical test for the tendency of a price series sample to mean revert .
The current price of a mean-reverting series may tell us something about the next move (as opposed, for example, to a geometric Brownian motion). Thus, the ADF test allows us to spot market inefficiencies and potentially exploit this information in a trading strategy.
Mathematically, the mean reversion property means that the price change in the next time period is proportional to the difference between the average price and the current price. The purpose of the ADF test is to check if this proportionality constant is zero. Accordingly, the ADF test statistic is defined as the estimated proportionality constant divided by the corresponding standard error.
In this script, the ADF test is applied in a rolling window with a user-defined lookback length. The calculated values of the ADF test statistic are plotted as a time series. The more negative the test statistic, the stronger the rejection of the hypothesis that there is no mean reversion. If the calculated test statistic is less than the critical value calculated at a certain confidence level (90%, 95%, or 99%), then the hypothesis of a mean reversion is accepted (strictly speaking, the opposite hypothesis is rejected).
Input parameters:
Source - The source of the time series being tested.
Length - The number of points in the rolling lookback window. The larger sample length makes the ADF test results more reliable.
Maximum lag - The maximum lag included in the test, that defines the order of an autoregressive process being implied in the model. Generally, a non-zero lag allows taking into account the serial correlation of price changes. When dealing with price data, a good starting point is lag 0 or lag 1.
Confidence level - The probability level at which the critical value of the ADF test statistic is calculated. If the test statistic is below the critical value, it is concluded that the sample of the price series is mean-reverting. Confidence level is calculated based on MacKinnon (2010) .
Show Infobox - If True, the results calculated for the last price bar are displayed in a table on the left.
More formal background:
Formally, the ADF test is a test for a unit root in an autoregressive process. The model implemented in this script involves a non-zero constant and zero time trend. The zero lag corresponds to the simple case of the AR(1) process, while higher order autoregressive processes AR(p) can be approached by setting the maximum lag of p. The null hypothesis is that there is a unit root, with the alternative that there is no unit root. The presence of unit roots in an autoregressive time series is characteristic for a non-stationary process. Thus, if there is no unit root, the time series sample can be concluded to be stationary, i.e., manifesting the mean-reverting property.
A few more comments:
It should be noted that the ADF test tells us only about the properties of the price series now and in the past. It does not directly say whether the mean-reverting behavior will retain in the future.
The ADF test results don't directly reveal the direction of the next price move. It only tells wether or not a mean-reverting trading strategy can be potentially applicable at the given moment of time.
The ADF test is related to another statistical test, the Hurst exponent. The latter is available on TradingView as implemented by balipour , QuantNomad and DonovanWall .
The ADF test statistics is a negative number. However, it can take positive values, which usually corresponds to trending markets (even though there is no statistical test for this case).
Rigorously, the hypothesis about the mean reversion is accepted at a given confidence level when the value of the test statistic is below the critical value. However, for practical trading applications, the values which are low enough - but still a bit higher than the critical one - can be still used in making decisions.
Examples:
The VIX volatility index is known to exhibit mean reversion properties (volatility spikes tend to fade out quickly). Accordingly, the statistics of the ADF test tend to stay below the critical value of 90% for long time periods.
The opposite case is presented by BTCUSD. During the same time range, the bitcoin price showed strong momentum - the moves away from the mean did not follow by the counter-move immediately, even vice versa. This is reflected by the ADF test statistic that consistently stayed above the critical value (and even above 0). Thus, using a mean reversion strategy would likely lead to losses.
Mean Reversion Strategy v2 [KL]Description :
This strategy will enter a position when the following conditions are met:
a) Main signal: When source data (ATR) diverts from its moving average value, and
b) Confirmation: If predicted direction of trend is favorable.
Assumptions :
During periods of high price volatility, ATR diverts from its moving average value. Eventually, ATR should revert. But since just knowing the magnitude of increase/decrease of ATR does not indicate a trend signal, we need to introduce a model to predict the current trend.
In short:
• Trend Prediction : This strategy calculates the expected logarithmic return of the security (the "Drift") and considers prices to be moving in uptrend if the drift curve is upward sloping.
• Assessment of ATR diversion : To determine "yes/no" regarding whether ATR at a given point in time has diverted, this script conducts a two-tailed hypothesis test at each candlestick period. The null hypothesis (H0) is that the fast moving average value should equal the slow moving average value (say, denoted as H0: atr14 == atr28; it is assumed that atr28 is more meaningful for the purpose of describing the current trend because it has a larger sample size). Investopedia has an article summarizing this topic .
Exit Condition :
When trailing stop loss hits.
Previous version :
This strategy is based on Version 1 published back in September . This older version considers +/- one standard deviation to be the critical values relative to average ATR when testing whether ATR has diverted from the mean. This does not take Standard Error ("SE") into account. As a result, the threshold is often too wide and it generates too many entry signals.
Percentile Rank [racer8]The Percentile is a mathematical tool developed in the field of statistics. It determines how a value compares to a set of values.
There are many applications for this like ...
... determining your rank in your college math class
... your rank in terms of height, weight, economic status, etc.
... determining the 3-month percentile of the current stock price (which is what this indicator performs)
This indicator calculates the percentile rank for the current stock price for n periods.
For example, if the stock's current price is above 80% of the previous stock's prices over a 100-period span, then it has a percentile rank of 80.
For traders, this is extremely valuable information because it tells you if the current stock price is overbought or oversold.
If the stock's price is in the 95th percentile, then it is highly likely that it is OVERBOUGHT, and that it will revert back to the mean price.
Helplful TIP: I recommend that you set the indicator to look back over at LEAST 100 periods for accuracy!
Thanks for reading! 👍
Volume Breakout (ValueRay)Easy visuals on, if volume is way over average. Good for Mean Reverting. Higher Volume tends to higher breakout chances.
Please whisper me for for ideas how to make this better. Its a very simple script, but got some alpha. If you know how to improve, let me know and i will code it into.
Bitcoin - CME Futures Friday Close
This indicator displays the weekly Friday closing price according to the CME trading hours (Friday 4pm CT).
A horizontal line is displayed until the CME opens again on Sunday 5pm CT.
This indicator is based on the thesis, that during the weekend the Bitcoin price tends to mean reverse to the CME closing price of the prior Friday. The level can also act as support/resistance. This indicator gives a visualization of this key level for the relevant time window.
Furthermore the indicator helps to easily identify, if there is an up or down gap in the CME Bitcoin contract.
[KL] Mean Reversion (ATR) StrategyThis strategy will enter into a position when price volatility is relative high, betting that price will subsequently trend in a favourable direction.
Hypothesis : During periods of high price volatility, ATR will divert from its moving average by at least +/- one standard deviation. Eventually, ATR will revert back to the mean. However, just knowing the magnitude of increase/decrease of ATR does not give a trend signal, so we need to introduce a model in this script to predict whether the next bars will be up/down.
Trend Prediction : This strategy calculates the expected logarithmic return of the security (the "Drift") and considers prices to be moving in uptrend if the drift curve is upward sloping or if the drift value is positive.
Entry Conditions : Long position is entered when:
(a) ATR has diverted from mean by one standard deviation, and
(b) trend is predicted to move in our favor.
Exit Condition : When trailing stop loss is hit.
Results from backtesting against VOO (1H timeframe):
- approx 46% win rate over 491 trades, on average holding for 20 hours per trade
- price at the beginning of backtest (Jan. 2015) was $187.52, giving holding period return of ~120% had we not sold in between ("HPR of HODL'ing")
- this strategy gained ~159%, exceeding ~120% HPR of HODL'ing