Uptrick: Acceleration ShiftsIntroduction
Uptrick: Acceleration Shifts is designed to measure and visualize price momentum shifts by focusing on acceleration —the rate of change in velocity over time. It uses various moving average techniques as a trend filter, providing traders with a clearer perspective on market direction and potential trade entries or exits.
Purpose
The main goal of this indicator is to spot strong momentum changes (accelerations) and confirm them with a chosen trend filter. It attempts to distinguish genuine market moves from noise, helping traders make more informed decisions. The script can also trigger multiple entries (smart pyramiding) within the same trend, if desired.
Overview
By measuring how quickly price velocity changes (acceleration) and comparing it against a smoothed average of itself, this script generates buy or sell signals once the acceleration surpasses a given threshold. A trend filter is added for further validation. Users can choose from multiple smoothing methods and color schemes, and they can optionally enable a small table that displays real-time acceleration values.
Originality and Uniqueness
This script offers an acceleration-based approach, backed by several different moving average choices. The blend of acceleration thresholds, a trend filter, and an optional extra-entry (pyramiding) feature provides a flexible toolkit for various trading styles. The inclusion of multiple color themes and a slope-based coloring of the trend line adds clarity and user customization.
Inputs & Features
1. Acceleration Length (length)
This input determines the number of bars used when calculating velocity. Specifically, the script computes velocity by taking the difference in closing prices over length bars, and then calculates acceleration based on how that velocity changes over an additional length. The default is 14.
2. Trend Filter Length (smoothing)
This sets the lookback period for the chosen trend filter method. The default of 50 results in a moderately smooth trend line. A higher smoothing value will create a slower-moving trend filter.
3. Acceleration Threshold (threshold)
This multiplier determines when acceleration is considered strong enough to trigger a main buy or sell signal. A default value of 2.5 means the current acceleration must exceed 2.5 times the average acceleration before signaling.
4. Smart Pyramiding Strength (pyramidingThreshold)
This lower threshold is used for additional (pyramiding) entries once the main trend has already been identified. For instance, if set to 0.5, the script looks for acceleration crossing ±0.5 times its average acceleration to add extra positions.
5. Max Pyramiding Entries (maxPyramidingEntries)
This sets a limit on how many extra positions can be opened (beyond the first main signal) in a single directional trend. The default of 3 ensures traders do not become overexposed.
6. Show Acceleration Table (showTable)
When enabled, a small table displaying the current acceleration and its average is added to the top-right corner of the chart. This table helps monitor real-time momentum changes.
7. Smart Pyramiding (enablePyramiding)
This toggle decides whether additional entries (buy or sell) will be generated once a main signal is active. If enabled, these extra signals act as filtered entries, only firing when acceleration re-crosses a smaller threshold (pyramidingThreshold). These signals have a '+' next to their signal on the label.
8. Select Color Scheme (selectedColorScheme)
Allows choosing between various pre-coded color themes, such as Default, Emerald, Sapphire, Golden Blaze, Mystic, Monochrome, Pastel, Vibrant, Earth, or Neon. Each theme applies a distinct pair of colors for bullish and bearish conditions.
9. Trend Filter (TrendFilter)
Lets the user pick one of several moving average approaches to determine the prevailing trend. The options include:
Short Term (TEMA)
EWMA
Medium Term (HMA)
Classic (SMA)
Quick Reaction (DEMA)
Each method behaves differently, balancing reactivity and smoothness.
10. Slope Lookback (slopeOffset)
Used to measure the slope of the trend filter over a set number of bars (default is 10). This slope then influences the coloring of the trend filter line, indicating bullish or bearish tilt.
Note: The script refers to this as the "Massive Slope Index," but it effectively serves as a Trend Slope Calculation, measuring how the chosen trend filter changes over a specified period.
11. Alerts for Buy/Sell and Pyramiding Signals
The script includes built-in alert conditions that can be enabled or configured. These alerts trigger whenever the script detects a main Buy or Sell signal, as well as extra (pyramiding) signals if Smart Pyramiding is active. This feature allows traders to receive immediate notifications or automate a trading response.
Calculation Methodology
1. Velocity and Acceleration
Velocity is derived by subtracting the closing price from its value length bars ago. Acceleration is the difference in velocity over an additional length period. This highlights how quickly momentum is shifting.
2. Average Acceleration
The script smooths raw acceleration with a simple moving average (SMA) using the smoothing input. Comparing current acceleration against this average provides a threshold-based signal mechanism.
3. Trend Filter
Users can pick one of five moving average types to form a trend baseline. These range from quick-reacting methods (DEMA, TEMA) to smoother options (SMA, HMA, EWMA). The script checks whether the price is above or below this filter to confirm trend direction.
4. Buy/Sell Logic
A buy occurs when acceleration surpasses avgAcceleration * threshold and price closes above the trend filter. A sell occurs under the opposite conditions. An additional overbought/oversold check (based on a longer SMA) refines these signals further.
When price is considered oversold (i.e., close is below a longer-term SMA), a bullish acceleration signal has a higher likelihood of success because it indicates that the market is attempting to reverse from a lower price region. Conversely, when price is considered overbought (close is above this longer-term SMA), a bearish acceleration signal is more likely to be valid. This helps reduce false signals by waiting until the market is extended enough that a reversal or continuation has a stronger chance of following through.
5. Smart Pyramiding
Once a main buy or sell signal is triggered, additional (filtered) entries can be taken if acceleration crosses a smaller multiplier (pyramidingThreshold). This helps traders scale into strong moves. The script enforces a cap (maxPyramidingEntries) to limit risk.
6. Visual Elements
Candles can be recolored based on the active signal. Labels appear on the chart whenever a main or pyramiding entry signal is triggered. An optional table can show real-time acceleration values.
Color Schemes
The script includes a variety of predefined color themes. For bullish conditions, it might use turquoise or green, and for bearish conditions, magenta or red—depending on which color scheme the user selects. Each scheme aims to provide clear visual differentiation between bullish and bearish market states.
Why Each Indicator Was Part of This Component
Acceleration is employed to detect swift changes in momentum, capturing shifts that may not yet appear in more traditional measures. To further adapt to different trading styles and market conditions, several moving average methods are incorporated:
• TEMA (Triple Exponential Moving Average) is chosen for its ability to reduce lag more effectively than a standard EMA while still reacting swiftly to price changes. Its construction layers exponential smoothing in a way that can highlight sudden momentum shifts without sacrificing too much smoothness.
• DEMA (Double Exponential Moving Average) provides a faster response than a single EMA by using two layers of exponential smoothing. It is slightly less smoothed than TEMA but can alert traders to momentum changes earlier, though with a higher risk of noise in choppier markets.
• HMA (Hull Moving Average) is known for its balance of smoothness and reduced lag. Its weighted calculations help track trend direction clearly, making it useful for traders who want a smoother line that still reacts fairly quickly.
• SMA (Simple Moving Average) is the classic baseline for smoothing price data. It offers a clear, stable perspective on long-term trends, though it reacts more slowly than other methods. Its simplicity can be beneficial in lower-volatility or more stable market environments.
• EWMA (Exponentially Weighted Moving Average) provides a middle ground by emphasizing recent price data while still retaining some degree of smoothing. It typically responds faster than an SMA but is less aggressive than DEMA or TEMA.
Alongside these moving average techniques, the script employs a slope calculation (referred to as the “Massive Slope Index”) to visually indicate whether the chosen filter is sloping upward or downward. This adds an extra layer of clarity to directional analysis. The indicator also uses overbought/oversold checks, based on a longer-term SMA, to help filter out signals in overstretched markets—reducing the likelihood of false entries in conditions where the price is already extensively extended.
Additional Features
Alerts can be set up for both main signals and additional pyramiding signals, which is helpful for automated or semi-automated trading. The optional acceleration table offers quick reference values, making momentum monitoring more intuitive. Including explicit alert conditions for Buy/Sell and Pyramiding ensures traders can respond promptly to market movements or integrate these triggers into automated strategies.
Summary
This script serves as a comprehensive momentum-based trading framework, leveraging acceleration metrics and multiple moving average filters to identify potential shifts in market direction. By combining overbought/oversold checks with threshold-based triggers, it aims to reduce the noise that commonly plagues purely reactive indicators. The flexibility of Smart Pyramiding, customizable color schemes, and built-in alerts allows users to tailor their experience and respond swiftly to valid signals, potentially enhancing trading decisions across various market conditions.
Disclaimer
All trading involves significant risk, and users should apply their own judgment, risk management, and broader analysis before making investment decisions.
Ewma
Uptrick: MultiMA_VolumePurpose:
The "Uptrick: MultiMA_Volume" indicator, identified by its abbreviated title 'MMAV,' is meticulously designed to provide traders with a comprehensive view of market dynamics by incorporating multiple moving averages (MAs) and volume analysis. With adjustable inputs and customizable visibility options, traders can tailor the indicator to their specific trading preferences and strategies, thereby enhancing its utility and usability.
Explanation:
Input Variables and Customization:
Traders have the flexibility to adjust various parameters, including the lengths of different moving averages (SMA, EMA, WMA, HMA, and KAMA), as well as the option to show or hide each moving average and volume-related components.
Customization options empower traders to fine-tune the indicator according to their trading styles and market preferences, enhancing its adaptability across different market conditions.
Moving Averages and Trend Identification:
The script computes multiple types of moving averages, including Simple (SMA), Exponential (EMA), Weighted (WMA), Hull (HMA), and Kaufman's Adaptive (KAMA), allowing traders to assess trend directionality and strength from various perspectives.
Traders can determine potential price movements by observing the relationship between the current price and the plotted moving averages. For example, prices above the moving averages may suggest bullish sentiment, while prices below could indicate bearish sentiment.
Volume Analysis:
Volume analysis is integrated into the indicator, enabling traders to evaluate volume dynamics alongside trend analysis.
Traders can identify significant volume spikes using a customizable threshold, with bars exceeding the threshold highlighted to signify potential shifts in market activity and liquidity.
Determining Potential Price Movements:
By analyzing the relationship between price and the plotted moving averages, traders can infer potential price movements.
Bullish biases may be suggested when prices are above the moving averages, accompanied by rising volume, while bearish biases may be indicated when prices are below the moving averages, with declining volume reinforcing the potential for downward price movements.
Utility and Potential Usage:
The "Uptrick: MultiMA_Volume" indicator serves as a comprehensive tool for traders, offering insights into trend directionality, strength, and volume dynamics.
Traders can utilize the indicator to identify potential trading opportunities, confirm trend signals, and manage risk effectively.
By consolidating multiple indicators into a single chart, the indicator streamlines the analytical process, providing traders with a concise overview of market conditions and facilitating informed decision-making.
Through its customizable features and comprehensive analysis, the "Uptrick: MultiMA_Volume" indicator equips traders with actionable insights into market trends and volume dynamics. By integrating trend analysis and volume assessment into their trading strategies, traders can navigate the markets with confidence and precision, thereby enhancing their trading outcomes.
Exponentially Weighted Moving Average Oscillator [BackQuant]Exponentially Weighted Moving Average (EWMA)
The Exponentially Weighted Moving Average (EWMA) is a quantitative or statistical measure used to model or describe a time series. The EWMA is widely used in finance, the main applications being technical analysis and volatility modeling.
The moving average is designed as such that older observations are given lower weights. The weights fall exponentially as the data point gets older – hence the name exponentially weighted.
Applications of the EWMA
The EWMA is widely used in technical analysis. It may not be used directly, but it is used in conjunction with other indicators to generate trading signals. A well-known example is the Negative Volume Index (NVI), which is used in conjunction with its EWMA.
Why is it different from the In-Built TradingView EWMA
Adaptive Algorithms: If your strategy requires the alpha parameter to change adaptively based on certain conditions (for example, based on market volatility), a for loop can be used to adjust the weights dynamically within the loop as opposed to the fixed decay rate in the standard EWMA.
Customization: A for loop allows for more complex and nuanced calculations that may not be directly supported by built-in functions. For example, you might want to adjust the weights in a non-standard way that the typical EWMA calculation doesn't allow for.
Use of the Oscillator
This mainly comes from 3 main premises, this is something I like to do personally since it is easier to work with them in the context of my system. E.g. Using them to spot clear trends without noise on longer timeframes.
Clarity: Plotting the EWMA as an oscillator provides a clear visual representation of the momentum or trend strength. It allows traders to see overbought or oversold conditions relative to a normalized range.
Comparison: An oscillator can make it easier to compare different securities or timeframes on a similar scale, especially when normalized. This is because the oscillator values are typically bounded within a range (like -1 to 1 or 0 to 100), whereas the actual price series can vary significantly.
Focus on Change: When plotted as an oscillator, the focus is on the rate of change or the relative movement of the EWMA, not on the absolute price levels. This can help traders spot divergences or convergences that may not be as apparent when the EWMA is plotted directly on the price chart. This is also one reason there is a conditional plotting on the chart.
Trend Strength: When normalized, the distance of the oscillator from its midpoint can be interpreted as the strength of the trend, providing a quantitative measure that can be used to make systematic trading decisions.
Here are the backtests on the 1D Timeframe for
BITSTAMP:BTCUSD
BITSTAMP:ETHUSD
COINBASE:SOLUSD
When using this script the user is able to define a source and period, which by extension calculates the alpha. An option to colour the bars accord to trend.
This makes it super easy to use in a system.
I recommend using this as above the midline (0) for a positive trend and below the midline for negative trend.
Hence why I put a label on the last bar to ensure it is easier for traders to read.
Lastly, The decreasing colour relative to RoC, this also helps traders to understand the strength of the indicator and gain insight into when to potentially reduce position size.
This indicator is best used in the medium timeframe.
HMA w/ SSE-Dynamic EWMA Volatility Bands [Loxx]This indicator is for educational purposes to lay the groundwork for future closed/open source indicators. Some of thee future indicators will employ parameter estimation methods described below, others will require complex solvers such as the Nelder-Mead algorithm on log likelihood estimations to derive optimal parameter values for omega, gamma, alpha, and beta for GARCH(1,1) MLE and other volatility metrics. For our purposes here, we estimate the rolling lambda (λ) value used to calculate EWMA by minimizing of the sum of the squared errors minus the long-run variance--a rolling window of the one year mean of squared log-returns. In practice, practitioners will use a λ equal to a standardized value put out by institutions such as JP Morgan. Even simpler than this, others use a ratio of (per - 1) / (per + 1) to derive λ where per is the lookback period for EWMA. Due to computation limits in Pine, we'll likely not see a true GARCH(1,1) MLE on Pine for quite some time, but future closed source indicators will contain some very interesting industry hacks to get close by employing modifications to EWMA. Enjoy!
Exponentially weighted volatility and its relationship to GARCH(1,1)
Exponentially weighted volatility--also called exponentially weighted moving average volatility (EWMA)--puts more weight on more recent observations. EWMA is calculated as follows:
σ*2 = λσ(n - 1)^2 + (1 − λ)u(n - 1)^2
The estimate, σn, of the volatility for day n (made at the end of day n − 1) is calculated from σn −1 (the estimate that was made at the end of day n − 2 of the volatility for day n − 1) and u^n−1 (the most recent daily percentage change).
The EWMA approach has the attractive feature that the data storage requirements are modest. At any given time, we need to remember only the current estimate of the variance rate and the most recent observation on the value of the market variable. When we get a new observation on the value of the market variable, we calculate a new daily percentage change to update our estimate of the variance rate. The old estimate of the variance rate and the old value of the market variable can then be discarded.
The EWMA approach is designed to track changes in the volatility. Suppose there is a big move in the market variable on day n − 1 so that u2n−1 is large. This causes our estimate of the current volatility to move upward. The value of λ governs how responsive the estimate of the daily volatility is to the most recent daily percentage change. A low value of λ leads to a great deal of weight being given to the u(n−1)^2 when σn is calculated. In this case, the estimates produced for the volatility on successive days are themselves highly volatile. A high value of λ (i.e., a value close to 1.0) produces estimates of the daily volatility that respond relatively slowly to new information provided by the daily percentage change.
The RiskMetrics database, which was originally created by JPMorgan and made publicly available in 1994, used the EWMA model with λ = 0.94 for updating daily volatility estimates. The company found that, across a range of different market variables, this value of λ gives forecasts of the variance rate that come closest to the realized variance rate. In 2006, RiskMetrics switched to using a long memory model. This is a model where the weights assigned to the u(n -i)^2 as i increases decline less fast than in EWMA.
GARCH(1,1) Model
The EWMA model is a particular case of GARCH(1,1) where γ = 0, α = 1 − λ, and β = λ. The “(1,1)” in GARCH(1,1) indicates that σ^2 is based on the most recent observation of u^2 and the most recent estimate of the variance rate. The more general GARCH(p, q) model calculates σ^2 from the most recent p observations on u2 and the most recent q estimates of the variance rate.7 GARCH(1,1) is by far the most popular of the GARCH models. Setting ω = γVL, the GARCH(1,1) model can also be written:
σ(n)^2 = ω + αu(n-1)^2 + βσ(n-1)^2
What this indicator does
Calculate log returns log(close/close(1))
Calculates Lambda (λ) dynamically by minimizing the sum of squared errors. I've restricted this to the daily timeframe so as to not bloat the code with additional logic required to derive an annualized EWMA historical volatility metric.
After the Lambda is derived, EWMA is calculated one last time and the result is the daily volatility
This daily volatility is multiplied by the source and the multiplier +/- the HMA to create the volatility bands
Finally, daily volatility is multiplied by the square-root of days per year to derive annualized volatility. Years are trading days for the asset, for most everything but crypto, its 252, for crypto is 365.
EWMA Implied Volatility based on Historical VolatilityVolatility is the most common measure of risk.
Volatility in this sense can either be historical volatility (one observed from past data), or it could implied volatility (observed from market prices of financial instruments.)
The main objective of EWMA is to estimate the next-day (or period) volatility of a time series and closely track the volatility as it changes.
The EWMA model allows one to calculate a value for a given time on the basis of the previous day's value.
The EWMA model has an advantage in comparison with SMA, because the EWMA has a memory.
The EWMA remembers a fraction of its past by a factor A, that makes the EWMA a good indicator of the history of the price movement if a wise choice of the term is made.
Full details regarding the formula :
www.investopedia.com
In this scenario, we are looking at the historical volatility using the anual length of 252 trading days and a monthly length of 21.
Once we apply all of that we are going to get the yearly volatility.
After that we just have to divide that by the square root of number of days in a year, or weeks in a year or months in a year in order to get the daily/weekly/monthly expected volatility.
Once we have the expected volatility, we can estimate with a high chance where the market top and bottom is going to be and continue our analysis on that premise.
If you have any questions, please let me know !