Real-Fast Fourier Transform of Price w/ Linear Regression [Loxx]Real-Fast Fourier Transform of Price w/ Linear Regression is a indicator that implements a Real-Fast Fourier Transform on Price and modifies the output by a measure of Linear Regression. The solid line is the Linear Regression Trend of the windowed data, The green/red line is the Real FFT of price.
What is the Discrete Fourier Transform?
In mathematics, the discrete Fourier transform (DFT) converts a finite sequence of equally-spaced samples of a function into a same-length sequence of equally-spaced samples of the discrete-time Fourier transform (DTFT), which is a complex-valued function of frequency. The interval at which the DTFT is sampled is the reciprocal of the duration of the input sequence. An inverse DFT is a Fourier series, using the DTFT samples as coefficients of complex sinusoids at the corresponding DTFT frequencies. It has the same sample-values as the original input sequence. The DFT is therefore said to be a frequency domain representation of the original input sequence. If the original sequence spans all the non-zero values of a function, its DTFT is continuous (and periodic), and the DFT provides discrete samples of one cycle. If the original sequence is one cycle of a periodic function, the DFT provides all the non-zero values of one DTFT cycle.
What is the Complex Fast Fourier Transform?
The complex Fast Fourier Transform algorithm transforms N real or complex numbers into another N complex numbers. The complex FFT transforms a real or complex signal x in the time domain into a complex two-sided spectrum X in the frequency domain. You must remember that zero frequency corresponds to n = 0, positive frequencies 0 < f < f_c correspond to values 1 ≤ n ≤ N/2 −1, while negative frequencies −fc < f < 0 correspond to N/2 +1 ≤ n ≤ N −1. The value n = N/2 corresponds to both f = f_c and f = −f_c. f_c is the critical or Nyquist frequency with f_c = 1/(2*T) or half the sampling frequency. The first harmonic X corresponds to the frequency 1/(N*T).
The complex FFT requires the list of values (resolution, or N) to be a power 2. If the input size if not a power of 2, then the input data will be padded with zeros to fit the size of the closest power of 2 upward.
What is Real-Fast Fourier Transform?
Has conditions similar to the complex Fast Fourier Transform value, except that the input data must be purely real. If the time series data has the basic type complex64, only the real parts of the complex numbers are used for the calculation. The imaginary parts are silently discarded.
Inputs:
src = source price
uselreg = whether you wish to modify output with linear regression calculation
Windowin = windowing period, restricted to powers of 2: "4", "8", "16", "32", "64", "128", "256", "512", "1024", "2048"
Treshold = to modified power output to fine tune signal
dtrendper = adjust regression calculation
barsback = move window backward from bar 0
mutebars = mute bar coloring for the range
Further reading:
Real-valued Fast Fourier Transform Algorithms IEEE Transactions on Acoustics, Speech, and Signal Processing, June 1987
Related indicators utilizing Fourier Transform
Fourier Extrapolator of Variety RSI w/ Bollinger Bands
Fourier Extrapolation of Variety Moving Averages
Fourier Extrapolator of Price w/ Projection Forecast
Trend
Ultimate IndicatorThis is a combination of all the price chart indicators I frequently switch between. It contains my day time highlighter (for day trading), multi-timeframe long-term trend indicator for current commodity in the bottom right, customizable trend EMA which also has multi-timeframe drawing capabilities, VWAP, customizable indicators with separate settings from the trend indicator including: EMA, HL2 over time, Donchian Channels, Keltner Channels, Bollinger Bands, and Super Trend. The settings for these are right below the trend settings and can have their length and multiplier adjusted. All of those also have multi-timeframe capabilities separate from the trend multi-time settings.
The Day Trade Highlight option will draw faint yellow between 9:15-9:25, red between 9:25-9:45, yellow between 9:45-10:05. There will be one white background at 9:30am to show the opening of the market. while the market is open there will be a very faint blue background. For the end of the day there will be yellow between 15:45-15:50, red between 15:50-16:00, and yellow between 16:00-16:05. During the night hours, there is no coloring. The purpose of this highlight is to show the opening / closing times of the market and the hot times for large moves.
The indicators can also be colored in the following ways:
1. Simple = Makes all colors for the indicator Gray
2. Trend = Will use the Donchian Channels to get the short-trend direction and by default will color the short-term direction as Blue or Red. Unless using Super Trend, the Donchian Channel is used to find short-term trend direction.
3. Trend Adv = Will use the Donchian Channels to get the short-trend direction and by default will color the short-term direction as Blue or Red. Unless using Super Trend, the Donchian Channel is used to find short-term trend direction. If there is a short-term up-trend during a long-term down-trend, the Blue will become Navy. If short-term down-trend during long-term up-trend, the Red will be Brown.
4. Squeeze = Compares the Bollinger Bands width to the Keltner Channels width and will color based on relative squeeze of the market: Teal = no squeeze. Yellow = little squeeze. Red = decent squeeze. White = huge squeeze. if you do not understand this one, try drawing the Bollinger Bands while using the Squeeze color option and it should become more apparent how this works. I also recommend leaving the length and multiplier to the default 20 and 2 if using this setting and only changing the timeframe to get longer/shorter lengths as I've seen that changing the length or multiplier can more or less make it not work at all.
Along with the indicator settings are options to draw lines/labels/fills for the indicator. I enjoy having only fills for a cleaner look.
The Labels option will show Buy/Sell signals when the short-term trend flips to agree with the long-term trend.
The Trend Bars option will do the same as the Labels option but instead will color the bars white when a Buy/Sell option is given.
The Range Bars option shows will color a bar white when the Close of a candle is outside of a respective ranging indicator option (Bollinger or Keltner).
The Trend Bars will draw white candles no matter which indicator selection you make (even "Off"). However, Range Bars will only draw white when either Bollinger or Keltner are selected.
The Donchian Channels and Super Trend are trending indicators and should be used during trending markets. I like to use the MACD in conjunction with these indicators for possibly earlier entries.
The Bollinger Bands and Keltner Channel are ranging indicators and should be used during ranging markets. I like to use the RSI in conjunction with these indicators and will use 60/40 for overbought and oversold areas rather than 70/30. During a range, I wait for an overbought or oversold indication and will buy/sell when it crosses back into the middle area and close my position when it touches the opposite band.
I have a MACD/RSI combination indicator if you'd like that as well :D
As always, trade at your own risk. This is not some secret indicator that will 100% win. As always, the trades you see in the picture use a 1:1.5 or 1:2 risk to reward ratio, for today (August 8, 2022) it won 5/6 times with one trade still open at the end of the day. Manage your account correctly and you'll win in the long term. Hit me up with any questions or suggestions. Happy Trading!
Swing Trend StrategyThis script is a trend following system which uses a long term Moving Average to spot the trend in combination with the Average True Range to filter out Fakeouts, limiting the overall drawdown.
Default Settings and Calculation:
- The trend is detected using the Exponential Moving Average on 200 periods.
- The Average True Range is calculated on 10 periods.
- The Market is considered in an Uptrend when the price closes above the EMA + ATR.
- The Market is considered in a Downtrend when the price closes below the EMA - ATR.
- The strategy will open a LONG position when the market is in an Uptrend.
- The strategy will close its LONG positions when the price closes below the EMA.
- The strategy will open a SHORT position when the market is in a Downtrend.
- The strategy will close its SHORT positions when the price closes above the EMA.
This script is best suited for the 4h timeframe, and shows good results on BTC and ETH especially.
The options allow to modify the type of moving average to use, the period of the moving average, the ATR multiplier to add as well as the possibility to open short trades or not.
Strategy - Trend Chaser - PSeTrend Chaser for Philippine Stock Exchange - LONG ONLY
-Elvin Kennedy Latayan 2022
3LS | 3 Line Strike Strategy [Kintsugi Trading]What is the 3LS | 3 Line Strike Strategy?
Incorporating the 3 Line Strike candlestick pattern into our strategy was inspired by Arty at The Moving Average and the amazing traders at TheTrdFloor .
The Three Line Strike is a trend continuation candlestick pattern consisting of four candles. Depending on their heights and collocation, a bullish or a bearish trend continuation can be predicted.
In a symphony of trend analysis, price action, and volume we can find and place high-probability trades with the 3LS Strategy.
How to use it!
----- First, start by choosing a Stop-Loss Strategy, Stop PIP Size, and Risk/Reward Ratio -----
- Stop-Loss Strategy
Fixed PIP Size – This uses the top/bottom of the indicator candle and places a TP based on the chosen Risk:Reward ratio.
ATR Trail (No set Target Profit, only uses ATR Stop)
ATR Trail-Stop (Has set Target Profit, however, stop is based on ATR inputs)
**If you choose an ATR Stop-Loss Strategy - input the desired ATR period and Multiple you would like the stop to be calculated at**
**ATR Stop-Loss Strategies have a unique alert setup for Auto-Trading. See Auto-Trading Section**
- Risk/Reward Ratio = If you have a .5 risk/reward, it means you are risking $100 to make $50.
- Additional Stop PIP Size = Number of PIPs over the default stop location of the top or bottom of the indicator candle.
----- Next, we set the Session Filter -----
Set the Timezone and Trade Session you desire. If no specific session is desired, simply set the Trade Session to 00:00 - 00:00.
----- Next, we set the Moving Average Cloud Fill -----
Enter the Fast and Slow Moving Average Length used to calculate trend direction:
MA Period Fast
MA Period Slow
These inputs will determine whether the strategy looks for Long or Short positions.
----- Next, we set the VSA – Volume Spread Analysis Settings -----
Check the box to show the indicator at the bottom of the chart if desired.
This is just a different visual output of the VSA | Volume Spread Analysis indicator available for free under the community indicators tab. You can add that indicator to your chart and see the same output in candle format.
In combination with the Moving Average Cloud, the Volume Spread Analysis will help us determine when to take a trade and in what direction.
The strategy is essentially looking for small reversals going against the overall trend and placing a trade once that reversal ends and the price moves back in the direction of the overall trend.
The 3LS Strategy utilizes confirmation between trend, volume, and price action to place high probability trades.
The VSA is completely customizable by:
Moving Average Length
MA-1 Multiplier
MA-2 Multiplier
MA-3 Multiplier
Check out the VSA | Volume Spread Analysis indicator in the community scripts section under the indicators tab to use this awesome resource on other strategies.
----- Next, we have the option to view the automated KT Bull/Bear Signals -----
Check the boxes to show the buy-sell signal on the chart if desired.
----- Next, we set the risk we want to use if Auto Trading the strategy -----
I always suggest using no more than 1-3% of your total account balance per trade. Remember, if you have multiple strategies triggering per day with each using 1%, the total percent at risk will be much larger.
For Example – if you have 10 strategies each risking 1% your total risk is 10% of your account, not 1%! Be mindful to only use 1-3% of your total account balance across all strategies, not just each individual one.
----- Finally, we backtest our ideas -----
After using the 'Strategy Tester' tab on TradingView to thoroughly backtest your predictions you are ready to take it to the next level - Automated Trading!
This was my whole reason for creating the script. If you work a full-time job, live in a time zone that is hard to trade, or just don't have the patience, this will be a game-changer for you as it was for me.
Auto-Trading
When it comes to auto-trading this strategy I have included two options in the script that utilize the alert messages generated by TradingView.
*Note: Please trade on a demo account until you feel comfortable enough to use real money, and then please stick to 1%-2% of your total account value in risk per trade.*
AutoView
PineConnector
**ATR Auto-Trading Alert Setup**
How to create alerts on 3 Line Strike Strategy
For Trailing Stops:
1) Adjust autoview/pineconnector settings
2) Click "add alert"
3) Select "Condition" = Strategy Name
4) Select "Order Fills Only" from the drop-down
3) Remove template message text from "message" box and place the exact text. '{{strategy.order.alert_message}}'
4) Click "create"
For Fixed Pip Stop:
1) Adjust autoview/pineconnector settings
2) Click "add alert"
3) Select "Condition" = Strategy Name
4) Select "alert() function calls only"
5) I like to title my Alert Name the same thing I named it as an Indicator Template to keep track
Good luck with your trading!
Refracted EMARefracted EMA is a price based indicator with bands that is built on moving average.
The price range between the bands directly depends on relationship of Average True Range to Moving Average. This gives us very valuable variable constant that changes with the market moves.
So the bands expand and contract due to changes in volatility of the market, which makes this tool very flexible exposing psychological levels.
TF Segmented Polynomial Regression [LuxAlgo]This indicator displays polynomial regression channels fitted using data within a user selected time interval.
The model is fitted using the same method described in our previous script:
Settings
Degree: Degree of the fitted polynomial
Width: Multiplicative factor of the model RMSE. Controls the width of the polynomial regression's channels
Timeframe: Fits the polynomial regression using data within the selected timeframe interval
Show fit for new bars: If selected, will fit the regression model for newly generated bars, else the previous fitted value is displayed.
Src: Input source
Usage
Segmented (or piecewise) models yield multiple fits by first partitioning the data into multiple intervals from specific partitioning conditions. In this script this partitioning condition is for a user selected timeframe to change.
Segmented models can be particularly pertinent for market prices, which often describes a series of local trends.
Segmented polynomial regressions can describe the nature of underlying trends in the price from their fit, such as if an underlying trend is more linear (trending) or constant (ranging), and if a trend is monotonic.
The above chart shows a monthly partitioning on SPX 15m, using a polynomial regression of degree 3. Channel extremities allows highlighting local tops/bottoms.
For real time applications users can choose to fit a current model to incoming price data using the Show fit for new bars settings.
Details
The script does not make use of line.new to display the segmented linear regressions, which allows showing a higher number of historical fits. Each channel extremity as well as the model fit is displayed from the plot function, as such user can more easily set alerts on them.
It is important to note that achieving this requires accessing future price data, as such this script is subject to lookahead bias, historical results differ from the results one could have obtained in real-time.
ADXVMA iTrend [Loxx]ADXVMA iTrend is an iTrend indicator with ADXVMA smoothing. Trend is used to determine where the trend starts and ends. Adjust the period inputs accordingly to suit your backtest requirements. This is also useful for scalping lower timeframes.
What is the ADXvma - Average Directional Volatility Moving Average?
Linnsoft's ADXvma formula is a volatility-based moving average, with the volatility being determined by the value of the ADX indicator.The ADXvma has the SMA in Chande's CMO replaced with an EMA , it then uses a few more layers of EMA smoothing before the "Volatility Index" is calculated.
Included
Bar coloring
Alerts
Signals
Loxx's Expanded Source Types
VHF-Adaptive T3 iTrend [Loxx]VHF-Adaptive T3 iTrend is an iTrend indicator with T3 smoothing and Vertical Horizontal Filter Adaptive period input. iTrend is used to determine where the trend starts and ends. You'll notice that the noise filter on this one is extreme. Adjust the period inputs accordingly to suit your take and your backtest requirements. This is also useful for scalping lower timeframes. Enjoy!
What is VHF Adaptive Period?
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 the T3 moving average?
Better Moving Averages Tim Tillson
November 1, 1998
Tim Tillson is a software project manager at Hewlett-Packard, with degrees in Mathematics and Computer Science. He has privately traded options and equities for 15 years.
Introduction
"Digital filtering includes the process of smoothing, predicting, differentiating, integrating, separation of signals, and removal of noise from a signal. Thus many people who do such things are actually using digital filters without realizing that they are; being unacquainted with the theory, they neither understand what they have done nor the possibilities of what they might have done."
This quote from R. W. Hamming applies to the vast majority of indicators in technical analysis . Moving averages, be they simple, weighted, or exponential, are lowpass filters; low frequency components in the signal pass through with little attenuation, while high frequencies are severely reduced.
"Oscillator" type indicators (such as MACD , Momentum, Relative Strength Index ) are another type of digital filter called a differentiator.
Tushar Chande has observed that many popular oscillators are highly correlated, which is sensible because they are trying to measure the rate of change of the underlying time series, i.e., are trying to be the first and second derivatives we all learned about in Calculus.
We use moving averages (lowpass filters) in technical analysis to remove the random noise from a time series, to discern the underlying trend or to determine prices at which we will take action. A perfect moving average would have two attributes:
It would be smooth, not sensitive to random noise in the underlying time series. Another way of saying this is that its derivative would not spuriously alternate between positive and negative values.
It would not lag behind the time series it is computed from. Lag, of course, produces late buy or sell signals that kill profits.
The only way one can compute a perfect moving average is to have knowledge of the future, and if we had that, we would buy one lottery ticket a week rather than trade!
Having said this, we can still improve on the conventional simple, weighted, or exponential moving averages. Here's how:
Two Interesting Moving Averages
We will examine two benchmark moving averages based on Linear Regression analysis.
In both cases, a Linear Regression line of length n is fitted to price data.
I call the first moving average ILRS, which stands for Integral of Linear Regression Slope. One simply integrates the slope of a linear regression line as it is successively fitted in a moving window of length n across the data, with the constant of integration being a simple moving average of the first n points. Put another way, the derivative of ILRS is the linear regression slope. Note that ILRS is not the same as a SMA ( simple moving average ) of length n, which is actually the midpoint of the linear regression line as it moves across the data.
We can measure the lag of moving averages with respect to a linear trend by computing how they behave when the input is a line with unit slope. Both SMA (n) and ILRS(n) have lag of n/2, but ILRS is much smoother than SMA .
Our second benchmark moving average is well known, called EPMA or End Point Moving Average. It is the endpoint of the linear regression line of length n as it is fitted across the data. EPMA hugs the data more closely than a simple or exponential moving average of the same length. The price we pay for this is that it is much noisier (less smooth) than ILRS, and it also has the annoying property that it overshoots the data when linear trends are present.
However, EPMA has a lag of 0 with respect to linear input! This makes sense because a linear regression line will fit linear input perfectly, and the endpoint of the LR line will be on the input line.
These two moving averages frame the tradeoffs that we are facing. On one extreme we have ILRS, which is very smooth and has considerable phase lag. EPMA has 0 phase lag, but is too noisy and overshoots. We would like to construct a better moving average which is as smooth as ILRS, but runs closer to where EPMA lies, without the overshoot.
A easy way to attempt this is to split the difference, i.e. use (ILRS(n)+EPMA(n))/2. This will give us a moving average (call it IE /2) which runs in between the two, has phase lag of n/4 but still inherits considerable noise from EPMA. IE /2 is inspirational, however. Can we build something that is comparable, but smoother? Figure 1 shows ILRS, EPMA, and IE /2.
Filter Techniques
Any thoughtful student of filter theory (or resolute experimenter) will have noticed that you can improve the smoothness of a filter by running it through itself multiple times, at the cost of increasing phase lag.
There is a complementary technique (called twicing by J.W. Tukey) which can be used to improve phase lag. If L stands for the operation of running data through a low pass filter, then twicing can be described by:
L' = L(time series) + L(time series - L(time series))
That is, we add a moving average of the difference between the input and the moving average to the moving average. This is algebraically equivalent to:
2L-L(L)
This is the Double Exponential Moving Average or DEMA , popularized by Patrick Mulloy in TASAC (January/February 1994).
In our taxonomy, DEMA has some phase lag (although it exponentially approaches 0) and is somewhat noisy, comparable to IE /2 indicator.
We will use these two techniques to construct our better moving average, after we explore the first one a little more closely.
Fixing Overshoot
An n-day EMA has smoothing constant alpha=2/(n+1) and a lag of (n-1)/2.
Thus EMA (3) has lag 1, and EMA (11) has lag 5. Figure 2 shows that, if I am willing to incur 5 days of lag, I get a smoother moving average if I run EMA (3) through itself 5 times than if I just take EMA (11) once.
This suggests that if EPMA and DEMA have 0 or low lag, why not run fast versions (eg DEMA (3)) through themselves many times to achieve a smooth result? The problem is that multiple runs though these filters increase their tendency to overshoot the data, giving an unusable result. This is because the amplitude response of DEMA and EPMA is greater than 1 at certain frequencies, giving a gain of much greater than 1 at these frequencies when run though themselves multiple times. Figure 3 shows DEMA (7) and EPMA(7) run through themselves 3 times. DEMA^3 has serious overshoot, and EPMA^3 is terrible.
The solution to the overshoot problem is to recall what we are doing with twicing:
DEMA (n) = EMA (n) + EMA (time series - EMA (n))
The second term is adding, in effect, a smooth version of the derivative to the EMA to achieve DEMA . The derivative term determines how hot the moving average's response to linear trends will be. We need to simply turn down the volume to achieve our basic building block:
EMA (n) + EMA (time series - EMA (n))*.7;
This is algebraically the same as:
EMA (n)*1.7-EMA( EMA (n))*.7;
I have chosen .7 as my volume factor, but the general formula (which I call "Generalized Dema") is:
GD (n,v) = EMA (n)*(1+v)-EMA( EMA (n))*v,
Where v ranges between 0 and 1. When v=0, GD is just an EMA , and when v=1, GD is DEMA . In between, GD is a cooler DEMA . By using a value for v less than 1 (I like .7), we cure the multiple DEMA overshoot problem, at the cost of accepting some additional phase delay. Now we can run GD through itself multiple times to define a new, smoother moving average T3 that does not overshoot the data:
T3(n) = GD ( GD ( GD (n)))
In filter theory parlance, T3 is a six-pole non-linear Kalman filter. Kalman filters are ones which use the error (in this case (time series - EMA (n)) to correct themselves. In Technical Analysis , these are called Adaptive Moving Averages; they track the time series more aggressively when it is making large moves.
Included
Bar coloring
Alerts
Signals
Loxx's Expanded Source Types
Donchian Channels+Standard Donchian Channels, this includes a Trend EMA which can be configured and the channels will use to give buy and sell signals. The channels are also colored in such a way to indicate a trend reversals. My favorite part that sets this apart from others is, if using the bClose option (which I recommend you do) the trend will not reverse until there is a close above/below the previous channel high/low. i.e. a reversal into an uptrend requires the current bar to close above the previous upper channel rather than just a new high.
The coloring of the current trend allows for a quick read of current market conditions and I use this on any timeframe across all forms of charts (forex stock, futures , crypto, etc). When taking one of the signals I use the opposite channel as the stop loss (when buying use bottom, and selling use top channel)
Update 1:
- Added my name to the code
- Updated the picture to show off the indicator better
- Raised the brightness of the fill color a bit, looks nicer I think
As a warning: I have obviously hand picked this picture to really show off this indicator's power to work in a trending market. Donchian Channels are a trending indicator and work best in trending markets with decent pull backs. If there are multiple signals going in each direction, it is a choppy market and you should stay out until it starts trending again. I generally use a 1:1.5 risk to reward ratio but sometimes will stretch it to 1:2 if it is a nice trade and I feel the market is in my favor as you can see from the trades placed in the picture (and I use that method for any commodity / chart and timeframe). I use the close of the white candle and then (since they are trades going short) I use the upper Donchian Channel as my stop loss.
I personally like to have the lines and labels turned off and enable all other options. Labels are just there to really stand out so you don't miss the white candle indication for a trade. OH! Also, I've had comments from friends that the white candles are hard to see, I turn off my candle borders in settings; makes it super easy to see them then. I turn lines off as the fill does the job well enough and it seems cleaner in my eyes.
If you'd like to see this picture on your chart, it is Micro E-Mini S&P 500 Futures from July 10, 2022 @ 18:00 on the 1-min chart.
just now
Update 2:
- Added day trading time highlights
- Added ranging market indicator (This I'm still working on so use at your own discretion, it's intended purpose is to tell when the Donchian Channels are not going to give great signals and to use a ranging indicator instead)
- Added multi-timeframe trend screener (handy if you want to quickly see the trend direction (based on the Trend EMA you set) of several time frames without having to change charts). It will draw in the bottom right of the chart.
Mark MinerviniHi everyone,
Just sharing a script that I made when I began to be interested in Mark Minervini, Wiliam O'Neil, Nicolas Darvas,.. trading style.
This script displays :
- 10 EMA (orange)
- 20 EMA (blue light)
- 50 SMA (blue)
-150 SMA (green)
-200 SMA (red)
- Shows when the stock is "extended" from EMA10 to high of the candle (Works in Daily, you can adjust the % to make it match with the stock's volatility)
(Shows a red area between price and 10 EMA)
- Shows when Mark Minervini's trend template is respected by highlighting green between 150 & 200 SMA.
I Although added bollinger bands and 5 EMA for very strong stocks. (I never use them)
Have fun
EMA Cross CloudSimple ema cross trading alerts, completely customizable fast and slow crossovers with rendered cloud.
This cross indicator attempts to filter counter trend trades by added additional ema market and if crossunder/over occurs opposite of ema market the cloud will turn gray, otherwise if it's with the overall trend then red/green.
The last ema is a trailing stop guideline that is rendered with yellow crosses, could also utilize other stops such as the top or bottom of the cloud.
Alerts are baked in for ema crosses, trend breaks into stops.
Smoothed Heikin Ashi Trend on Chart - TraderHalai BACKTESTSmoothed Heikin Ashi Trend on chart - Backtest
This is a backtest of the Smoothed Heikin Ashi Trend indicator, which computes the reverse candle close price required to flip a Heikin Ashi trend from red to green and vice versa. The original indicator can be found in the scripts section of my profile.
This particular back test uses this indicator with a Trend following paradigm with a percentage-based stop loss.
Note, that backtesting performance is not always indicative of future performance, but it does provide some basis for further development and walk-forward / live testing.
Testing was performed on Bitcoin , as this is a primary target market for me to use this kind of strategy.
Sample Backtesting results as of 10th June 2022:
Backtesting parameters:
Position size: 10% of equity
Long stop: 1% below entry
Short stop: 1% above entry
Repainting: Off
Smoothing: SMA
Period: 10
8 Hour:
Number of Trades: 1046
Gross Return: 249.27 %
CAGR Return: 14.04 %
Max Drawdown: 7.9 %
Win percentage: 28.01 %
Profit Factor (Expectancy): 2.019
Average Loss: 0.33 %
Average Win: 1.69 %
Average Time for Loss: 1 day
Average Time for Win: 5.33 days
1 Day:
Number of Trades: 429
Gross Return: 458.4 %
CAGR Return: 15.76 %
Max Drawdown: 6.37 %
Profit Factor (Expectancy): 2.804
Average Loss: 0.8 %
Average Win: 7.2 %
Average Time for Loss: 3 days
Average Time for Win: 16 days
5 Day:
Number of Trades: 69
Gross Return: 1614.9 %
CAGR Return: 26.7 %
Max Drawdown: 5.7 %
Profit Factor (Expectancy): 10.451
Average Loss: 3.64 %
Average Win: 81.17 %
Average Time for Loss: 15 days
Average Time for Win: 85 days
Analysis:
The strategy is typical amongst trend following strategies with a less regular win rate, but where profits are more significant than losses. Most of the losses are in sideways, low volatility markets. This strategy performs better on higher timeframes, where it shows a positive expectancy of the strategy.
The average win was positively impacted by Bitcoin’s earlier smaller market cap, as the percentage wins earlier were higher.
Overall the strategy shows potential for further development and may be suitable for walk-forward testing and out of sample analysis to be considered for a demo trading account.
Note in an actual trading setup, you may wish to use this with volatility filters, combined with support resistance zones for a better setup.
As always, this post/indicator/strategy is not financial advice, and please do your due diligence before trading this live.
Original indicator links:
On chart version -
Oscillator version -
Update - 27/06/2022
Unfortunately, It appears that the original script had been taken down due to auto-moderation because of concerns with no slippage / commission. I have since adjusted the backtest, and re-uploaded to include the following to address these concerns, and show that I am genuinely trying to give back to the community and not mislead anyone:
1) Include commission of 0.1% - to match Binance's maker fees prior to moving to a fee-less model.
2) Include slippage of 10 ticks (This is a realistic slippage figure from searching online for most crypto exchanges)
3) Adjust account balance to 10,000 - since most of us are not millionaires.
The rest of the backtesting parameters are comparable to previous results:
Backtesting parameters:
Initial capital: 10000 dollars
Position size: 10% of equity
Long stop: 2% below entry
Short stop: 2% above entry
Repainting: Off
Smoothing: SMA
Period: 10
Slippage: 10 ticks
Commission: 0.1%
This script still remains to shows viability / profitablity on higher term timeframes (with slightly higher drawdown), and I have included the backtest report below to document my findings:
8 Hour:
Number of Trades: 1082
Gross Return: 233.02%
CAGR Return: 14.04 %
Max Drawdown: 7.9 %
Win percentage: 25.6%
Profit Factor (Expectancy): 1.627
Average Loss: 0.46 %
Average Win: 2.18 %
Average Time for Loss: 1.33 day
Average Time for Win: 7.33 days
Once again, please do your own research and due dillegence before trading this live. This post is for education and information purposes only, and should not be taken as financial advice.
Nyquist Moving Average (NMA) MACD [Loxx]Nyquist Moving Average (NMA) MACD is a MACD indicator using Nyquist Moving Average for its calculation.
What is the Nyquist Moving Average?
A moving average outlined originally developed by Dr . Manfred G. Dürschner in his paper "Gleitende Durchschnitte 3.0".
In signal processing theory, the application of a MA to itself can be seen as a Sampling procedure. The sampled signal is the MA (referred to as MA.) and the sampling signal is the MA as well (referred to as MA). If additional periodic cycles which are not included in the price series are to be avoided sampling must obey the Nyquist Criterion.
It can be concluded that the Moving Averages 3.0 on the basis of the Nyquist Criterion bring about a significant improvement compared with the Moving Averages 2.0 and 1.0. Additionally, the efficiency of the Moving Averages 3.0 can be proven in the result of a trading system with NWMA as basis.
What is the MACD?
Moving average convergence divergence (MACD) is a trend-following momentum indicator that shows the relationship between two moving averages of a security’s price. The MACD is calculated by subtracting the 26-period exponential moving average (EMA) from the 12-period EMA.
The result of that calculation is the MACD line. A nine-day EMA of the MACD called the "signal line," is then plotted on top of the MACD line, which can function as a trigger for buy and sell signals. Traders may buy the security when the MACD crosses above its signal line and sell—or short—the security when the MACD crosses below the signal line. Moving average convergence divergence (MACD) indicators can be interpreted in several ways, but the more common methods are crossovers, divergences, and rapid rises/falls.
Included
Bar coloring
2 types of signal output options
Alerts
Loxx's Expanded Source Types
RSI Precision Trend Candles [Loxx]RSI Precision Trend Candles is a candle coloring indicator that uses an average range algorithm to determine trend direction. The precision trend algorithm can be used on any calculated output to tease out interesting trend information.
What is RSI?
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 is displayed as an oscillator (a line graph) on a scale of zero to 100. The indicator was developed by J. Welles Wilder Jr. and introduced in his seminal 1978 book, New Concepts in Technical Trading Systems.
Included
Bar coloring
Signals
Alerts
Loxx's Expanded Source Types
MACD + RSI with Trade SignalsThis indicator by default comes with the MACD shown but can be switched to show the RSI instead. Settings for each indicator can also be customized as well as Buy/Sell signals given based on pull back crossovers that follow the 200 EMA of the price Chart. There's an above/below middle fill option you can use but I tend not to but I know some traders like to see when an oscillator is above/below the middle and use it as a trend diretion. By the way, the fourth setting for the MACD (which is 2 by default) is the size of the histogram.
Buy Signal = Price is above the 200 EMA. Current or previous MACD or RSI line is/was below middle line and now crossed above the signal line.
Sell Signal = Price is below the 200 EMA. Current or previous MACD or RSI line is/was above middle line and now crossed below the signal line.
There are alerts for each signal as well (MACD and RSI, both buy and sell).
Feel free to leave a comment regarding issues or suggestions for this indicator or ideas for the next one I should do :)
Price-Filtered Spearman Rank Correl. w/ Floating Levels [Loxx]Price-Filtered Spearman Rank Correl. w/ Floating Levels is a Spearman Rank Correlation indicator with optional source filtering and floating levels.
What is Spearman rank correlation?
Spearman rank correlation, also known as Spearman coefficient is a formula used to identify the strength of the link between two datasets. This coefficient is a method that can be used to assess the strength of a relationship apart from the direction it takes. The formula, named after Charles Spearman, a mathematician, can only be used in circumstances where data can be categorized or put in order, for instance, the highest to the lowest.
For a better understanding of Spearman coefficient, it helps to get a sense of what monotonic function means. There’s a monotonic relationship under these circumstances:
– When the variable values rise together.
– When one variable value rises the other variable value lowers.
– The rate of movement of the variables need not necessarily be constant.
The Spearman correlation coefficient or rs, between +1 and -1, where +1 indicates a perfect strength between variables, while zero shows no association and -1 shows a perfect negative strength.
Spearman rank correlation theory:
A nonparametric (distribution-free) rank statistic proposed by Spearman in 1904 as a measure of the strength of the associations between two variables (Lehmann and D'Abrera 1998). The Spearman rank correlation coefficient can be used to give an R-estimate, and is a measure of monotone association that is used when the distribution of the data make Pearson's correlation coefficient undesirable or misleading.
Included:
Zero-line and signal cross options for bar coloring, signals, and alerts
Alerts
3 Signal types
Loxx's Expanded Source Types
Dynamic Zones Polychromatic Momentum Candles [Loxx]Dynamic Zones Polychromatic Momentum Candles is a candle coloring, momentum indicator that uses Jurik Filtering and Dynamic Zones to calculate the monochromatic color between two colors.
What is Jurik Volty used in the Juirk Filter?
One of the lesser known qualities of Juirk smoothing is that the Jurik smoothing process is adaptive. "Jurik Volty" (a sort of market volatility ) is what makes Jurik smoothing adaptive. The Jurik Volty calculation can be used as both a standalone indicator and to smooth other indicators that you wish to make adaptive.
What is the Jurik Moving Average?
Have you noticed how moving averages add some lag (delay) to your signals? ... especially when price gaps up or down in a big move, and you are waiting for your moving average to catch up? Wait no more! JMA eliminates this problem forever and gives you the best of both worlds: low lag and smooth lines.
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
Loxx's Expanded Source Types
Larry Williams Large Trade Index (LWTI) [Loxx]Larry Williams Large Trade Index (LWTI) is an indicatory by Larry Williams as explained in his book "Trade Stocks and Commodities with the Insiders: Secrets of the COT Report". I've added optional smoothing if you wish to smooth the output.
What is the Larry Williams Large Trade Index (LWTI)?
The original concept was specifically based on Trader (or Market) Sentiment and predicting market reversals. It's calculated as follows:
MovingAvg(Close - Close , bars used in average)/MovingAvg(Range,bars used in average)*50 + 50
Included
Bar coloring
Signals
Alerts
Larry Williams Proxy Index (LWPI) [Loxx]Larry Williams Proxy Index (LWPI) is an indicatory by Larry Williams as explained in his book "Trade Stocks and Commodities with the Insiders: Secrets of the COT Report", pages 129-135. This is an INVERSE indicator, so follow the signals and colors to understand what it's doing. I've added optional smoothing if you wish to smooth the output.
What is the Larry Williams Proxy Index (LWPI)?
The original concept was specifically based on Trader (or Market) Sentiment and predicting market reversals. It's calculated as follows:
MovingAvg(Open-Close, bars used in average)/MovingAvg(Range, bars used in average)*50+50
Included
Bar coloring
Signals
Alerts
pickle financialversion 1.0
A multi-use indicator
FEATURES:
1) Robust VWAP with up to 3 deviations that can be adjusted for Session, Week, Month, Quarter, Year, Decade, Century, Earnings , Dividend, & Split intervals
2) 20 customizable Moving Averages that can be changed to EMAs, SMAs , WMAs, SMMAs, and VWMAs; can also be adjusted to Candle Closes, Highs, Lows, Opens, HLC3, HL2 , OHLC4, & HLCC4
-Praise be lady VWAP
Smoothed Repulse w/ Floating Levels [Loxx]Smoothed Repulse w/ Floating Levels indicator measures and displays the bullish or bearish pressure associated with each price candlestick in the form of a curve.
It is more relevant when compared to price and offers valuable additional information on the feeling and confidence that traders have about the markets.
This version can use one of the 4 basic averages types for smoothing.
Coloring can be chosen depending on :
slope
outer levels cross
middle ("zero") level cross
Since the "repulse" indicator is not limited to known bounds, levels are dynamic — the "zero" value too. That makes it more responsive in the times of elevated volatility. Alerts are triggered based on the color change.
Included:
Bar coloring
Signals
Alerts
Your choice of moving average for smoothing
Auto Trendline Indicator (based on fractals)A tool that automatically draws out trend lines by connecting the most recent fractals.
Description:
The process of manual drawing out trend lines is highly subjective. Many times, we don’t trade what we see, but what we “want to see”. As a result, we draw lines pointing to the direction that we wishfully want price to move towards. While there are no right/wrong ways to draw trend lines, there are, however, systematic/unsystematic ways to draw trend lines. This tool will systematically draw out trend lines based on fractals.
Additional feature:
This tool will also plot out symbols (default symbol “X”) to signify points of crossings. This can be useful for traders considering to use trend lines as part of their trading strategies.
Here is an interesting observation on the price actions of NASDAQ futures on a 5 second chart during regular trading hours on July 14, 2022.
It’s a phenomenon. People like to see straight lines connecting HL/LH, etc., so it's possible for the market as a whole to psychologically react to these lines. However, it is important to note that is is impossible to predict the direction of price. In the case above, price could have tanked below auto-drawn trend line. Fractal based trend lines should only be taken as references and regarded as price levels. No studies have ever proven that the slope of trend lines can indicate price's future direction.
More about fractals:
To understand more about fractals:
www.investopedia.com
www.tradingview.com
Contrary to what it sounds like, fractal in "technical analysis" does not refer to the recursive self-repeating patterns that appear in nature, such as the mesmerizing patterns found in snowflakes. The Fractal Markets Hypothesis claims that market prices exhibit fractal properties over time. Assuming this assertion to be true, then fractals can be used a tool to represent the chaotic movements of price is a simplified manner.
The purpose of this exercise is to take a tool that is readily available (ie. in this case, TradingView’s built-in fractals tool), and to create a newer tool based on it.
Parameters:
Fractal period (denoted as ‘n’ in code): It is the number of bars bounding a high/low point that must be lower/higher than it, respectively, in order for fractal to be considered valid. Period ‘n’ can be adjusted in this tool. Traditionally, chartists pick the value of 5. The longer it is, the less noise seen on the chart, and the pivot point may also be exhibited in higher timeframes. The drawback is that it will increase the period of lag, and it will take more bars to confirm the printed fractal.
Others: Intuitive parameters such as whether to draw historical trend lines, what color to use, which way to extend the lines, and whether or not to show points of crossings.