Amplitude [Anan]The Amplitude indicator calculates and visualizes both the amplitude and cumulative amplitude of price movements, providing traders with insights into price volatility and trend strength. By distinguishing between positive and negative amplitude movements, this indicator aids in identifying bullish and bearish sentiments, potential reversal points, and confirming trend directions.
█ Main Formulas
‣ Amplitude = High - Low
‣ Cumulative Amplitude = sum of Amplitude over the specified lookback period
‣ Percentage Amplitude = (Amplitude / Open) × 100%
High: Candle high (or highest high when lookback > 1)
Low: Candle low (or lowest low when lookback > 1)
Open: Open price of the first candle in the lookback period
█ Key Features
✦Dual Amplitude Calculations:
Amplitude: Reflects price range and direction over a short-term period.
Cumulative Amplitude: Aggregates amplitude over a longer period for broader trend analysis.
✦Customizable Parameters: Adjust lookback periods, smoothing options, moving averages and Alerts.
✦Direction Separation: Distinguish between positive and negative amplitude movements to identify market sentiment.
✦Flexible Visualization: Customizable colors and plot styles for enhanced chart readability.
✦Alert System: Generate signals based on amplitude direction and moving average crossovers
█ How to Use and Interpret
✦Understanding Amplitude and Cumulative Amplitude:
‣Amplitude: Measures the price range (high - low) over a specified short-term period.
‣Cumulative Amplitude: Aggregates amplitude over a defined longer-term period.
‣Percentage Representation: shows amplitude relative to the open price from `amp_length` bars ago, providing a normalized view.
‣Interpretation:
Large Amplitude Values: Indicate high volatility.
Small Amplitude Values: Indicate low volatility.
✦Trend Identification:
‣Uptrend: Consistently positive amplitudes and upward-moving averages.
‣Downtrend: Consistently negative amplitudes and downward-moving averages.
✦Overbought/Oversold Conditions:
‣High Positive Amplitude: May indicate overbought conditions and potential reversals.
‣High Negative Amplitude: May indicate oversold conditions and potential reversals.
✦Volatility Analysis:
‣High Amplitude Values: Suggest increased market volatility.
‣Low Amplitude Values: Suggest reduced market volatility.
✦Signal Confirmation:
‣Moving Average Crossovers: Confirm the strength and direction of trends, aiding in informed trading decisions.
✦Trading Strategies:
‣ Breakout Trading: Large increases in amplitude can signal potential breakouts.
‣ Mean Reversion: Extreme amplitude values may indicate upcoming price corrections.
‣ Volatility-Based Strategies: Adjust position sizes or trading frequency based on amplitude magnitudes.
‣ Multi-Timeframe Analysis: Compare amplitudes across different timeframes for a comprehensive market view.
█ Customization Tips
‣ Lookback Periods: Experiment with different periods to suit your trading style and asset characteristics.
‣ Smoothing Settings: Adjust to balance responsiveness and noise reduction.
‣ Percentage Amplitude: Use for normalized comparisons across different price levels.
Amplitude
Hann Window Amplitude FilterThis script is designed to implement a multi-signal Hann filter, which is essentially a movable Hann window filter. The purpose of this filter is to allow users to select the periods or frequencies that best align with their trading strategy or market analysis.
The Hann window filter operates by enabling the selection of either lower or higher frequencies. The period of the window is twice the number of signals you wish to filter. As you shift the window by the number of your signals, the signal on one side will have an amplitude of 0, while the other side will have an amplitude of 1.
Continuing to shift the window will result in new values of 0. This feature is particularly useful for further filtering the frequencies or periods that you want to focus on for your trading decisions.
In summary, this script provides a flexible and customizable tool for filtering signals based on their frequency or period, which can be a valuable addition to any trader's technical analysis toolkit.
Ehlers Cycle Amplitude [CC]The Cycle Amplitude was created by John Ehlers (Trend Modes and Cycle Modes) and this indicator wasn't meant to give buy and sell signals by itself but I'm publishing this open source script in case someone comes up with a cool way to use this indicator for buy and sell signals. This indicator essentially tells you the distance between the peaks from the Cycle BandPass Filter and I will be including the last script tomorrow most likely. I'm reusing the same exact buy and sell signals from the cycle bandpass filter so if you have any questions then feel free to refer to the link I posted.
Let me know if there are any other scripts you would like to see me publish!
Trend Volume Accumulations [LuxAlgo]Deeply inspired by the Weiss wave indicator, the following indicator aims to return the accumulations of rising and declining volume of a specific trend. Positive waves are constructed using rising volume while negative waves are using declining volume.
The trend is determined by the sign of the rise of a rolling linear regression.
Settings
Length : Period of the indicator.
Src : Source of the indicator.
Linearity : Allows the output of the indicator to look more linear.
Mult : the multiplicative factor of both the upper and lower levels
Gradient : Use a gradient as color for the waves, true by default.
Usages
The trend volume accumulations (TVA) indicator allows determining the current price trend while taking into account volume, with blue colors representing an uptrend and red colors representing a downtrend.
The first motivation behind this indicator was to see if movements mostly made of declining volume were different from ones made of rising volume.
Waves of low amplitude represent movements with low trading activity.
Using higher values of Linearity allows giving less importance to individual volumes values, thus returning more linear waves as a result.
The indicator includes two levels, the upper one is derived from the cumulative mean of the waves based on rising volume, while the lower one is based on the cumulative mean of the waves based on declining volume, when a wave reaches a level we can expect the current trend to reverse. You can use different values of mult to control the distance from 0 of each level.
Filter Amplitude Response Estimator - A Simple CalculationIn digital signal processing knowing how a system interact with the frequency content of an input signal is extremely important, the mathematical tool that give you this information is called "frequency response". The frequency response regroup two elements, the amplitude response, and the phase response. The amplitude response tells you how the system modify the amplitude of the frequency components in the input signal, the phase response tells you how the system modify the phase of the frequency components in the signal, each being a function of the frequency.
The today proposed tool aim to give a low resolution representation of the amplitude response of any filter.
What Is The Amplitude Response Of A Filter ?
Remember that filters allow to interact with the frequency content of a signal by amplifying, attenuating and/or removing certain frequency components in the input signal, the amplitude (also called magnitude) response of a filter let you know exactly how your filter change the amplitude of the frequency components in the input signal, another way to see the amplitude response is as a tool that tell you what is the peak amplitude of a filter using a sinusoid of a certain frequency as input signal.
For example if the amplitude response of a filter give you a value of 0.9 at frequency 0.5, it means that the filter peak amplitude using a sinusoid of frequency 0.5 is equal to 0.9.
There are several ways to calculate the frequency response of a filter, when our filter is a FIR filter (the filter impulse response is finite), the frequency response of the filter is the absolute value of the discrete Fourier transform (DFT) of the filter impulse response.
If you are curious about this process, know that the DFT of a N samples signal return N values, so if our FIR filter coefficients are composed of only 5 values we would get a frequency response of 5 values...which would not be useful, this is why we "pad" our coefficients with zeros, that is we add zeros to the start and end of our series of coefficients, this process is called "zero-padding", so if our series of coefficients is: (1,2,3,4,5), applying zero padding would give (0,0...1,2,3,4,5,...0,0) while keeping a certain symmetry. This is related to the concept of resolution, a low resolution amplitude response would be composed of a low number of values and would not be useful, this is why we use zero-padding to add more values thus increasing the resolution.
Making a Fourier transform in Pinescript is not doable, as you need the complex number i for computing a DFT, but thats not even the only problem, a DFT would not be that useful anyway (as the processes to make it useful in a trading context would be way too complex) . So how can we calculate a filter amplitude response without using a DFT ? The simple answer is by taking the peak amplitude of a filter using a sinusoid of a certain frequency as input, this is what the proposed tool do.
Using The Tool
The proposed tool give you a 50 point amplitude response from frequency 0.005 to 0.25 by default. the setting "Range Divisor" allow you to see the amplitude response by using a different range of frequency, for example if the range divisor is equal to 2 the filter amplitude response will be evaluated from frequency 0.0025 to 0.125.
In the script, filt hold the filter you want to see the frequency response, by default a simple moving average.
The position of the frequency response is defined by the "Show Amplitude Response At Bar Number" setting, if you want the frequency response to start at bar number 5000 then enter 5000, by default 10000. If you are not a premium set the number at 4000 and it should work.
amplitude response of a simple moving average of period 14, res = 2.
By default the amplitude response use an amplitude scale, a value of 1 represent an unchanged amplitude. You can use Dbfs (decibel full scale) instead by checking the "To Decibels (Full Scale)" setting.
Dbfs amplitude response, a value of 0 represent an unchanged amplitude.
Some Amplitude Responses
In order to prove the accuracy of the proposed tool we can compare the amplitude response given by the proposed tool with the mathematical function of the amplitude response of a simple moving average, that is:
abs(sin(pi*f*length)/(length*sin(pi*f)))
In cyan the amplitude response given by the proposed tool and in blue the above function. Below are the amplitude responses of some moving averages with period 14.
Amplitude response of an EMA, the EMA is a IIR filter, therefore the amplitude response can't be made by taking the DFT of the impulse response (as this ones has infinite length), however our tool can give its frequency response.
Amplitude response of the Hull MA, as you can see some frequencies are amplified, this is common with low-lag filters.
Gaussian moving average (ALMA), with offset = 0.5 and sigma = 6.
Simple moving average high-pass filter amplitude response
Center of gravity bandpass filter amplitude response
Center of gravity bandreject filter.
IMPORTANT!: The amplitude response of adaptive moving averages is not stationary and might change over time.
Conclusion
A tool giving the amplitude response of any filter has been presented, of course this method is not efficient at all and has a low resolution of 50 points (the common resolution is of 512 points) and is difficult to work with, but has the merit to work on Tradingview and can give the frequency response of IIR filters, if you really need to see the frequency response of a filter then i recommend you to use the function freqz from the scipy package.
I still hope you will enjoy using this tool to have a look at the amplitude responses of your favorite moving averages.
I'am aware of the current situation, however i'am somehow feeling left out from the pinescript community, let me know via PM if i have done something to you and i'll do my best to fix any problems i might have caused (or i might be being parano xD)
SL/TP assistantThis is a simple script to quickly see changes in % in each candle.
In blue open/close variation. In red Histogram with range between high and low.
This helps me understand very quickly what's the typical change in % for a specific timeframe/pair, so I can fine tune my Stop Losses and Take Profits.
AmplitudeAmplitude is a very simple measurement of subtracting the range (high - low) of a candle by some other data from that candle. in this case, we use the midpoint of the candle, so the calculation is (high - low) / (high + low)/2 . This isn't a new concept, but I could not find this study anywhere so I decided to add it myself.