TASC 2024.11 Ultimate Strength Index█ OVERVIEW
This script implements the Ultimate Strength Index (USI) indicator, introduced by John Ehlers in his article titled "Ultimate Strength Index (USI)" from the November 2024 edition of TASC's Traders' Tips . The USI is a modified version of Wilder's original Relative Strength Index (RSI) that incorporates Ehlers' UltimateSmoother lowpass filter to produce an output with significantly reduced lag.
█ CONCEPTS
Many technical indicators, including the RSI, lag due to their heavy reliance on historical data. John Ehlers reformulated the RSI to substantially reduce lag by applying his UltimateSmoother filter to upward movements ( strength up - SU ) and downward movements ( strength down - SD ) in the time series, replacing the standard process of smoothing changes with rolling moving averages (RMAs). Ehlers' recent works, covered in our recent script publications, have shown that the UltimateSmoother is an effective alternative to other classic averages, offering notably less lag in its response.
Ehlers also modified the RSI formula to produce an index that ranges from -1 to +1 instead of 0 to 100. As a result, the USI indicates bullish conditions when its value moves above 0 and bearish conditions when it falls below 0.
The USI retains many of the strengths of the traditional RSI while offering the advantage of reduced lag. It generally uses a larger lookback window than the conventional RSI to achieve similar behavior, making it suitable for trend trading with longer data lengths. When applied with shorter lengths, the USI's peaks and valleys tend to align closely with significant turning points in the time series, making it a potentially helpful tool for timing swing trades.
█ CALCULATIONS
The first step in the USI's calculation is determining each bar's strength up (SU) and strength down (SD) values. If the current bar's close exceeds the previous bar's, the calculation assigns the difference to SU. Otherwise, SU is zero. Likewise, if the current bar's close is below the previous bar's, it assigns the difference to SD. Otherwise, SD is zero.
Next, instead of the RSI's typical smoothing process, the USI's calculation applies the UltimateSmoother to the short-term average SU and SD values, reducing high-frequency chop in the series with low lag.
Finally, this formula determines the USI value:
USI = ( Ult (SU) − Ult (SD)) / ( Ult (SU) + Ult (SD)),
where Ult (SU) and Ult (SD) are the smoothed average strength up and strength down values.
Tasc
TASC 2024.07 Gaps and Extreme Closes█ OVERVIEW
This script, inspired by Perry Kaufman's article "Trading Opening Gaps and Extreme Closes in Stocks" from the TASC's July 2024 edition of Traders' Tips , provides analytical insights into stock price behaviors following significant price moves. The information about the frequency, pullbacks, and closing patterns of these extreme price movements can aid in developing more effective trading strategies by understanding what to expect during volatile market conditions.
█ CONCEPTS
Perry Kaufman's article investigates the behavior of stock prices following substantial opening gaps and extreme closing moves to identify patterns and expectations that traders can utilize to make informed decisions. The motivation behind the article is to offer traders a more scientific approach to understanding price movements during volatile market conditions, particularly during earnings season or significant economic events. Kaufman's analysis reveals that stock prices have a history of exhibiting certain behaviors after substantial price gaps and extreme closes. This script follows Perry Kaufman's study and helps provide insight into how prices often behave after significant price changes. This analysis can help traders establish price movement expectations and potential strategies for trading such occurrences.
█ CALCULATIONS
Input Parameters:
This script offers users the choice to analyze "Opening Gaps" or "Extreme Closes" for price movements of different predefined magnitudes in a specified direction ("Upward" or "Downward").
Outputs:
Based on the specified inputs, the script performs the following calculations for the active ticker displayed on the chart:
Frequency of Extreme Price Movements : Quantifies the occurrences of directional price movements within predefined percentage ranges.
Average Pullbacks : Computes the average retracement (pullback) from analyzed price movements within each percentage range.
Average Closes : Analyzes the typical closing behavior relative to the directional price movements within each range.
The script organizes the results from these calculations within the table on a separate chart pane, providing users with helpful insights into how a stock historically behaved following significant price movements.
TASC 2024.04 The Ultimate Smoother█ OVERVIEW
This script presents an implementation of the digital smoothing filter introduced by John Ehlers in his article "The Ultimate Smoother" from the April 2024 edition of TASC's Traders' Tips .
█ CONCEPTS
The UltimateSmoother preserves low-frequency swings in the input time series while attenuating high-frequency variations and noise. The defining input parameter of the UltimateSmoother is the critical period , which represents the minimum wavelength (highest frequency) in the filter's pass band. In other words, the filter attenuates or removes the amplitudes of oscillations at shorter periods than the critical period.
According to Ehlers, one primary advantage of the UltimateSmoother is that it maintains zero lag in its pass band and minimal lag in its transition band, distinguishing it from other conventional digital filters (e.g., moving averages ). One can apply this smoother to various input data series, including other indicators.
█ CALCULATIONS
Ehlers derived the UltimateSmoother using inspiration from the design principles he learned from his experience with analog filters , as described in the original publication. On a technical level, the UltimateSmoother's unique response involves subtracting a high-pass response from an all-pass response . At very low frequencies (lengthy periods), where the high-pass filter response has virtually no amplitude, the subtraction yields a frequency and phase response practically equivalent to the input data. At other frequencies, the subtraction achieves filtration through cancellation due to the close similarities in response between the high-pass filter and the input data.
TASC 2024.03 Rate of Directional Change█ OVERVIEW
This script implements the Rate of Directional Change (RODC) indicator introduced by Richard Poster in the "Taming The Effects Of Whipsaw" article featured in the March 2024 edition of TASC's Traders' Tips .
█ CONCEPTS
In his article, Richard Poster discusses an approach to potentially reduce false trend-following strategy entry signals due to whipsaws in forex data. The RODC indicator is central to this approach. The idea behind RODC is that one can characterize market whipsaw as alternating up and down ZigZag segments. By counting the number of up and down segments within a lookback window, the RODC indicator aims to identify if the window contains a significant whipsaw pattern:
RODC = 100 * Segments / Window Size (bars)
Larger RODC values suggest elevated whipsaw in the calculation window, while smaller values signify trending price activity.
█ CALCULATIONS
• For each price bar, the script iterates through the lookback window to identify up and down segments.
• If the price change between subsequent bars within the window is in the direction opposite to the current segment and exceeds the specified threshold , the calculation interprets the condition as a reversal point and the start of a new segment.
• The script uses the number of segments within the window to calculate RODC according to the above formula.
• Finally, the script applies a simple moving average to smoothen the RODC data.
Users can change the length of the lookback window , the threshold value, and the smoothing length in the "Inputs" tab of the script's settings.
TASC 2024.02 Price-Time Filtering█ OVERVIEW
This script implements a price-time trend filter proposed by Alfred François Tagher in the “Trend Identification By Price And Time Filtering” article from the February 2024 edition of TASC's Traders' Tips .
█ CONCEPTS
In his article, Alfred François Tagher proposed a rule set designed to minimize the impact of stochastic price movements, facilitating the identification of larger-scale trends. The rules are:
• If the most recent week's close exceeds the previous week's high, the trend is up.
• If the most recent week's close is below the previous week's low, the trend is down.
• The trend remains unchanged until one of the above conditions occurs.
Similar rules can also apply to monthly bars.
The author argues that this approach integrates characteristics of conventional price action and time dynamics filters, so he refers to it as price-time filtering .
█ CALCULATIONS
This script applies the above price-time filtering rules and offers multiple ways to view the results on a chart:
• In the "Oscillator" view mode, the script counts and displays the number of bars in the uptrend and downtrend.
• In the "Linebreak" view mode, the trend filter is presented in a format resembling a point-and-figure (P&F) chart , with the length of each bar corresponding to the high-low range of the respective trend.
• In both view modes, the script offers bar coloring of the main chart based on the identified trend.
TASC 2023.12 Growth and Value Switching System█ OVERVIEW
This script implements a rotation system for trading value and growth ETFs, as developed by Markos Katsanos and detailed in the article titled 'Growth Or Value?' in TASC's December 2023 edition of Traders' Tips . The purpose of this script is to demonstrate how short-term momentum can be employed to track market trends and provide clarity on when to switch between value and growth.
█ CONCEPTS
The central concept of the presented rotation strategy is based on the observation that the stock market undergoes cycles favoring either growth or value stocks. Consequently, the script introduces a momentum trading system that is designed to switch between value and growth equities based on prevailing market conditions. Specifically tailored for long-term index investors, the system focuses on trading Vanguard's value and growth ETFs ( VTV and VUG ) on a weekly timeframe.
To identify the ETF likely to outperform, the script uses a custom relative strength indicator applied to both VTV and VUG in comparison with an index ( SPY ). To minimize risk and drawdowns during bear markets, when both value and growth experience downtrends, the script employs the author's custom volume flow indicator (VFI) and blocks trades when its reading indicates money outflow . Positions are closed if the relative strength of the current open trade ETF falls below that of the other ETF for two consecutive weeks and is also below its moving average. Additionally, the script implements a stop-loss when the ETF is trading below its 40-week moving average, but only during bear markets.
The script plots the relative strengths of the value and growth equities along with the signals triggered by the aforementioned rules. Information about the current readings of the relative strength and volume flow indicators, along with the current open position, is displayed in a table.
█ CALCULATIONS
The script uses the request.security() function to gather price data for both equities and the reference index. Custom relative strength and volume flow indicators are calculated based on the formulas presented in the original article. By default, the script employs the same parameters for these indicators as proposed in the original article for VTV and VUG on a weekly timeframe.
TASC 2023.11 VAcc█ OVERVIEW
The November 2023 edition of TASC's Traders' Tips features an article titled "VAcc: A Momentum Indicator Based On Velocity And Acceleration" by Scott Cong. This script implements the author's momentum indicator based on simple physics concepts.
█ CONCEPTS
The indicator is named VAcc as it is derived from the average velocity (V) and acceleration (Acc) over a specified lookback period. Consequently, its readings reflect two valuable characteristics of price data: rate (indicating the speed at which the price is moving) and rate of change (indicating whether the price is speeding up or slowing down).
In the article, the author reports that for longer periods, VAcc behaves similarly to the MACD , albeit with a more responsive nature. For shorter periods, VAcc exhibits characteristics reminiscent of the stochastic oscillator , but it trends more prominently and is less prone to overbought/oversold saturation.
To incorporate VAcc into trading strategies, the author suggests considering the following two permutations for the velocity and acceleration data series:
Strong upward condition: Velocity is rising, and acceleration is rising above zero.
Strong downward condition: Velocity is falling, and acceleration is falling.
In the current implementation, the chart displays the average velocity as a line, while the average acceleration is presented as a histogram.
█ CALCULATIONS
The calculation of VAcc involves the following steps:
For the current closing price, C , and for each bar C (i) within a specified lookback period from the current bar, the script calculates velocities, V (i) = ( C - C (i))/i. These velocities are then subjected to an exponential moving average to obtain the smoothed average velocity.
Similarly, for each bar within the lookback period, accelerations are calculated as Acc (i) = ( V - V (i))/i and then averaged without smoothing.
TASC 2023.10 COT Commercials Indicator█ OVERVIEW
This script implements the COT Commercials Indicator introduced by Alfred François Tagher in an article featured in TASC's October 2023 edition of Traders' Tips . The indicator is designed for use in futures markets and represents a fast stochastic (%K) calculated based on the commercial open interest values of an asset derived from the weekly Commitments Of Traders (COT) report .
█ CONCEPTS
The COT report, issued by the Commodity Futures Trading Commission (CFTC) , presents a breakdown of reportable open interest positions held by various trader groups—commercial, noncommercial, and nonreportable (small traders). Open interest reflects the total number of derivative contracts entered by market participants but not yet settled. Consequently, it can serve as a measure of market activity and liquidity.
The indicator showcased here aims to analyze changes in the reported net values of open interest for commercial traders/hedgers (often referred to as 'smart money', as they deal directly in underlying commodities). The net values are positive when the commercial traders have more long positions than short ones and negative when they hold more short positions than long ones. Positive net values indicate that commercial traders hold more long positions than short ones, while negative values indicate the opposite. Thus, overbought and oversold conditions of the COT Commercials Indicator potentially suggest collective bullish and bearish sentiments, respectively.
█ CALCULATIONS
The calculations involve these steps:
1. Net open interest values are extracted from COT data using the LibraryCOT library provided by TradingView.
2. A fast stochastic indicator (%K) is then applied to normalize these net values.
The script also provides an option of calculating and plotting the indicator curve for noncommercial (speculators) open interest.
TASC 2023.08 Channeling Your Inner Chartist█ OVERVIEW
TASC's August 2023 edition of Traders' Tips features an article written by Stella Osoba titled “Using Price Channels.” The article offers a basic look at using price channels, with a primary focus on Donchian channels . Following the article, the script provides an example of how to calculate and utilize the Donchian channel to gain insights into the price behavior and potential trend movements.
█ CONCEPTS
The use of price channels is a long-standing and fundamental charting technique commonly associated with trend-following trading strategies. Price channels help identify the trend on the chart and facilitate trading in its direction. The Donchian channel, in particular, consists of three lines. The upper line is conventionally calculated as the highest high over a specified lookback period, while the lower line is defined as the lowest low over the same period. The central line represents the midpoint between the upper and lower lines.
The Donchian channel provides a simple and intuitive visual representation of price behavior. Breaking through the lower line, for instance, can indicate weakness and selling pressure, while breaking through the upper line can signal buying pressure. By observing these breakout points, one can gain insight into potential beginnings or endings of long-term trends. However, it is important to note that breakouts often lead to price reversals, so they should be carefully evaluated
█ CALCULATIONS
To illustrate a simple Donchian trading system, this script calculates and plots the channel lines, as well as potential entry points for long positions (green triangles) and short positions (red triangles).
TASC 2023.07 Keeping With The Larger Trend█ OVERVIEW
TASC's July 2023 edition of Traders' Tips features an article by Barbara Star titled "Stay On Track With The Supertrend Indicator". The article explores how the supertrend indicator , whether used as a standalone tool or in conjunction with other indicators, can assist traders in aligning with the larger trend. Drawing inspiration from the article, this script enhances the supertrend indicator with additional visual and analytical features, making it easier to analyze the readings and make informed trading decisions.
█ CONCEPTS
Over the past few years, the supertrend indicator has gained significant popularity among traders. Unlike moving averages, it incorporates both price and volatility information, enabling traders to navigate upward or downward trends despite occasional price disruptions.
When using the supertrend indicator, a trader may consider entering a long position when the price surpasses the supertrend line or retraces to it after the initial crossover. Similarly, for short positions, a trader could enter when the price drops below the supertrend line or retests it. Exiting these positions can be triggered by the opposite scenario, such as a price drop below the supertrend line for long positions or a price rise above the supertrend line for short positions. To assist in monitoring the distance between the price and the indicator line, this script introduces the following display features:
Breach levels, representing fractions of the most recent maximum distance.
On-chart signals indicating crossings of the highest and lowest breach levels.
An infobox displaying the average value of the maximum distance.
█ CALCULATIONS
For calculating the supertrend line, this script uses the built-in function ta.supertrend() . Additionally, the script showcases the use of state-of-the-art PineScript® functionality, including methods and tables .
TASC 2023.06 Stochastic Distance Oscillator█ OVERVIEW
This script implements the stochastic distance oscillator (SDO) , a momentum indicator introduced by Vitali Apirine in an article featured in TASC's June 2023 edition of Traders' Tips . The SDO is a variation of the classic stochastic oscillator and is designed to identify overbought and oversold levels, as well as detect bull and bear trend changes.
█ CONCEPTS
Unlike the classic stochastic oscillator, which compares an asset's price to its past price range, the SDO measures the size of the current distance relative to the maximum-minimum distance range over a set number of periods. The current distance is defined as the distance between the current price and the price n periods ago.
The readings of the SDO can be used to identify the following states of the asset price:
Uptrend state: the oscillator crosses over 50 from a non-uptrend state.
Downtrend state: the oscillator crosses under -50 from a non-downtrend state.
Overbought state: the oscillator is in an uptrend and crosses -50 for the first time.
Oversold state: the oscillator is in a downtrend and crosses 50 for the first time.
Trend continuity: the oscillator crosses 0 in the direction of the current trend.
The script indicates these five conditions using on-chart signals and background coloring.
█ CALCULATIONS
The SDO is calculated as follows:
1. Calculate the distance between the current price and the price n periods ago, as well as the maximum and minimum distances for the selected lookback period. The author recommends using one of two values of n , 14 or 40 bars.
2. Calculate the time series % D that represents the relation between the asset's current distance and its distance range over a loockback period:
% D = (Abs(current distance) − Abs(minimum distance)) / (Abs(maximum distance) − Abs(minimum distance)) * 100
3. Use the calculated % D to obtain the SDO:
If the closing price is above the close n periods ago, SDO = % D
If the closing price is below the close n periods ago, SDO = −% D
If the closing price equals the close n periods ago or the current distance equals the minimum distance, SDO = 0
4. Smooth the SDO using an exponential moving average (EMA). The author recommends using an EMA in the range from 3 to 6 .
Adjustable input parameters include the number of periods n , the lookback period for calculating % D , the smoothing EMA length, and the overbought/oversold threshold level.
TASC 2023.05 Cong Adaptive Moving Average█ OVERVIEW
TASC's May 2023 edition of Traders' Tips features an article titled "An Adaptive Moving Average For Swing Trading" by Scott Cong. The article presents a new adaptive moving average (AMA) that adjusts its parameters automatically based on market volatility. The AMA tracks price closely during trending movements and remains flat during congestion areas.
█ CONCEPTS
Conventional moving averages (MAs) use a fixed lookback period, which may lead to limited performance in constantly changing market conditions. Perry Kaufman's adaptive moving average , first described in his 1995 book Smarter Trading, is a great example of how an AMA can self-adjust to adapt to changing environments. Scott Cong draws inspiration from Kaufman's approach and proposes a new way to calculate the AMA smoothing factor.
█ CALCULATIONS
Following Perry Kaufman's approach, Scott Cong's AMA is calculated progressively as:
AMA = α * Close + (1 − α) * AMA(1),
where:
Close = Close of the current bar
AMA(1) = AMA value of the previous bar
α = Smoothing factor between 0 and 1, defined by the lookback period
The smoothing factor determines the performance of AMA. In Cong's approach, it is calculated as:
α = Result / Effort,
where:
Result = Highest price of the n period − Lowest price of the n period
Effort = Sum(TR, n ), where TR stands for Wilder’s true range values of individual bars of the n period
n = Lookback period
As the price range is always no greater than the total journey, α is ensured to be between 0 and 1.
TASC 2023.04 Undersampled Double MA█ OVERVIEW
TASC's April 2023 edition of Traders' Tips features an article entitled "Just Ignore Them: Undersampling The Data As A Smoothing Technique" by John Ehlers, which explores a method for reducing noise through data sampling. This script implements the article's proposed Undersampled Double MA indicator.
█ CONCEPTS
The conventional approach to reducing the impact of noise in the market data on trading rules is to use smoothing filters like moving averages. However, John Ehlers suggests that changing the sample rate of the datastream is a simple and effective way to smooth the data and reduce noise. Specifically, he argues that undersampling the data removes high-frequency components contributing to noisiness. Notably, the elimination of these components produces less lag than that of conventional smoothing filters.
The Undersampled Double MA indicator implemented in this script represents a practical application of smoothing with undersampling. It samples the data at a given rate (for instance, once every five bars, as suggested by Ehlers), then processes the resulting data using a Hann window filter with two different periods, producing two smooth data streams that traders can use in the same way as the combination of two conventional moving averages of different lengths (i.e., fast and slow MAs).
█ CALCULATIONS
The script samples data once every N th bar (by default, N = 5) and smooths the undersampled data with 6-period and 12-period Hann filters, which it plots on the main chart. Users can adjust the sampling period and the periods of each Hann filter to their liking from the inputs in the script settings.
TASC 2023.03 Every Little Bit Helps - Special EditionMy first Published contribution.
Gracious thank you to all Pine Coders,
this has subtle features that have multiple shifts based on inputs.
with some experimentation, one might try pushing other sources
at the hue dials and see more dynamic indication.
for John Ehlers article
TASC Magazine This Month.
- Special Edition.
TASC 2023.03 Every Little Bit Helps█ OVERVIEW
TASC's February 2023 edition of Traders' Tips includes an article titled "Every Little Bit Helps: Averaging The Open And Close To Reduce Noise" by John Ehlers. This code implements the numerical example from this article.
█ CONCEPTS
Using theories from digital signal processing as a starting point, John Ehlers argues that using the average of the open and close as the source time series of an indicator instead of using only the closing price can often lead to noise reduction in the output. This effect especially applies when there is no gap between the current bar's opening and the previous bar's closing prices. This trick can reduce noise in many common indicators such as the RSI, MACD, and Stochastic.
█ CALCULATIONS
Following the example presented in the original publication, this script illustrates the proposed strategy using the Relative Strength Index (RSI) as a test indicator. It plots two series:
RSI calculated using only closing prices as its source.
RSI of the same length as the first, but calculated using the average of open and close prices as its source, i.e. (open+close)/2 .
This script demonstrates that using the average of open and close as the calculation source results in a smoother indicator. To visually emphasize the advantage of this proposed trick, the script's color scheme is sensitive to both the RSI value and the difference between the two RSI data streams.
TASC 2023.01 TRAdj EMA█ OVERVIEW
TASC's January 2023 edition of Traders' Tips includes an article titled "True Range Adjusted Exponential Moving Average (TRadj EMA)" by Vitali Apirine. This code implements the indicator presented in that publication.
█ CONCEPTS
The True Range Adjusted Exponential Moving Average (TRAdj EMA) is a trend-following indicator that considers volatility for a quicker response to price changes. It is an EMA that modulates its weighting factor based on the true range (TR) of the asset.
In a trading strategy, traders can use a TRAdj EMA in tandem with an EMA of the same length to identify an asset's trend, or they can use it alongside another TRAdj EMA of a different length to identify turning points and filter price movements.
█ CALCULATIONS
The following steps are performed to calculate the indicator:
• Calculate the asset's TR according to the standard definition proposed by J. Welles Wilder, Jr.
• Define the true range adjustment factor as:
TRAdj =( Current TR − Minimum TR) ⁄ ( Maximum TR − Minimum TR ),
where Maximum TR and Minimum TR are the maximum and minimum TR values over the specified lookback period .
• Calculate the TRAdj EMA in the same manner as a traditional EMA, but with a weighting factor defined as:
2*(1 + TRAdj * Multiplier ) ⁄ ( EMA length + 1),
where Multiplier is an input parameter that ranges from 5 to 10. For comparison, a traditional EMA uses a weighting factor of 2 ⁄ ( EMA length + 1).
TASC 2022.12 Short-Term Continuation And Reversal Signals█ OVERVIEW
TASC's December 2022 edition Traders' Tips includes an article by Barbara Star titled "Short-Term Continuation And Reversal Signals". This is the code that implements the concepts presented in this publication.
█ CONCEPTS
The article takes two classic indicators, the Commodity Channel Index (CCI) and the Directional Movement Indicator (DMI), makes changes to the traditional ways of visualizing their readings, and uses them together to generate potential signals. The author first discusses the benefits of converting the DMI indicator to an oscillator format by subtracting the −DI from the +DI, which is then displayed as a histogram. Next, the author shows how the use of an on-chart visual framework (i.e., choosing the line style and color, coloring price bars, etc.) can help traders interpret the signals produced the considered pair of indicators.
█ CALCULATIONS
The article offers the following signals based on the readings of the DMI and CCI pair, suitable for several types of trades:
• Short-term trend change signals:
A DMI oscillator above zero indicates that prices are in an uptrend. A DMI oscillator below the zero line and falling means that selling pressure is dominating and price is trending down. The sign of the DMI oscillator is indicated by the color of the price bars (which correlates with the color of the DMI histogram). Namely, green, red and grey price bars correspond to the DMI oscillator above, below and equal to zero . Colored price bars and the DMI oscillator make it easy for trend traders to recognize changes in short-term trends.
• Trend continuation signals:
Blue circles appear near the bottom of the oscillator chart border when the DMI is above the zero line and the price is above its simple moving average in an uptrend . Dark red circles appear near the top of the chart in a downtrend when the DMI oscillator is below its zero line and below the 18-period moving average. Trend continuation signals are useful for those looking to add to existing positions, as well as for traders waiting for a pullback after a trend has started.
• Reversal signals:
The CCI signals a reversal to the downside when it breaks out of its +100 and then returns at some point, crossing below the +100 level. This is indicated by a magenta-colored diamond shape near the top the chart. The CCI signals a reversal to the upside when it moves below its −100 level and then at some point comes back to cross above the −100 level. This is indicated by a yellow diamond near the bottom of the chart. Reversal signals offer short-term rallies for countertrend traders as well as for swing traders looking for longer-term moves using the interplay between continuation and reversal signals.
TASC 2022.11 Phasor Analysis█ OVERVIEW
TASC's November 2022 edition Traders' Tips includes an article by John Ehlers titled "Recurring Phase Of Cycle Analysis". This is the code that implements the phasor analysis indicator presented in this publication.
█ CONCEPTS
The article explores the use of phasor analysis to identify market trends.
An ordinary rotating phasor diagram is a two-dimensional vector, anchored to the origin, whose rotation rate corresponds to the cycle period in the price data stream. Similarly, Ehlers' phasor is a representation of angular phase rotation along the course of time. Its angle reflects the current phase of the cycle. Angles -180, -90, +90 and +180 degrees correspond to the beginning, valley, peak and end of the cycle, respectively.
If the observed cycle is very long, the market can be considered trending . In his article, John Ehlers defined trending behavior to occur when the derived instantaneous cycle period value is greater that 60 bars. The author also introduced guidelines for long and short entries in a trending state. Depending on the tuning of the indicator period input, a long entry position may occur when the phasor angle is around the approximate vicinity of −90 degrees, while a short entry position may occur when the phasor angle will be around the approximate vicinity of +90 degrees. Applying these definitive guidelines, the author proposed a state variable that is indicated by +1 for a trending long position, 0 for cycling, and −1 for a trending short position (or out).
The phasor angle, the cycle period, and the state variable are made available with three selectable display modes provided for this TradingView indicator.
█ CALCULATIONS
The calculations are carried out as follows.
First, the price data stream is correlated with cosine and sine of a fixed cycle period. This produces two new data streams that correspond to the projections of the frequency domain phasor diagram to the horizontal (so-called real ) and vertical (so-called imaginary ) axis respectively. The wavelength of the cycle period input should be set for the midrange vicinities of the phasor to coincide with the peaks and valleys of the charted price data.
Secondly, the phase angle of the phasor is easily computed as the arctangent of the ratio of the imaginary component to the real component. The difference between the current phasor values and its last is then employed to calculate a derived instantaneous period and market state. This computation is then repeated successively for each individual bar over the entire duration of the data set.
TASC 2022.10 RS VA EMA█ OVERVIEW
TASC's October 2022 edition Traders' Tips includes the second part of the "Relative Strength Moving Averages" article series authored by Vitali Apirine. This is the code that implements the Relative Strength Volume-Adjusted Exponential Moving Average (RS VA EMA) presented in this publication.
█ CONCEPTS
In his article series, the author argues that the relative strength of price, volume, and volatility can potentially be used to filter price movements and define turning points. In particular, the RS VA EMA indicator is designed to account for the relative strength of volume. Like the traditional exponential moving average (EMA) , it is a lagging trend-following indicator. The difference is that it responds more quickly.
In a trading strategy, RS VA EMA is suggested to be used in combination with EMA of the same length to determine the overall trend or in combination with RS VA EMA of a different length to identify turning points and filter price movements.
█ CALCULATIONS
The calculation of RS VA EMA is based on the concept of volume strength (VS). By definition, VS measures the difference between "positive" and "negative" volume flow. Volume is indicated as "positive" when the close is higher than the previous close and "negative" when the close is below the previous close.
The following steps are used in the calculation process:
• Calculate the volume strength (VS) of a given length.
• Multiply VS by a predefined multiplier and calculate the EMA of the resulting time series.
The values of 10,10,10 are the typical input settings for RS VA EMA, where the first parameter is the length of the moving average, the second is the length of VS, and the third is the volume strength multiplier.
TASC 2022.09 LRAdj EMA█ OVERVIEW
TASC's September 2022 edition of Traders' Tips includes an article by Vitali Apirine titled "The Linear Regression-Adjusted Exponential Moving Average". This script implements the titular indicator presented in this article.
█ CONCEPT
The Linear Regression-Adjusted Exponential Moving Average (LRAdj EMA) is a new tool that combines a linear regression indicator with exponential moving averages . First, the indicator accounts for the linear regression deviation, that is, the distance between the price and the linear regression indicator. Subsequently, an exponential moving average (EMA) smooths the price data and and provides an indication of the current direction.
As part of a trading system, LRAdj EMA can be used in conjunction with an exponential moving average of the same length to identify the overall trend. Alternatively, using LRAdj EMAs of different lengths together can help identify turning points.
█ CALCULATION
The script uses the following input parameters:
EMA Length
LR Lookback Period
Multiplier
The calculation of LRAdj EMA is carried out as follows:
Current LRAdj EMA = Prior LRAdj EMA + MLTP × (1+ LRAdj × Multiplier ) × ( Price − Prior LRAdj EMA ),
where MLTP is a weighting multiplier defined as MLTP = 2 ⁄ ( EMA Length + 1), and LRAdj is the linear regression adjustment (LRAdj) multiplier:
LRAdj = (Abs( Current LR Dist )−Abs( Minimum LR Dist )) ⁄ (Abs( Maximum LR Dist )−Abs( Minimum LR Dist ))
When calculating the LRAdj multiplier, the absolute values of the following quantities are used:
Current LR Dist is the distance between the current close and the linear regression indicator with a length determined by the LR Lookback Period parameter,
Minimum LR Dist is the minimum distance between the close and the linear regression indicator for the LR lookback period ,
Maximum LR Dist is the maximum distance between the close and the linear regression indicator for the LR lookback period .
TASC 2022.07 Pairs Rotation With Ehlers Loops█ OVERVIEW
TASC's July 2022 edition of Traders' Tips includes an article by John Ehlers titled "Pairs Rotation With Ehlers Loops". This is the code that implements the Ehlers Loops applied to pairs rotation trading.
█ CONCEPTS
John Ehlers developed Ehlers loops as a tool to visualize the performance of one data stream versus another. Initially, he used this tool to chart price versus volume. However, Ehlers loops proved to be suitable for determining the timing of the pairs rotation strategy . This strategy works by having a long position in only one of two securities, depending on which one is considered stronger at a given time.
When the prices of two securities (filtered and scaled with a standard deviation for consistent presentation) are plotted against each other, the curvature and direction of rotation on the chart can help guide decisions on long positions. For example, when plotting a stock versus a referenced symbol, a vertical upward movement while rotating clockwise is a sign of going long the stock. Similarly, a horizontal movement to the right while rotating counterclockwise is the sign to go long the reference. A higher probability of a reversal is expected when the price moves more than one or two standard deviations.
█ CALCULATIONS
The script uses the following steps to calculate the Ehlers Loops:
The price data of both securities in the pair are individually filtered using identical high-pass and SuperSmoother filters. This results in two band-limited data streams, having a nominally zero mean. The input parameters Low-Pass Period and High-Pass Period control the filter bandwidth and thus can modify the shape of the Ehlers Loops.
Subsequently, the filtered data streams are scaled in terms of standard deviation by dividing each of them by their root-mean-square (RMS) values. These data streams are plotted as zero-mean oscillators.
Finally, the scaled data streams are displayed one against another for the selected time interval (defined by the input parameter Loop Segments ). In the resulting scatterplot, the thicker line corresponds to the later data points. The fluctuations of the filtered price data of the chart symbol are plotted along the y -axis, and the price changes of the referenced symbol are shown along the x -axis.
TASC 2022.06 Ehlers Loops█ OVERVIEW
TASC's June 2022 edition Traders' Tips includes an article by John Ehlers titled "Ehlers Loops. Part 1". This is the code implementing the price-volume Ehlers Loops he introduced in the publication.
█ CONCEPTS
John Ehlers developed Ehlers loops as a tool to visualize the performance of one data stream versus another, both filtered and scaled. In this article, the author applies his concept to exploit and/or dispel the dogmatic principles of reliable price-volume relationships.
The script offers two different ways to visualize Ehlers Loops:
Oscillators (default option)
In this implementation, filtered and scaled volume is plotted along with filtered and scaled price as zero-mean oscillators. Observation of the relative direction of volume and price oscillators can be discretionarily used to interpret and predict market conditions. For example, it is generally assumed that an increase in volume and an increase in price define a bullish condition. Similarly, decreasing volume and increasing price are generally considered bearish. A decrease in volume and a decrease in price is considered a bullish condition. The increase in volume and decrease in price is often thought to be bearish.
Scatterplot
This Crocker-style visualization displays filtered and scaled price against filtered and scaled volume for the selected timespan. Fluctuations in volume are plotted along the x -axis, while price changes along the y -axis. This way of visualizing the Ehlers Loop allows you to analyze the curvature and directional path of the price in relation to volume, offering a different comparative perspective. The boundaries of the price and volume scale on the Ehlers Loop Crocker-chart are presented in standard deviations. Deviations can be used to predict possible future price or volume fluctuations. The expected probability of potential reversals is 68%, 95% and 99.7% at one, two and three standard deviations, respectively.
█ CALCULATIONS
The following steps are used to build an Ehlers Loop:
• Both price and volume are filtered to be band-limited signals. This is done by applying the high-pass Butterworth filter in combination with the low-pass SuperSmooth filter.
The cutoff wavelengths of the high-pass and low-pass filters are defined by the input parameters HPPeriod and LPPeriod , respectively.
These values change the appearance of the Ehlers Loops and can be customized to your trading style.
• The filtered price and volume time series are then scaled in terms of standard deviation by dividing each by their root-mean-square values.
• The resultant price and volume data are plotted as zero-mean oscillators or as a scatterplot.