Short Term RSI and SMA Percentage ChangeThis strategy utilises common indicators like RSI and moving averages in order to enter and exit trades. The Relative Strength Index (RSI) is a momentum indicator that has a value between 0 and 100, where a value greater than 70 is considered overbought and a value less than 30 is oversold. If the RSI value is above or below these values, then it can signal a possible trend reversal.
The second indicator used in this strategy is the Simple Moving Average (SMA). A SMA is an arithmetic moving average calculated by adding recent prices and then dividing that figure by the number of time periods in the calculation average. For example, one could add the closing price of a coin for a number of time periods and then divide this total by that same number of periods. Short-term averages respond quickly to changes in the price of the underlying coin, while long-term averages are slower to react.
Long/Exit orders are placed when three basic signals are triggered.
Long Position:
RSI is greater than 50
MA9 is greater than MA100
MA9 increases by 6%
Exit Position:
Price increases 5% trailing
Price decreases 5% trailing
The script is backtested from 1 May 2022 and provides good returns.
A trading fee of 0.1% is also taken into account and is aligned to the base fee applied on Binance.
This script also works well on AVAX 45m/1h, MATIC 15m/45m/1h and ETH 4h.
Indice de force relative (RSI)
PrevHighLow Trend IndicatorPrevHighLow Trend Indicator which is calculated by using prev lowest and highest of p1 -period and p2 -period for two MAs.
First MA is made of prev highest of p1-period / prev lowest of p1-period.
Second MA is faster, made up of p2(<p1)- period(same formula).
Can be used in the next way: slower MA(straight line) shows main trend, faster shows temporary trend.
BUY, when first MA and second MA are green; Exit: second MA changes from green to red.
SELL, when first MA and second MA are red; Exit: second MA changes from red to green.
RSI Assistant basically filtres signals in the way, when signals from RSI and Faster MA are similar? it signals about it with labels: BUY for long, SELL for short. You can either enable or disable it. Also customizable so you can find your setup. RSI Assistant, depending on you customize it, can help you either follow trend or show reversals. Just find your own setup and watch things happen!
Feel free to leave valuable feedback and your setups which you consider to be good.
Hope you PHLTI usefull. Good luck!
Ultimate RSI - Divergence + S/R + Reverse RSIThis is a modification of the TradingView RSI with some of my favourite RSI features added.
This includes Divergence indicators. EMA with colour change on cross, Support and resistance lines and reverse RSI.
A reverse calc has also been added. This will allow you to input 3 different RSI values for a price prediction. This is good to use with the support and resistance lines and can give you key areas on the chart where the price may bounce/reject.
All colours and modifications can be turned on/off.
Enjoy! :)
PlanB Quant Investing 101 v2This script has been Inspired by PlanB Article Quant Investing 101.
With this script, I implemented Plan B strategy outlined in that article, trying to reproduce his findings independently and allowing TradeView Users to do the same.
PlabB is aware of this effort, and he's positive about it, via Twitter commenting, liking and sharing of this resource .
Trading Idea:
This script uses RSI index to determine the Buy And Sell signal.
As per the original PlanB article:
IF ( RSI was above 90% last six months AND drops below 65%) THEN sell,
IF ( RSI was below 50% last six months AND jumps +2% from the low) THEN buy, ELSE hold
My simple code is aimed at replicating his study in Pine so that every TV user can check his signal.
Multi Type RSI [Misu]█ This Indicator is based on RSI ( Relative Strength Index ) & multiple type of MA (Moving Average) to show different variations of RSI.
The relative strength index (RSI) is a momentum indicator used in technical analysis to evaluate overvalued or undervalued conditions in the price of that security.
█ Usages:
The purpose of this indicator is to obtain the RSI calculated with different MAs modes instead of the classic RMA.
The red and green zones indicate the oversold and overbought zones.
Buy or sell signals are marked by the green and red circles
We have 2 different signal modes : when the different size RSIs cross and when the fast RSI crosses the extreme bands.
Alerts are setup.
█ Parameters:
Lenght RSI: The lenght of the RSI. (14 by default)
RSI MA Type: The type of MA with which the rsi will be calculated. ("SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA")
Fast Lenght MA: The fast lenght smoothing MA.
Slow Lenght MA: The Slow lenght smoothing MA.
Lower Band: The lenght of the lower band. (25 by default)
Upper Band: The lenght of the upper band. (75 by default)
Signal Type: The mode with which buy and sell signals are triggered. ("Cross 2 Mas", "Cross Ma/Bands")
Commodity Channel Relative StrengthNew concept(I think atleast) I've joined the Standard RSI and CCI at the hip with another plotcandle, which gives a picture of a larger candle With more interesting movement imo. Includes Fib Retracement Levels, High/Low and a couple of coppock curves for more confirmation. Broadening candles seem to indicate a weakening of trend strength (from what i've seen atleast) although exceptions do occur. Vice versa for tapering to a lesser degree I imagine. RSI has been shifted down to 0 to align the center point with the CCI , so the usual 30/70 RSI Levels are now -20/20 (although I have 30/-30 instead for the hlines).
CRSI - EddyBased on Cyclic Smoothed Relative Strength Indicator v2 by WhenToTrade
The cyclic smoothed RSI indicator is an enhancement of the classic RSI , adding
- additional smoothing according to the market vibration,
- adaptive upper and lower bands according to the cyclic memory and
- using the current dominant cycle length as input for the indicator.
The cRSI is used like a standard indicator but I've added bar colors and reduced the period minimum to 1.
The default settings uses period of 4.
Bar colors explanation:
Yellow = Bullish cross up of crsi and ub
Lime = bullish continuation
Fuchsia = Cross down of crsi and ub
Red = Cross down of crsi and db
Black = Bearish continuation
ub = aqua line high
db = aqua line low
crsi = fuchsia line representing smoothed RSI
Enjoy!
Ichimoku Cloud with RSI (By Coinrule)The Ichimoku Cloud is a collection of technical indicators that show support and resistance levels, as well as momentum and trend direction. It does this by taking multiple averages and plotting them on a chart. It also uses these figures to compute a “cloud” that attempts to forecast where the price may find support or resistance in the future.
The Ichimoku Cloud was developed by Goichi Hosoda, a Japanese journalist, and published in the late 1960s. It provides more data points than the standard candlestick chart. While it seems complicated at first glance, those familiar with how to read the charts often find it easy to understand with well-defined trading signals.
The Ichimoku Cloud is composed of five lines or calculations, two of which comprise a cloud where the difference between the two lines is shaded in.
The lines include a nine-period average, a 26-period average, an average of those two averages, a 52-period average, and a lagging closing price line.
The cloud is a key part of the indicator. When the price is below the cloud, the trend is down. When the price is above the cloud, the trend is up.
The above trend signals are strengthened if the cloud is moving in the same direction as the price. For example, during an uptrend, the top of the cloud is moving up, or during a downtrend, the bottom of the cloud is moving down.
This strategy combines the Ichimoku Cloud with the RSI indicator to better enter trades.
Long/Short orders are placed when three basic signals are triggered.
Long Position:
Tenkan-Sen is above the Kijun-Sen
Chikou-Span is above the close of 26 bars ago
Close is above the Kumo Cloud
RSI is greater less than 50
Short Position:
Tenkan-Sen is below the Kijun-Sen
Chikou-Span is below the close of 26 bars ago
Close is below the Kumo Cloud
RSI is greater than 50
The script is backtested from 1 June 2022 and provides good returns.
The strategy assumes each order is using 30% of the available coins to make the results more realistic and to simulate you only ran this strategy on 30% of your holdings. A trading fee of 0.1% is also taken into account and is aligned to the base fee applied on Binance.
This script also works well on SOL (45m timeframe), BNB (1h timeframe), and ETH (1h timeframe).
Variety RSI of Fast Discrete Cosine Transform [Loxx]Variety RSI of Fast Discrete Cosine Transform is an RSI indicator with 7 types of RSI that is calculated on the Fast Discrete Cosine Transform of source. The source inputs are 33 different source types from Loxx's Expanded Source Types.
What is Discrete Cosine Transform?
A discrete cosine transform (DCT) expresses a finite sequence of data points in terms of a sum of cosine functions oscillating at different frequencies. The DCT, first proposed by Nasir Ahmed in 1972, is a widely used transformation technique in signal processing and data compression. It is used in most digital media, including digital images (such as JPEG and HEIF, where small high-frequency components can be discarded), digital video (such as MPEG and H.26x), digital audio (such as Dolby Digital, MP3 and AAC), digital television (such as SDTV, HDTV and VOD), digital radio (such as AAC+ and DAB+), and speech coding (such as AAC-LD, Siren and Opus). DCTs are also important to numerous other applications in science and engineering, such as digital signal processing, telecommunication devices, reducing network bandwidth usage, and spectral methods for the numerical solution of partial differential equations.
Fast Discrete Cosine Transform
The algorithm performs a fast cosine transform of the real function defined by nn samples on the real axis.
Depending on the passed parameters, it can be executed both direct and inverse conversion.
Input parameters:
tnn - Number of function values minus one. Should be 1024 degree of two. The algorithm does not check correct value passed.
a - array of Real 1025 Function values.
InverseFCT - the direction of the transformation. True if reverse, False if direct.
Output parameters: a - the result of the transformation. For more details, see description on the site. www.alglib.net
Included:
7 types of RSI
33 source inputs from Loxx's Expanded Source Types
2 types of signals
Alerts
2 Ema Pullback StrategyHi everyone!
CAUTION... This is only an indicator. Do not rely 100% on it.
I made this indicator hoping to help everyone with this specific Pull Back Scalping Strategy.
RULES:
Time Chart of 5minuts
LONG Condition - "EMA Red Line" below the "EMA Blue Line" and wait for a green long signal.
SHORT Condition - "EMA Red Line" below the "EMA Blue Line" and wait for a red short signal
Feel free to add any adjustments or give feedback so we can improve.
The strategy idea and guidelines came from "The Master" Juan Luis.
Autor: © Germangroa
STD-Filtered Variety RSI of Double Averages w/ DSL [Loxx]STD-Filtered Variety RSI of Double Averages w/ DSL is a standard deviation step filtered RSI indicator that is calculated using double smoothing. The user can choose from 8 different RSI types and 38 different double smoothing types. This indicator uses Discontinued Signal Lines instead of regular signals and levels. This allows the signals to be more precise in catching early trend breakouts and breakdowns.
Things to note
Double smoothing of the source does not function like DEMA, for example. This double smoothing is just smoothing of smoothing of source
There are two types of smoothing for Discontinued Signals Lines: Regular EMA and Fast EMA
T3 RSI has been added on top of Loxx's Variety RSI library
Contained inside this indicator
Loxx's Moving Averages
Loxx's Variety RSI
Related indicators
Corrected RSI w/ Floating Levels
Adaptive, Jurik-Filtered, Floating RSI
Variety RSI w/ Dynamic Zones
Included
Bar coloring
Alerts
2 types of signals with precision adjustment
Loxx's Variety RSI
Loxx's Moving Averages
Crypto Breakout IndicatorHey Guys,
The idea of the script is that accumalation and small pumps do happen before the big ones, therefore, i tried to create a breakout indicator that can tell that:
the script components are:
1- Price to consolidate within 15% range between the highest of 6 candles and lowest of 6 candles
2- Price needs to breakout with minimum of 1% and maximum of 20%
3- Price needs to have sufficient volume, hence volume of current bar needs to be higher than previous one with 10% at least
4- RSI needs to be between 50 and 75
5- Bollinger Bands Percentage needs to be equal or lower than 1
6- Price is closing above EMA200
I tried to make all these numbers to be available for you guys through settings so you can tell me about any better settings!
Fourier Extrapolator of Variety RSI w/ Bollinger Bands [Loxx]Fourier Extrapolator of Variety RSI w/ Bollinger Bands is an RSI indicator that shows the original RSI, the Fourier Extrapolation of RSI in the past, and then the projection of the Fourier Extrapolated RSI for the future. This indicator has 8 different types of RSI including a new type of RSI called T3 RSI. The purpose of this indicator is to demonstrate the Fourier Extrapolation method used to model past data and to predict future price movements. This indicator will repaint. If you wish to use this for trading, then make sure to take a screenshot of the indicator when you enter the trade to save your analysis. This is the first of a series of forecasting indicators that can be used in trading. Due to how this indicator draws on the screen, you must choose values of npast and nfut that are equal to or less than 200. this is due to restrictions by TradingView and Pine Script in only allowing 500 lines on the screen at a time. Enjoy!
What is Fourier Extrapolation?
This indicator uses a multi-harmonic (or multi-tone) trigonometric model of a price series xi, i=1..n, is given by:
xi = m + Sum( a*Cos(w*i) + b*Sin(w*i), h=1..H )
Where:
xi - past price at i-th bar, total n past prices;
m - bias;
a and b - scaling coefficients of harmonics;
w - frequency of a harmonic ;
h - harmonic number;
H - total number of fitted harmonics.
Fitting this model means finding m, a, b, and w that make the modeled values to be close to real values. Finding the harmonic frequencies w is the most difficult part of fitting a trigonometric model. In the case of a Fourier series, these frequencies are set at 2*pi*h/n. But, the Fourier series extrapolation means simply repeating the n past prices into the future.
This indicator uses the Quinn-Fernandes algorithm to find the harmonic frequencies. It fits harmonics of the trigonometric series one by one until the specified total number of harmonics H is reached. After fitting a new harmonic , the coded algorithm computes the residue between the updated model and the real values and fits a new harmonic to the residue.
see here: A Fast Efficient Technique for the Estimation of Frequency , B. G. Quinn and J. M. Fernandes, Biometrika, Vol. 78, No. 3 (Sep., 1991), pp . 489-497 (9 pages) Published By: Oxford University Press
The indicator has the following input parameters:
src - input source
npast - number of past bars, to which trigonometric series is fitted;
Nfut - number of predicted future bars;
nharm - total number of harmonics in model;
frqtol - tolerance of frequency calculations.
Included:
Loxx's Expanded Source Types
Loxx's Variety RSI
Other indicators using this same method
Fourier Extrapolator of Price w/ Projection Forecast
Fourier Extrapolator of Price
Polynomial-Regression-Fitted RSI [Loxx]Polynomial-Regression-Fitted RSI is an RSI indicator that is calculated using Polynomial Regression Analysis. For this one, we're just smoothing the signal this time. And we're using an odd moving average to do so: the Sine Weighted Moving Average. The Sine Weighted Moving Average assigns the most weight at the middle of the data set. It does this by weighting from the first half of a Sine Wave Cycle and the most weighting is given to the data in the middle of that data set. The Sine WMA closely resembles the TMA (Triangular Moving Average). So we're trying to tease out some cycle information here as well, however, you can change this MA to whatever soothing method you wish. I may come back to this one and remove the point modifier and then add preliminary smoothing, but for now, just the signal gets the smoothing treatment.
What is Polynomial Regression?
In statistics, polynomial regression is a form of regression analysis in which the relationship between the independent variable x and the dependent variable y is modeled as an nth degree polynomial in x. Polynomial regression fits a nonlinear relationship between the value of x and the corresponding conditional mean of y, denoted E(y |x). Although polynomial regression fits a nonlinear model to the data, as a statistical estimation problem it is linear, in the sense that the regression function E(y | x) is linear in the unknown parameters that are estimated from the data. For this reason, polynomial regression is considered to be a special case of multiple linear regression .
Included
Alerts
Signals
Bar coloring
Loxx's Expanded Source Types
Loxx's Moving Averages
Other indicators in this series using Polynomial Regression Analysis.
Poly Cycle
PA-Adaptive Polynomial Regression Fitted Moving Average
Polynomial-Regression-Fitted Oscillator
RSI Improved strategySet a Horizontal Ray at the price that relates highest / lowest RSI .
It 's more clear to decide when to open long / short position manually.
It's a scalping strategy that works in 15min chart(basically works in most of timeframe , if you don't look it as a scalping strategy), when RSI hits Highest / Lowest value , the strategy will open a Long / Short position.
The Default Risk Reward Ratio was 1 (1600 points : 1600 points) you can adjust it in settings
You guys can look it as a RSI alert indicator
Think before you do , use it wisely. Thanks a lot!
There is a lot of useless words in Pine if you wanna look it please ignore it.
PharshK RSI and Zigzag with H/LIt is with RSI level
and Zigzag Pattern that Market goes on Maximum level and Lower Level
And it is also Showing High and Law Level of last Moving Candle so it is easy to entry and Hold
PharshK RSI and Zigzag with H/LIt is with RSI level
and Zigzag Pattern that Market goes on Maximum level and Lower Level
And it is also Showing High and Law Level of last Moving Candle so it is easy to entry and Hold
Non-Lag Inverse Fisher Transform of RSX [Loxx]Non-Lag Inverse Fisher Transform of RSX is an Inverse Fisher Transform on the Non-Lagged Smoothing Filter of Jurik RSX.
What is the Inverse Fisher Transform?
The Inverse Fisher Transform was authored by John Ehlers. The IFT applies some math functions and constants to a moving average of the relative strength index (rsi) of the closing price to calculate its oscillator position. T
read more here: www.mesasoftware.com
What is RSX?
RSI is a very popular technical indicator, because it takes into consideration market speed, direction and trend uniformity. However, the its widely criticized drawback is its noisy (jittery) appearance. The Jurk RSX retains all the useful features of RSI , but with one important exception: the noise is gone with no added lag.
What is the Non-lag moving average?
The Non Lag Moving average follows price closely and gives very quick signals as well as early signals of price change. As a standalone Moving Average, it should not be used on its own, but as an additional confluence tool for early signals.
Included:
Alerts
Signals
Bar coloring
Chameleon-RSI by KALADIA RSI that changes color like a Chameleon when in overbought or oversold zones of your liking.
2RSI j15Fast RSI and slow RSI. It turns out something like a double check. At their intersection with the limits it shows either buy or sell.
VHF-Adaptive, Digital Kahler Variety RSI w/ Dynamic Zones [Loxx]VHF-Adaptive, Digital Kahler Variety RSI w/ Dynamic Zones is an RSI indicator with adaptive inputs, Digital Kahler filtering, and Dynamic Zones. This indicator uses a Vertical Horizontal Filter for calculating the adaptive period inputs and allows the user to select from 7 different types of RSI.
What is VHF Adaptive Cycle?
Vertical Horizontal Filter (VHF) was created by Adam White to identify trending and ranging markets. VHF measures the level of trend activity, similar to ADX DI. Vertical Horizontal Filter does not, itself, generate trading signals, but determines whether signals are taken from trend or momentum indicators. Using this trend information, one is then able to derive an average cycle length.
What is Digital Kahler?
From Philipp Kahler's article for www.traders-mag.com, August 2008. "A Classic Indicator in a New Suit: Digital Stochastic"
Digital Indicators
Whenever you study the development of trading systems in particular, you will be struck in an extremely unpleasant way by the seemingly unmotivated indentations and changes in direction of each indicator. An experienced trader can recognise many false signals of the indicator on the basis of his solid background; a stupid trading system usually falls into any trap offered by the unclear indicator course. This is what motivated me to improve even further this and other indicators with the help of a relatively simple procedure. The goal of this development is to be able to use this indicator in a trading system with as few additional conditions as possible. Discretionary traders will likewise be happy about this clear course, which is not nerve-racking and makes concentrating on the essential elements of trading possible.
How Is It Done?
The digital stochastic is a child of the original indicator. We owe a debt of gratitude to George Lane for his idea to design an indicator which describes the position of the current price within the high-low range of the historical price movement. My contribution to this indicator is the changed pattern which improves the quality of the signal without generating too long delays in giving signals. The trick used to generate this “digital” behavior of the indicator. It can be used with most oscillators like RSI or CCI .
First of all, the original is looked at. The indicator always moves between 0 and 100. The precise position of the indicator or its course relative to the trigger line are of no interest to me, I would just like to know whether the indicator is quoted below or above the value 50. This is tantamount to the question of whether the market is just trading above or below the middle of the high-low range of the past few days. If the market trades in the upper half of its high-low range, then the digital stochastic is given the value 1; if the original stochastic is below 50, then the value –1 is given. This leads to a sequence of 1/-1 values – the digital core of the new indicator. These values are subsequently smoothed by means of a short exponential moving average . This way minor false signals are eliminated and the indicator is given its typical form.
What are Dynamic Zones?
As explained in "Stocks & Commodities V15:7 (306-310): Dynamic Zones by Leo Zamansky, Ph .D., and David Stendahl"
Most indicators use a fixed zone for buy and sell signals. Here’ s a concept based on zones that are responsive to past levels of the indicator.
One approach to active investing employs the use of oscillators to exploit tradable market trends. This investing style follows a very simple form of logic: Enter the market only when an oscillator has moved far above or below traditional trading lev- els. However, these oscillator- driven systems lack the ability to evolve with the market because they use fixed buy and sell zones. Traders typically use one set of buy and sell zones for a bull market and substantially different zones for a bear market. And therein lies the problem.
Once traders begin introducing their market opinions into trading equations, by changing the zones, they negate the system’s mechanical nature. The objective is to have a system automatically define its own buy and sell zones and thereby profitably trade in any market — bull or bear. Dynamic zones offer a solution to the problem of fixed buy and sell zones for any oscillator-driven system.
An indicator’s extreme levels can be quantified using statistical methods. These extreme levels are calculated for a certain period and serve as the buy and sell zones for a trading system. The repetition of this statistical process for every value of the indicator creates values that become the dynamic zones. The zones are calculated in such a way that the probability of the indicator value rising above, or falling below, the dynamic zones is equal to a given probability input set by the trader.
To better understand dynamic zones, let's first describe them mathematically and then explain their use. The dynamic zones definition:
Find V such that:
For dynamic zone buy: P{X <= V}=P1
For dynamic zone sell: P{X >= V}=P2
where P1 and P2 are the probabilities set by the trader, X is the value of the indicator for the selected period and V represents the value of the dynamic zone.
The probability input P1 and P2 can be adjusted by the trader to encompass as much or as little data as the trader would like. The smaller the probability, the fewer data values above and below the dynamic zones. This translates into a wider range between the buy and sell zones. If a 10% probability is used for P1 and P2, only those data values that make up the top 10% and bottom 10% for an indicator are used in the construction of the zones. Of the values, 80% will fall between the two extreme levels. Because dynamic zone levels are penetrated so infrequently, when this happens, traders know that the market has truly moved into overbought or oversold territory.
Calculating the Dynamic Zones
The algorithm for the dynamic zones is a series of steps. First, decide the value of the lookback period t. Next, decide the value of the probability Pbuy for buy zone and value of the probability Psell for the sell zone.
For i=1, to the last lookback period, build the distribution f(x) of the price during the lookback period i. Then find the value Vi1 such that the probability of the price less than or equal to Vi1 during the lookback period i is equal to Pbuy. Find the value Vi2 such that the probability of the price greater or equal to Vi2 during the lookback period i is equal to Psell. The sequence of Vi1 for all periods gives the buy zone. The sequence of Vi2 for all periods gives the sell zone.
In the algorithm description, we have: Build the distribution f(x) of the price during the lookback period i. The distribution here is empirical namely, how many times a given value of x appeared during the lookback period. The problem is to find such x that the probability of a price being greater or equal to x will be equal to a probability selected by the user. Probability is the area under the distribution curve. The task is to find such value of x that the area under the distribution curve to the right of x will be equal to the probability selected by the user. That x is the dynamic zone.
Included:
Bar coloring
4 signal types
Alerts
Loxx's Expanded Source Types
Loxx's Moving Averages
Loxx's Variety RSI
Loxx's Dynamic Zones
Bollinger Bands and RSI Short Selling (by Coinrule)The Bollinger Bands are among the most famous and widely used indicators. A Bollinger Band is a technical analysis tool defined by a set of trendlines plotted two standard deviations (positively and negatively) away from a simple moving average ( SMA ) of a security's price, but which can be adjusted to user preferences. They can suggest when an asset is oversold or overbought in the short term, thus provide the best time for buying and selling it.
The relative strength index ( RSI ) is a momentum indicator used in technical analysis . RSI measures the speed and magnitude of a security's recent price changes to evaluate overvalued or undervalued conditions in the price of that security. The RSI can do more than point to overbought and oversold securities. It can also indicate securities that may be primed for a trend reversal or corrective pullback in price. It can signal when to buy and sell. Traditionally, an RSI reading of 70 or above indicates an overbought situation. A reading of 30 or below indicates an oversold condition.
The short order is placed on assets that present strong momentum when it's more likely that it is about to decrease further. The rule strategy places and closes the order when the following conditions are met:
ENTRY
The closing price is greater than the upper standard deviation of the Bollinger Bands
The RSI is less than 70
EXIT
The trade is closed in profit when the RSI is less than 70
Upper standard deviation of the Bollinger Band is greater than the the closing price.
This strategy comes with a stop loss and a take profit, and as you can see by the results, it is well suited for a bear market.
This trade works very well with ETH (1h timeframe), AVA (4h timeframe), and SOL (3h timeframe) and is backtested from the 1 December 2021 to capture how this strategy would perform in a bear market.
To make the results more realistic, the strategy assumes each order to trade 30% of the available capital. A trading fee of 0.1% is taken into account. The fee is aligned to the base fee applied on Binance, which is the largest cryptocurrency exchange.
Poly Cycle [Loxx]This is an example of what can be done by combining Legendre polynomials and analytic signals. I get a way of determining a smooth period and relative adaptive strength indicator without adding time lag.
This indicator displays the following:
The Least Squares fit of a polynomial to a DC subtracted time series - a best fit to a cycle.
The normalized analytic signal of the cycle (signal and quadrature).
The Phase shift of the analytic signal per bar.
The Period and HalfPeriod lengths, in bars of the current cycle.
A relative strength indicator of the time series over the cycle length. That is, adaptive relative strength over the cycle length.
The Relative Strength Indicator, is adaptive to the time series, and it can be smoothed by increasing the length of decreasing the number of degrees of freedom.
Other adaptive indicators based upon the period and can be similarly constructed.
There is some new math here, so I have broken the story up into 5 Parts:
Part 1:
Any time series can be decomposed into a orthogonal set of polynomials .
This is just math and here are some good references:
Legendre polynomials - Wikipedia, the free encyclopedia
Peter Seffen, "On Digital Smoothing Filters: A Brief Review of Closed Form Solutions and Two New Filter Approaches", Circuits Systems Signal Process, Vol. 5, No 2, 1986
I gave some thought to what should be done with this and came to the conclusion that they can be used for basic smoothing of time series. For the analysis below, I decompose a time series into a low number of degrees of freedom and discard the zero mode to introduce smoothing.
That is:
time series => c_1 t + c_2 t^2 ... c_Max t^Max
This is the cycle. By construction, the cycle does not have a zero mode and more physically, I am defining the "Trend" to be the zero mode.
The data for the cycle and the fit of the cycle can be viewed by setting
ShowDataAndFit = TRUE;
There, you will see the fit of the last bar as well as the time series of the leading edge of the fits. If you don't know what I mean by the "leading edge", please see some of the postings in . The leading edges are in grayscale, and the fit of the last bar is in color.
I have chosen Length = 17 and Degree = 4 as the default. I am simply making sure by eye that the fit is reasonably good and degree 4 is the lowest polynomial that can represent a sine-like wave, and 17 is the smallest length that lets me calculate the Phase Shift (Part 3 below) using the Hilbert Transform of width=7 (Part 2 below).
Depending upon the fit you make, you will capture different cycles in the data. A fit that is too "smooth" will not see the smaller cycles, and a fit that is too "choppy" will not see the longer ones. The idea is to use the fit to try to suppress the smaller noise cycles while keeping larger signal cycles.
Part 2:
Every time series has an Analytic Signal, defined by applying the Hilbert Transform to it. You can think of the original time series as amplitude * cosine(theta) and the transformed series, called the quadrature, can be thought of as amplitude * sine(theta). By taking the ratio, you can get the angle theta, and this is exactly what was done by John Ehlers in . It lets you get a frequency out of the time series under consideration.
Amazon.com: Rocket Science for Traders: Digital Signal Processing Applications (9780471405672): John F. Ehlers: Books
It helps to have more references to understand this. There is a nice article on Wikipedia on it.
Read the part about the discrete Hilbert Transform:
en.wikipedia.org
If you really want to understand how to go from continuous to discrete, look up this article written by Richard Lyons:
www.dspguru.com
In the indicator below, I am calculating the normalized analytic signal, which can be written as:
s + i h where i is the imagery number, and s^2 + h^2 = 1;
s= signal = cosine(theta)
h = Hilbert transformed signal = quadrature = sine(theta)
The angle is therefore given by theta = arctan(h/s);
The analytic signal leading edge and the fit of the last bar of the cycle can be viewed by setting
ShowAnalyticSignal = TRUE;
The leading edges are in grayscale fit to the last bar is in color. Light (yellow) is the s term, and Dark (orange) is the quadrature (hilbert transform). Note that for every bar, s^2 + h^2 = 1 , by construction.
I am using a width = 7 Hilbert transform, just like Ehlers. (But you can adjust it if you want.) This transform has a 7 bar lag. I have put the lag into the plot statements, so the cycle info should be quite good at displaying minima and maxima (extrema).
Part 3:
The Phase shift is the amount of phase change from bar to bar.
It is a discrete unitary transformation that takes s + i h to s + i h
explicitly, T = (s+ih)*(s -ih ) , since s *s + h *h = 1.
writing it out, we find that T = T1 + iT2
where T1 = s*s + h*h and T2 = s*h -h*s
and the phase shift is given by PhaseShift = arctan(T2/T1);
Alas, I have no reference for this, all I doing is finding the rotation what takes the analytic signal at bar to the analytic signal at bar . T is the transfer matrix.
Of interest is the PhaseShift from the closest two bars to the present, given by the bar and bar since I am using a width=7 Hilbert transform, bar is the earliest bar with an analytic signal.
I store the phase shift from bar to bar as a time series called PhaseShift. It basically gives you the (7-bar delayed) leading edge the amount of phase angle change in the series.
You can see it by setting
ShowPhaseShift=TRUE
The green points are positive phase shifts and red points are negative phase shifts.
On most charts, I have looked at, the indicator is mostly green, but occasionally, the stock "retrogrades" and red appears. This happens when the cycle is "broken" and the cycle length starts to expand as a trend occurs.
Part 4:
The Period:
The Period is the number of bars required to generate a sum of PhaseShifts equal to 360 degrees.
The Half-period is the number of bars required to generate a sum of phase shifts equal to 180 degrees. It is usually not equal to 1/2 of the period.
You can see the Period and Half-period by setting
ShowPeriod=TRUE
The code is very simple here:
Value1=0;
Value2=0;
while Value1 < bar_index and math.abs(Value2) < 360 begin
Value2 = Value2 + PhaseShift ;
Value1 = Value1 + 1;
end;
Period = Value1;
The period is sensitive to the input length and degree values but not overly so. Any insight on this would be appreciated.
Part 5:
The Relative Strength indicator:
The Relative Strength is just the current value of the series minus the minimum over the last cycle divided by the maximum - minimum over the last cycle, normalized between +1 and -1.
RelativeStrength = -1 + 2*(Series-Min)/(Max-Min);
It therefore tells you where the current bar is relative to the cycle. If you want to smooth the indicator, then extend the period and/or reduce the polynomial degree.
In code:
NewLength = floor(Period + HilbertWidth+1);
Max = highest(Series,NewLength);
Min = lowest(Series,NewLength);
if Max>Min then
Note that the variable NewLength includes the lag that comes from the Hilbert transform, (HilbertWidth=7 by default).
Conclusion:
This is an example of what can be done by combining Legendre polynomials and analytic signals to determine a smooth period without adding time lag.
________________________________
Changes in this one : instead of using true/false options for every single way to display, use Type parameter as following :
1. The Least Squares fit of a polynomial to a DC subtracted time series - a best fit to a cycle.
2. The normalized analytic signal of the cycle (signal and quadrature).
3. The Phase shift of the analytic signal per bar.
4. The Period and HalfPeriod lengths, in bars of the current cycle.
5. A relative strength indicator of the time series over the cycle length. That is, adaptive relative strength over the cycle length.