loxxfftLibrary   "loxxfft" 
This code is a library for performing Fast Fourier Transform (FFT) operations. FFT is an algorithm that can quickly compute the discrete Fourier transform (DFT) of a sequence. The library includes functions for performing FFTs on both real and complex data. It also includes functions for fast correlation and convolution, which are operations that can be performed efficiently using FFTs. Additionally, the library includes functions for fast sine and cosine transforms. 
Reference:
www.alglib.net
 fastfouriertransform(a, nn, inversefft) 
  Returns Fast Fourier Transform
  Parameters:
     a (float ) : float , An array of real and imaginary parts of the function values. The real part is stored at even indices, and the imaginary part is stored at odd indices.
     nn (int) : int, The number of function values. It must be a power of two, but the algorithm does not validate this.
     inversefft (bool) : bool, A boolean value that indicates the direction of the transformation. If True, it performs the inverse FFT; if False, it performs the direct FFT.
  Returns: float , Modifies the input array a in-place, which means that the transformed data (the FFT result for direct transformation or the inverse FFT result for inverse transformation) will be stored in the same array a after the function execution. The transformed data will have real and imaginary parts interleaved, with the real parts at even indices and the imaginary parts at odd indices.
 realfastfouriertransform(a, tnn, inversefft) 
  Returns Real Fast Fourier Transform
  Parameters:
     a (float ) : float , A float array containing the real-valued function samples.
     tnn (int) : int, The number of function values (must be a power of 2, but the algorithm does not validate this condition).
     inversefft (bool) : bool, A boolean flag that indicates the direction of the transformation (True for inverse, False for direct).
  Returns: float , Modifies the input array a in-place, meaning that the transformed data (the FFT result for direct transformation or the inverse FFT result for inverse transformation) will be stored in the same array a after the function execution.
 fastsinetransform(a, tnn, inversefst) 
  Returns Fast Discrete Sine Conversion
  Parameters:
     a (float ) : float , An array of real numbers representing the function values.
     tnn (int) : int, Number of function values (must be a power of two, but the code doesn't validate this).
     inversefst (bool) : bool, A boolean flag indicating the direction of the transformation. If True, it performs the inverse FST, and if False, it performs the direct FST.
  Returns: float , The output is the transformed array 'a', which will contain the result of the transformation.
 fastcosinetransform(a, tnn, inversefct) 
  Returns Fast Discrete Cosine Transform
  Parameters:
     a (float ) : float , This is a floating-point array representing the sequence of values (time-domain) that you want to transform. The function will perform the Fast Cosine Transform (FCT) or the inverse FCT on this input array, depending on the value of the inversefct parameter. The transformed result will also be stored in this same array, which means the function modifies the input array in-place.
     tnn (int) : int, This is an integer value representing the number of data points in the input array a. It is used to determine the size of the input array and control the loops in the algorithm. Note that the size of the input array should be a power of 2 for the Fast Cosine Transform algorithm to work correctly.
     inversefct (bool) : bool, This is a boolean value that controls whether the function performs the regular Fast Cosine Transform or the inverse FCT. If inversefct is set to true, the function will perform the inverse FCT, and if set to false, the regular FCT will be performed. The inverse FCT can be used to transform data back into its original form (time-domain) after the regular FCT has been applied.
  Returns: float , The resulting transformed array is stored in the input array a. This means that the function modifies the input array in-place and does not return a new array.
 fastconvolution(signal, signallen, response, negativelen, positivelen) 
  Convolution using FFT
  Parameters:
     signal (float ) : float , This is an array of real numbers representing the input signal that will be convolved with the response function. The elements are numbered from 0 to SignalLen-1.
     signallen (int) : int, This is an integer representing the length of the input signal array. It specifies the number of elements in the signal array.
     response (float ) : float , This is an array of real numbers representing the response function used for convolution. The response function consists of two parts: one corresponding to positive argument values and the other to negative argument values. Array elements with numbers from 0 to NegativeLen match the response values at points from -NegativeLen to 0, respectively. Array elements with numbers from NegativeLen+1 to NegativeLen+PositiveLen correspond to the response values in points from 1 to PositiveLen, respectively.
     negativelen (int) : int, This is an integer representing the "negative length" of the response function. It indicates the number of elements in the response function array that correspond to negative argument values. Outside the range  , the response function is considered zero.
     positivelen (int) : int, This is an integer representing the "positive length" of the response function. It indicates the number of elements in the response function array that correspond to positive argument values. Similar to negativelen, outside the range  , the response function is considered zero.
  Returns: float , The resulting convolved values are stored back in the input signal array.
 fastcorrelation(signal, signallen, pattern, patternlen) 
  Returns Correlation using FFT
  Parameters:
     signal (float ) : float ,This is an array of real numbers representing the signal to be correlated with the pattern. The elements are numbered from 0 to SignalLen-1.
     signallen (int) : int, This is an integer representing the length of the input signal array.
     pattern (float ) : float , This is an array of real numbers representing the pattern to be correlated with the signal. The elements are numbered from 0 to PatternLen-1.
     patternlen (int) : int, This is an integer representing the length of the pattern array.
  Returns: float , The signal array containing the correlation values at points from 0 to SignalLen-1.
 tworealffts(a1, a2, a, b, tn) 
  Returns Fast Fourier Transform of Two Real Functions
  Parameters:
     a1 (float ) : float , An array of real numbers, representing the values of the first function.
     a2 (float ) : float , An array of real numbers, representing the values of the second function.
     a (float ) : float , An output array to store the Fourier transform of the first function.
     b (float ) : float , An output array to store the Fourier transform of the second function.
     tn (int) : float , An integer representing the number of function values. It must be a power of two, but the algorithm doesn't validate this condition.
  Returns: float , The a and b arrays will contain the Fourier transform of the first and second functions, respectively. Note that the function overwrites the input arrays a and b.
 █ Detailed explaination of each function  
 Fast Fourier Transform 
The fastfouriertransform() function takes three input parameters:
1. a: An array of real and imaginary parts of the function values. The real part is stored at even indices, and the imaginary part is stored at odd indices.
2. nn: The number of function values. It must be a power of two, but the algorithm does not validate this.
3. inversefft: A boolean value that indicates the direction of the transformation. If True, it performs the inverse FFT; if False, it performs the direct FFT.
The function performs the FFT using the Cooley-Tukey algorithm, which is an efficient algorithm for computing the discrete Fourier transform (DFT) and its inverse. The Cooley-Tukey algorithm recursively breaks down the DFT of a sequence into smaller DFTs of subsequences, leading to a significant reduction in computational complexity. The algorithm's time complexity is O(n log n), where n is the number of samples.
The fastfouriertransform() function first initializes variables and determines the direction of the transformation based on the inversefft parameter. If inversefft is True, the isign variable is set to -1; otherwise, it is set to 1.
Next, the function performs the bit-reversal operation. This is a necessary step before calculating the FFT, as it rearranges the input data in a specific order required by the Cooley-Tukey algorithm. The bit-reversal is performed using a loop that iterates through the nn samples, swapping the data elements according to their bit-reversed index.
After the bit-reversal operation, the function iteratively computes the FFT using the Cooley-Tukey algorithm. It performs calculations in a loop that goes through different stages, doubling the size of the sub-FFT at each stage. Within each stage, the Cooley-Tukey algorithm calculates the butterfly operations, which are mathematical operations that combine the results of smaller DFTs into the final DFT. The butterfly operations involve complex number multiplication and addition, updating the input array a with the computed values.
The loop also calculates the twiddle factors, which are complex exponential factors used in the butterfly operations. The twiddle factors are calculated using trigonometric functions, such as sine and cosine, based on the angle theta. The variables wpr, wpi, wr, and wi are used to store intermediate values of the twiddle factors, which are updated in each iteration of the loop.
Finally, if the inversefft parameter is True, the function divides the result by the number of samples nn to obtain the correct inverse FFT result. This normalization step is performed using a loop that iterates through the array a and divides each element by nn.
In summary, the fastfouriertransform() function is an implementation of the Cooley-Tukey FFT algorithm, which is an efficient algorithm for computing the DFT and its inverse. This FFT library can be used for a variety of applications, such as signal processing, image processing, audio processing, and more.
 Feal Fast Fourier Transform 
The realfastfouriertransform() function performs a fast Fourier transform (FFT) specifically for real-valued functions. The FFT is an efficient algorithm used to compute the discrete Fourier transform (DFT) and its inverse, which are fundamental tools in signal processing, image processing, and other related fields.
This function takes three input parameters:
1. a - A float array containing the real-valued function samples.
2. tnn - The number of function values (must be a power of 2, but the algorithm does not validate this condition).
3. inversefft - A boolean flag that indicates the direction of the transformation (True for inverse, False for direct).
The function modifies the input array a in-place, meaning that the transformed data (the FFT result for direct transformation or the inverse FFT result for inverse transformation) will be stored in the same array a after the function execution.
The algorithm uses a combination of complex-to-complex FFT and additional transformations specific to real-valued data to optimize the computation. It takes into account the symmetry properties of the real-valued input data to reduce the computational complexity.
Here's a detailed walkthrough of the algorithm:
1. Depending on the inversefft flag, the initial values for ttheta, c1, and c2 are determined. These values are used for the initial data preprocessing and post-processing steps specific to the real-valued FFT.
2. The preprocessing step computes the initial real and imaginary parts of the data using a combination of sine and cosine terms with the input data. This step effectively converts the real-valued input data into complex-valued data suitable for the complex-to-complex FFT.
3. The complex-to-complex FFT is then performed on the preprocessed complex data. This involves bit-reversal reordering, followed by the Cooley-Tukey radix-2 decimation-in-time algorithm. This part of the code is similar to the fastfouriertransform() function you provided earlier.
4. After the complex-to-complex FFT, a post-processing step is performed to obtain the final real-valued output data. This involves updating the real and imaginary parts of the transformed data using sine and cosine terms, as well as the values c1 and c2.
5. Finally, if the inversefft flag is True, the output data is divided by the number of samples (nn) to obtain the inverse DFT.
The function does not return a value explicitly. Instead, the transformed data is stored in the input array a. After the function execution, you can access the transformed data in the a array, which will have the real part at even indices and the imaginary part at odd indices.
 Fast Sine Transform 
This code defines a function called fastsinetransform that performs a Fast Discrete Sine Transform (FST) on an array of real numbers. The function takes three input parameters:
1. a (float array): An array of real numbers representing the function values.
2. tnn (int): Number of function values (must be a power of two, but the code doesn't validate this).
3. inversefst (bool): A boolean flag indicating the direction of the transformation. If True, it performs the inverse FST, and if False, it performs the direct FST.
The output is the transformed array 'a', which will contain the result of the transformation.
The code starts by initializing several variables, including trigonometric constants for the sine transform. It then sets the first value of the array 'a' to 0 and calculates the initial values of 'y1' and 'y2', which are used to update the input array 'a' in the following loop.
The first loop (with index 'jx') iterates from 2 to (tm + 1), where 'tm' is half of the number of input samples 'tnn'. This loop is responsible for calculating the initial sine transform of the input data.
The second loop (with index 'ii') is a bit-reversal loop. It reorders the elements in the array 'a' based on the bit-reversed indices of the original order.
The third loop (with index 'ii') iterates while 'n' is greater than 'mmax', which starts at 2 and doubles each iteration. This loop performs the actual Fast Discrete Sine Transform. It calculates the sine transform using the Danielson-Lanczos lemma, which is a divide-and-conquer strategy for calculating Discrete Fourier Transforms (DFTs) efficiently.
The fourth loop (with index 'ix') is responsible for the final phase adjustments needed for the sine transform, updating the array 'a' accordingly.
The fifth loop (with index 'jj') updates the array 'a' one more time by dividing each element by 2 and calculating the sum of the even-indexed elements.
Finally, if the 'inversefst' flag is True, the code scales the transformed data by a factor of 2/tnn to get the inverse Fast Sine Transform.
In summary, the code performs a Fast Discrete Sine Transform on an input array of real numbers, either in the direct or inverse direction, and returns the transformed array. The algorithm is based on the Danielson-Lanczos lemma and uses a divide-and-conquer strategy for efficient computation.
 Fast Cosine Transform 
This code defines a function called fastcosinetransform that takes three parameters: a floating-point array a, an integer tnn, and a boolean inversefct. The function calculates the Fast Cosine Transform (FCT) or the inverse FCT of the input array, depending on the value of the inversefct parameter.
The Fast Cosine Transform is an algorithm that converts a sequence of values (time-domain) into a frequency domain representation. It is closely related to the Fast Fourier Transform (FFT) and can be used in various applications, such as signal processing and image compression.
Here's a detailed explanation of the code:
1. The function starts by initializing a number of variables, including counters, intermediate values, and constants.
2. The initial steps of the algorithm are performed. This includes calculating some trigonometric values and updating the input array a with the help of intermediate variables.
3. The code then enters a loop (from jx = 2 to tnn / 2). Within this loop, the algorithm computes and updates the elements of the input array a.
4. After the loop, the function prepares some variables for the next stage of the algorithm.
5. The next part of the algorithm is a series of nested loops that perform the bit-reversal permutation and apply the FCT to the input array a.
6. The code then calculates some additional trigonometric values, which are used in the next loop.
7. The following loop (from ix = 2 to tnn / 4 + 1) computes and updates the elements of the input array a using the previously calculated trigonometric values.
8. The input array a is further updated with the final calculations.
9. In the last loop (from j = 4 to tnn), the algorithm computes and updates the sum of elements in the input array a.
10. Finally, if the inversefct parameter is set to true, the function scales the input array a to obtain the inverse FCT.
The resulting transformed array is stored in the input array a. This means that the function modifies the input array in-place and does not return a new array.
 Fast Convolution 
This code defines a function called fastconvolution that performs the convolution of a given signal with a response function using the Fast Fourier Transform (FFT) technique. Convolution is a mathematical operation used in signal processing to combine two signals, producing a third signal representing how the shape of one signal is modified by the other.
The fastconvolution function takes the following input parameters:
1. float  signal: This is an array of real numbers representing the input signal that will be convolved with the response function. The elements are numbered from 0 to SignalLen-1.
2. int signallen: This is an integer representing the length of the input signal array. It specifies the number of elements in the signal array.
3. float  response: This is an array of real numbers representing the response function used for convolution. The response function consists of two parts: one corresponding to positive argument values and the other to negative argument values. Array elements with numbers from 0 to NegativeLen match the response values at points from -NegativeLen to 0, respectively. Array elements with numbers from NegativeLen+1 to NegativeLen+PositiveLen correspond to the response values in points from 1 to PositiveLen, respectively.
4. int negativelen: This is an integer representing the "negative length" of the response function. It indicates the number of elements in the response function array that correspond to negative argument values. Outside the range  , the response function is considered zero.
5. int positivelen: This is an integer representing the "positive length" of the response function. It indicates the number of elements in the response function array that correspond to positive argument values. Similar to negativelen, outside the range  , the response function is considered zero.
The function works by:
1. Calculating the length nl of the arrays used for FFT, ensuring it's a power of 2 and large enough to hold the signal and response.
2. Creating two new arrays, a1 and a2, of length nl and initializing them with the input signal and response function, respectively.
3. Applying the forward FFT (realfastfouriertransform) to both arrays, a1 and a2.
4. Performing element-wise multiplication of the FFT results in the frequency domain.
5. Applying the inverse FFT (realfastfouriertransform) to the multiplied results in a1.
6. Updating the original signal array with the convolution result, which is stored in the a1 array.
The result of the convolution is stored in the input signal array at the function exit.
 Fast Correlation 
This code defines a function called fastcorrelation that computes the correlation between a signal and a pattern using the Fast Fourier Transform (FFT) method. The function takes four input arguments and modifies the input signal array to store the correlation values.
Input arguments:
1. float  signal: This is an array of real numbers representing the signal to be correlated with the pattern. The elements are numbered from 0 to SignalLen-1.
2. int signallen: This is an integer representing the length of the input signal array.
3. float  pattern: This is an array of real numbers representing the pattern to be correlated with the signal. The elements are numbered from 0 to PatternLen-1.
4. int patternlen: This is an integer representing the length of the pattern array.
The function performs the following steps:
1. Calculate the required size nl for the FFT by finding the smallest power of 2 that is greater than or equal to the sum of the lengths of the signal and the pattern.
2. Create two new arrays a1 and a2 with the length nl and initialize them to 0.
3. Copy the signal array into a1 and pad it with zeros up to the length nl.
4. Copy the pattern array into a2 and pad it with zeros up to the length nl.
5. Compute the FFT of both a1 and a2.
6. Perform element-wise multiplication of the frequency-domain representation of a1 and the complex conjugate of the frequency-domain representation of a2.
7. Compute the inverse FFT of the result obtained in step 6.
8. Store the resulting correlation values in the original signal array.
At the end of the function, the signal array contains the correlation values at points from 0 to SignalLen-1.
 Fast Fourier Transform of Two Real Functions 
This code defines a function called tworealffts that computes the Fast Fourier Transform (FFT) of two real-valued functions (a1 and a2) using a Cooley-Tukey-based radix-2 Decimation in Time (DIT) algorithm. The FFT is a widely used algorithm for computing the discrete Fourier transform (DFT) and its inverse.
Input parameters:
1. float  a1: an array of real numbers, representing the values of the first function.
2. float  a2: an array of real numbers, representing the values of the second function.
3. float  a: an output array to store the Fourier transform of the first function.
4. float  b: an output array to store the Fourier transform of the second function.
5. int tn: an integer representing the number of function values. It must be a power of two, but the algorithm doesn't validate this condition.
The function performs the following steps:
1. Combine the two input arrays, a1 and a2, into a single array a by interleaving their elements.
2. Perform a 1D FFT on the combined array a using the radix-2 DIT algorithm.
3. Separate the FFT results of the two input functions from the combined array a and store them in output arrays a and b.
Here is a detailed breakdown of the radix-2 DIT algorithm used in this code:
1. Bit-reverse the order of the elements in the combined array a.
2. Initialize the loop variables mmax, istep, and theta.
3. Enter the main loop that iterates through different stages of the FFT.
a. Compute the sine and cosine values for the current stage using the theta variable.
b. Initialize the loop variables wr and wi for the current stage.
c. Enter the inner loop that iterates through the butterfly operations within each stage.
i. Perform the butterfly operation on the elements of array a.
ii. Update the loop variables wr and wi for the next butterfly operation.
d. Update the loop variables mmax, istep, and theta for the next stage.
4. Separate the FFT results of the two input functions from the combined array a and store them in output arrays a and b.
At the end of the function, the a and b arrays will contain the Fourier transform of the first and second functions, respectively. Note that the function overwrites the input arrays a and b.
 █ Example scripts using functions contained in loxxfft 
Real-Fast Fourier Transform of Price w/ Linear Regression  
  
Real-Fast Fourier Transform of Price Oscillator  
  
Normalized, Variety, Fast Fourier Transform Explorer  
  
Variety RSI of Fast Discrete Cosine Transform  
  
STD-Stepped Fast Cosine Transform Moving Average  
 
Cari dalam skrip untuk "one一季度财报"
Descending Elliot Wave Patterns [theEccentricTrader]█   OVERVIEW 
This indicator automatically draws descending Elliot Wave patterns and price projections derived from the ranges that constitute the patterns. 
█   CONCEPTS 
 Green and Red Candles 
• A green candle is one that closes with a close price equal to or above the price it opened.
• A red candle is one that closes with a close price that is lower than the price it opened.
 Swing Highs and Swing Lows 
• A swing high is a green candle or series of consecutive green candles followed by a single red candle to complete the swing and form the peak.
• A swing low is a red candle or series of consecutive red candles followed by a single green candle to complete the swing and form the trough.
 Peak and Trough Prices (Basic) 
• The peak price of a complete swing high is the high price of either the red candle that completes the swing high or the high price of the preceding green candle, depending on which is higher.
• The trough price of a complete swing low is the low price of either the green candle that completes the swing low or the low price of the preceding red candle, depending on which is lower.
 Historic Peaks and Troughs 
The current, or most recent, peak and trough occurrences are referred to as occurrence zero. Previous peak and trough occurrences are referred to as historic and ordered numerically from right to left, with the most recent historic peak and trough occurrences being occurrence one.
 Range 
The range is simply the difference between the current peak and current trough prices, generally expressed in terms of points or pips.
 Support and Resistance 
• Support refers to a price level where the demand for an asset is strong enough to prevent the price from falling further.
• Resistance refers to a price level where the supply of an asset is strong enough to prevent the price from rising further.
Support and resistance levels are important because they can help traders identify where the price of an asset might pause or reverse its direction, offering potential entry and exit points. For example, a trader might look to buy an asset when it approaches a support level , with the expectation that the price will bounce back up. Alternatively, a trader might look to sell an asset when it approaches a resistance level , with the expectation that the price will drop back down.
It's important to note that support and resistance levels are not always relevant, and the price of an asset can also break through these levels and continue moving in the same direction. 
 Upper Trends 
• A return line uptrend is formed when the current peak price is higher than the preceding peak price.
• A downtrend is formed when the current peak price is lower than the preceding peak price.
• A double-top is formed when the current peak price is equal to the preceding peak price.
 Lower Trends 
• An uptrend is formed when the current trough price is higher than the preceding trough price.
• A return line downtrend is formed when the current trough price is lower than the preceding trough price.
• A double-bottom is formed when the current trough price is equal to the preceding trough price.
 Muti-Part Upper and Lower Trends 
• A multi-part return line uptrend begins with the formation of a new return line uptrend, or higher peak, and continues until a new downtrend, or lower peak, completes the trend.
• A multi-part downtrend begins with the formation of a new downtrend, or lower peak, and continues until a new return line uptrend, or higher peak, completes the trend.
• A multi-part uptrend begins with the formation of a new uptrend, or higher trough, and continues until a new return line downtrend, or lower trough, completes the trend.
• A multi-part return line downtrend begins with the formation of a new return line downtrend, or lower trough, and continues until a new uptrend, or higher trough, completes the trend. 
 Double Trends 
• A double uptrend is formed when the current trough price is higher than the preceding trough price and the current peak price is higher than the preceding peak price.
• A double downtrend is formed when the current peak price is lower than the preceding peak price and the current trough price is lower than the preceding trough price.
 Muti-Part Double Trends 
• A multi-part double uptrend begins with the formation of a new uptrend that proceeds a new return line uptrend, and continues until a new downtrend or return line downtrend ends the trend.
• A multi-part double downtrend begins with the formation of a new downtrend that proceeds a new return line downtrend, and continues until a new uptrend or return line uptrend ends the trend. 
 Wave Cycles 
A wave cycle is here defined as a complete two-part move between a swing high and a swing low, or a swing low and a swing high. The first swing high or swing low will set the course for the sequence of wave cycles that follow; for example a chart that begins with a swing low will form its first complete wave cycle upon the formation of the first complete swing high and vice versa. 
Figure 1.
 Fibonacci Retracement and Extension Ratios 
The Fibonacci sequence is a series of numbers in which each number is the sum of the two preceding numbers, starting with 0 and 1. For example 0 + 1 = 1, 1 + 1 = 2, 1 + 2 = 3, and so on. Ultimately, we could go on forever but the first few numbers in the sequence are as follows: 0 , 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144.
The extension ratios are calculated by dividing each number in the sequence by the number preceding it. For example 0/1 = 0, 1/1 = 1, 2/1 = 2, 3/2 = 1.5, 5/3 = 1.6666..., 8/5 = 1.6, 13/8 = 1.625, 21/13 = 1.6153..., 34/21 = 1.6190..., 55/34 = 1.6176..., 89/55 = 1.6181..., 144/89 = 1.6179..., and so on. The retracement ratios are calculated by inverting this process and dividing each number in the sequence by the number proceeding it. For example 0/1 = 0, 1/1 = 1, 1/2 = 0.5, 2/3 = 0.666..., 3/5 = 0.6, 5/8 = 0.625, 8/13 = 0.6153..., 13/21 = 0.6190..., 21/34 = 0.6176..., 34/55 = 0.6181..., 55/89 = 0.6179..., 89/144 = 0.6180..., and so on.
1.618 is considered to be the 'golden ratio', found in many natural phenomena such as the growth of seashells and the branching of trees. Some now speculate the universe oscillates at a frequency of 0,618 Hz, which could help to explain such phenomena, but this theory has yet to be proven.
Traders and analysts use Fibonacci retracement and extension indicators, consisting of horizontal lines representing different Fibonacci ratios, for identifying potential levels of support and resistance. Fibonacci ranges are typically drawn from left to right, with retracement levels representing ratios inside of the current range and extension levels representing ratios extended outside of the current range. If the current wave cycle ends on a swing low, the Fibonacci range is drawn from peak to trough. If the current wave cycle ends on a swing high the Fibonacci range is drawn from trough to peak.
 Elliot Wave Patterns 
Ralph Nelson Elliott, authored his book on Elliott wave theory titled "The Wave Principle" in 1938. In this book, Elliott presented his theory of market behaviour, which he believed reflected the natural laws that govern human behaviour. 
The Elliott Wave Theory is based on the principle that waves have a tendency to unfold in a specific sequence of five waves in the direction of the trend, followed by three waves leading in the opposite direction. This pattern is called a 5-3 wave pattern and is the foundation of Elliott's theory.
The five waves in the direction of the trend are labelled 1, 2, 3, 4, and 5, while the three waves in the opposite direction are labelled A, B, and C. Waves 1, 3, and 5 are impulse waves, while waves 2 and 4 are corrective waves. Waves A and C are also corrective waves, while wave B is an impulse wave.
According to Elliott, the pattern of waves is fractal in nature, meaning that it occurs on all time frames, from the smallest to the largest. 
In Elliott Wave Theory, the distance that waves move from each other depends on the specific market conditions and the amplitude of the waves involved. There is no fixed rule or limit for how far waves should move from each other, however, there are several guidelines to help identify and measure wave distances. One of the most common guidelines is the Fibonacci ratios, which can be used to describe the relationships between wave lengths. For example, Elliott identified that wave 3 is typically the strongest and longest wave, and it tends to be 1.618 times the length of wave 1. Meanwhile, wave 2 tends to retrace between 50% and 78.6% of wave 1, and wave 4 tends to retrace between 38.2% and 78.6% of wave 3. 
In general, the patterns are quite rare and the distances that the waves move in relation to one another is subject to interpretation. For such reasons, I have simply included the ratios of the current ranges as ratios of the preceding ranges in the wave labels and it will, ultimately, be up to the user to decide whether or not the patterns qualify as valid. 
█   FEATURES 
 Inputs 
• Show Projections
• Pattern Color
• Label Color
• Extend Current Projection Lines
█   LIMITATIONS 
All green and red candle calculations are based on differences between open and close prices, as such I have made no attempt to account for green candles that gap lower and close below the close price of the preceding candle, or red candles that gap higher and close above the close price of the preceding candle. This may cause some unexpected behaviour on some markets and timeframes. I can only recommend using 24-hour markets, if and where possible, as there are far fewer gaps and, generally, more data to work with.
Ascending Elliot Wave Patterns [theEccentricTrader]█   OVERVIEW 
This indicator automatically draws ascending Elliot Wave patterns and price projections derived from the ranges that constitute the patterns. 
█   CONCEPTS 
 Green and Red Candles 
• A green candle is one that closes with a close price equal to or above the price it opened.
• A red candle is one that closes with a close price that is lower than the price it opened.
 Swing Highs and Swing Lows 
• A swing high is a green candle or series of consecutive green candles followed by a single red candle to complete the swing and form the peak.
• A swing low is a red candle or series of consecutive red candles followed by a single green candle to complete the swing and form the trough.
 Peak and Trough Prices (Basic) 
• The peak price of a complete swing high is the high price of either the red candle that completes the swing high or the high price of the preceding green candle, depending on which is higher.
• The trough price of a complete swing low is the low price of either the green candle that completes the swing low or the low price of the preceding red candle, depending on which is lower.
 Historic Peaks and Troughs 
The current, or most recent, peak and trough occurrences are referred to as occurrence zero. Previous peak and trough occurrences are referred to as historic and ordered numerically from right to left, with the most recent historic peak and trough occurrences being occurrence one.
 Range 
The range is simply the difference between the current peak and current trough prices, generally expressed in terms of points or pips.
 Support and Resistance 
• Support refers to a price level where the demand for an asset is strong enough to prevent the price from falling further.
• Resistance refers to a price level where the supply of an asset is strong enough to prevent the price from rising further.
Support and resistance levels are important because they can help traders identify where the price of an asset might pause or reverse its direction, offering potential entry and exit points. For example, a trader might look to buy an asset when it approaches a support level , with the expectation that the price will bounce back up. Alternatively, a trader might look to sell an asset when it approaches a resistance level , with the expectation that the price will drop back down.
It's important to note that support and resistance levels are not always relevant, and the price of an asset can also break through these levels and continue moving in the same direction. 
 Upper Trends 
• A return line uptrend is formed when the current peak price is higher than the preceding peak price.
• A downtrend is formed when the current peak price is lower than the preceding peak price.
• A double-top is formed when the current peak price is equal to the preceding peak price.
 Lower Trends 
• An uptrend is formed when the current trough price is higher than the preceding trough price.
• A return line downtrend is formed when the current trough price is lower than the preceding trough price.
• A double-bottom is formed when the current trough price is equal to the preceding trough price.
 Muti-Part Upper and Lower Trends 
• A multi-part return line uptrend begins with the formation of a new return line uptrend, or higher peak, and continues until a new downtrend, or lower peak, completes the trend.
• A multi-part downtrend begins with the formation of a new downtrend, or lower peak, and continues until a new return line uptrend, or higher peak, completes the trend.
• A multi-part uptrend begins with the formation of a new uptrend, or higher trough, and continues until a new return line downtrend, or lower trough, completes the trend.
• A multi-part return line downtrend begins with the formation of a new return line downtrend, or lower trough, and continues until a new uptrend, or higher trough, completes the trend. 
 Double Trends 
• A double uptrend is formed when the current trough price is higher than the preceding trough price and the current peak price is higher than the preceding peak price.
• A double downtrend is formed when the current peak price is lower than the preceding peak price and the current trough price is lower than the preceding trough price.
 Muti-Part Double Trends 
• A multi-part double uptrend begins with the formation of a new uptrend that proceeds a new return line uptrend, and continues until a new downtrend or return line downtrend ends the trend.
• A multi-part double downtrend begins with the formation of a new downtrend that proceeds a new return line downtrend, and continues until a new uptrend or return line uptrend ends the trend. 
 Wave Cycles 
A wave cycle is here defined as a complete two-part move between a swing high and a swing low, or a swing low and a swing high. The first swing high or swing low will set the course for the sequence of wave cycles that follow; for example a chart that begins with a swing low will form its first complete wave cycle upon the formation of the first complete swing high and vice versa. 
Figure 1.
 Fibonacci Retracement and Extension Ratios 
The Fibonacci sequence is a series of numbers in which each number is the sum of the two preceding numbers, starting with 0 and 1. For example 0 + 1 = 1, 1 + 1 = 2, 1 + 2 = 3, and so on. Ultimately, we could go on forever but the first few numbers in the sequence are as follows: 0 , 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144.
The extension ratios are calculated by dividing each number in the sequence by the number preceding it. For example 0/1 = 0, 1/1 = 1, 2/1 = 2, 3/2 = 1.5, 5/3 = 1.6666..., 8/5 = 1.6, 13/8 = 1.625, 21/13 = 1.6153..., 34/21 = 1.6190..., 55/34 = 1.6176..., 89/55 = 1.6181..., 144/89 = 1.6179..., and so on. The retracement ratios are calculated by inverting this process and dividing each number in the sequence by the number proceeding it. For example 0/1 = 0, 1/1 = 1, 1/2 = 0.5, 2/3 = 0.666..., 3/5 = 0.6, 5/8 = 0.625, 8/13 = 0.6153..., 13/21 = 0.6190..., 21/34 = 0.6176..., 34/55 = 0.6181..., 55/89 = 0.6179..., 89/144 = 0.6180..., and so on.
1.618 is considered to be the 'golden ratio', found in many natural phenomena such as the growth of seashells and the branching of trees. Some now speculate the universe oscillates at a frequency of 0,618 Hz, which could help to explain such phenomena, but this theory has yet to be proven.
Traders and analysts use Fibonacci retracement and extension indicators, consisting of horizontal lines representing different Fibonacci ratios, for identifying potential levels of support and resistance. Fibonacci ranges are typically drawn from left to right, with retracement levels representing ratios inside of the current range and extension levels representing ratios extended outside of the current range. If the current wave cycle ends on a swing low, the Fibonacci range is drawn from peak to trough. If the current wave cycle ends on a swing high the Fibonacci range is drawn from trough to peak.
 Elliot Wave Patterns 
Ralph Nelson Elliott, authored his book on Elliott wave theory titled "The Wave Principle" in 1938. In this book, Elliott presented his theory of market behaviour, which he believed reflected the natural laws that govern human behaviour. 
The Elliott Wave Theory is based on the principle that waves have a tendency to unfold in a specific sequence of five waves in the direction of the trend, followed by three waves leading in the opposite direction. This pattern is called a 5-3 wave pattern and is the foundation of Elliott's theory.
The five waves in the direction of the trend are labelled 1, 2, 3, 4, and 5, while the three waves in the opposite direction are labelled A, B, and C. Waves 1, 3, and 5 are impulse waves, while waves 2 and 4 are corrective waves. Waves A and C are also corrective waves, while wave B is an impulse wave.
According to Elliott, the pattern of waves is fractal in nature, meaning that it occurs on all time frames, from the smallest to the largest. 
In Elliott Wave Theory, the distance that waves move from each other depends on the specific market conditions and the amplitude of the waves involved. There is no fixed rule or limit for how far waves should move from each other, however, there are several guidelines to help identify and measure wave distances. One of the most common guidelines is the Fibonacci ratios, which can be used to describe the relationships between wave lengths. For example, Elliott identified that wave 3 is typically the strongest and longest wave, and it tends to be 1.618 times the length of wave 1. Meanwhile, wave 2 tends to retrace between 50% and 78.6% of wave 1, and wave 4 tends to retrace between 38.2% and 78.6% of wave 3. 
In general, the patterns are quite rare and the distances that the waves move in relation to one another is subject to interpretation. For such reasons, I have simply included the ratios of the current ranges as ratios of the preceding ranges in the wave labels and it will, ultimately, be up to the user to decide whether or not the patterns qualify as valid. 
█   FEATURES 
 Inputs 
• Show Projections
• Pattern Color
• Label Color
• Extend Current Projection Lines
█   LIMITATIONS 
All green and red candle calculations are based on differences between open and close prices, as such I have made no attempt to account for green candles that gap lower and close below the close price of the preceding candle, or red candles that gap higher and close above the close price of the preceding candle. This may cause some unexpected behaviour on some markets and timeframes. I can only recommend using 24-hour markets, if and where possible, as there are far fewer gaps and, generally, more data to work with.
Degen Dominator - (Crypto Dominance Tool) - [mutantdog]A fairly simple one this time. Another crypto dominance tool, consider it a sequel to Dominion if you will. Ready to go out-of-the-box with a selection of presets at hand.
The premise is straightforward, rather than viewing the various marketcap dominance indexes as their standard percentage values, here we have them represented as basic oscillators. This allows for multiple indexes to be viewed in one pane and gives a decent overview of their relative changes and thus the flow of capital within the overall crypto market. As a general rule-of-thumb, when a plot is above zero then the dominance is climbing, thus capital is likely flowing in that direction. The inverse applies when below zero. When the market is quiet, all will be close to zero. Basic overbought/oversold conditions can also be inferred too. 
Active as default are:
 
 Bitcoin  (0range):    CRYPTOCAP:BTC.D 
 Ethereum  (Blue):    CRYPTOCAP:ETH.D 
 Stablecoins  (Red):    CRYPTOCAP:USDT.D  +  CRYPTOCAP:USDC.D 
 Altcoins  (Green):    100 - (all of the above) 
These are plotted according to the selected oscillator preset and it's length parameter. The default is set to 'EMA Centre'. An optional RMA(3) smoothing filter is also included and active as default. Each index plot has its own colour and opacity settings available on the main page.
Additionally, the following are also available (deactivated as default):
 Total DeFi :    CRYPTOCAP:TOTALDEFI.D 
 Current Symbol :    Will try to match corresponding dominance index for the chart symbol if available. 
 Custom Input :    Manual text input, will try to match if available. 
 
-------------
The included presets determine the oscillator type used, all are fairly simple and easy to interpret:
 
 EMA Centre
 SMA Centre
 Median Centre
 Midrange Centre
 The first 4 are all variations on the same theme, simply calculated as the difference between the actual value and its respective average. EMA is the default and is my personal preference, if you generally favour using an SMA then perhaps that would be your better choice. Like the two MAs, median and midrange are also dependant on the length parameter. Midrange is calculated from the difference between highest and lowest values within the length period, with a little extra smoothing from an RMA(3).
 Simple Delta
 Weighted Delta
 Running Delta 
Often referred to as momentum, delta is just change over time. 'Simple' is the most basic of these, the difference between the current value and the value (length) bars prior. A more long-winded way of calculating this would be to take the difference between each bar and its previous then average them with an SMA which results in the same value. 'Weighted' adopts that principle but instead uses a WMA, likewise 'Running' is the same but using an RMA. The latter is actually the basis of RSI calculations before any normalisation is applied, as you can see in the next preset.
 RSI
 CMO 
RSI really should not need explaining, it is however applied a little differently here to the usual, in this case centred around 0. The x100 multiplication factor has been dropped too for the sake of consistency. The same principle applies with CMO, which is basically a 'Simple Delta' version of RSI.
 
 Hard Floor
 Soft Floor 
 
These last two are a little different but both can provide useful interpretations. The floor here is simply the lowest value within the chosen length period. 'Hard' plots the difference between the current value and the floor, thus giving a value that is always above 0. In this case, focus should be given to the relative heights of each with a simple interpretation that capital is flowing into those that are climbing and out of those descending. 'Soft' is essentially the same except that the floor is smoothed with an RMA(3), the result being that when new lows are made, the plot will break below 0 before the floor corrects a few bars later. This soft break provides additional information to that given by 'Hard' so is probably the more useful of the two.
------------
To finish it off, a bunch of preset alerts are included for the various 0 crossings.
So that just about covers everything then, all quite straightforward really. Future updates may include some extra stuff, the composition of the stablecoin index may change if necessary too. While this is not really a tweaker's tool like some of my other projects, there's still some room for experimentation here. The 'current' and 'custom' indexes can provide some useful data for compatible altcoins and the possibility to compare inter-related tokens (eg: Doge vs Shib). While i introduced this as a sort of sequel to Dominion, it is not intended as a replacement but more of a companion. This initially started as a feature intended for that one but it quickly grew into its own thing. Both the oscillator view here and the more traditional view have merits, i personally use this one primarily now but frequently refer to Dominion for confirmations etc.
That's it for now anyway. As always, feedback is welcome below. Enjoy!
Candle Trend Counter [theEccentricTrader]█   OVERVIEW 
This indicator counts the number of confirmed candle trend scenarios on any given candlestick chart and displays the statistics in a table, which can be repositioned and resized at the user's discretion.
█   CONCEPTS 
 Green and Red Candles 
• A green candle is one that closes with a high price equal to or above the price it opened.
• A red candle is one that closes with a low price that is lower than the price it opened.
 Swing Highs and Swing Lows 
• A swing high is a green candle or series of consecutive green candles followed by a single red candle to complete the swing and form the peak.
• A swing low is a red candle or series of consecutive red candles followed by a single green candle to complete the swing and form the trough. 
 Muti-Part Green and Red Candle Trends 
• A multi-part green candle trend begins upon the completion of a swing low and continues until a red candle completes the swing high, with each green candle counted as a part of the trend.
• A multi-part red candle trend begins upon the completion of a swing high and continues until a green candle completes the swing low, with each red candle counted as a part of the trend.
█   FEATURES 
 Inputs 
    Start Date
    End Date
    Position
    Text Size
    Show Sample Period
    Show Plots
 Table 
The table is colour coded, consists of seven columns and, as many as, thirty-one rows. Blue cells denote the multi-part candle trend scenarios, green cells denote the corresponding green candle trend scenarios and red cells denote the corresponding red candle trend scenarios.
The candle trend scenarios are listed in the first column with their corresponding total counts to the right, in the second column. The last row in column one, displays the sample period which can be adjusted or hidden via indicator settings.
The third column displays the total candle trend scenarios as percentages of total 1-candle trends, or complete swing highs and swing lows. And column four displays the total candle trend scenarios as percentages of the, last, or preceding candle trend part. For example 4-candle trends as a percentage of 3-candle trends. This offers more insight into what might happen next at any given point in time. 
 Plots 
I have added plots as a visual aid to the various candle trend scenarios listed in the table. Green up-arrows, with the number of the trend part, denote green candle trends. Red down-arrows, with the number of the trend part, denote red candle trends.
█   HOW TO USE 
This indicator is intended for research purposes, strategy development and strategy optimisation. I hope it will be useful in helping to gain a better understanding of the underlying dynamics at play on any given market and timeframe. 
It can, for example, give you an idea of whether the next candle will close higher or lower than it opened, based on the current scenario and what has happened in the past under similar circumstances. Such information can be very useful when conducting top down analysis across multiple timeframes and making strategic decisions.
What you do with these statistics and how far you decide to take your research is entirely up to you, the possibilities are endless.
█   LIMITATIONS 
Some higher timeframe candles on tickers with larger lookbacks such as the DXY , do not actually contain all the open, high, low and close (OHLC) data at the beginning of the chart. Instead, they use the close price for open, high and low prices. So, while we can determine whether the close price is higher or lower than the preceding close price, there is no way of knowing what actually happened intra-bar for these candles. And by default candles that close at the same price as the open price, will be counted as green. You can avoid this problem by utilising the sample period filter.
The green and red candle calculations are based solely on differences between open and close prices, as such I have made no attempt to account for green candles that gap lower and close below the close price of the preceding candle, or red candles that gap higher and close above the close price of the preceding candle. I can only recommend using 24-hour markets, if and where possible, as there are far fewer gaps and, generally, more data to work with. Alternatively, you can replace the scenarios with your own logic to account for the gap anomalies, if you are feeling up to the challenge.
It is also worth noting that the sample size will be limited to your Trading View subscription plan. Premium users get 20,000 candles worth of data, pro+ and pro users get 10,000, and basic users get 5,000. If upgrading is currently not an option, you can always keep a rolling tally of the statistics in an excel spreadsheet or something of the like. 
Bitwise, Encode, DecodeLibrary   "Bitwise, Encode, Decode" 
Bitwise, Encode, Decode, and more Library
 docs() 
      Hover-Over Documentation for inside Text Editor
 bAnd(a, b) 
  Returns the bitwise AND of two integers  
  Parameters:
     a : `int` - The first integer
     b : `int` - The second integer
  Returns: `int` - The bitwise AND of the two integers
 bOr(a, b) 
  Performs a bitwise OR operation on two integers.  
  Parameters:
     a : `int` - The first integer.
     b : `int` - The second integer.
  Returns: `int` - The result of the bitwise OR operation.
 bXor(a, b) 
  Performs a bitwise Xor operation on two integers.  
  Parameters:
     a : `int` - The first integer.
     b : `int` - The second integer.
  Returns: `int` - The result of the bitwise Xor operation.
 bNot(n) 
  Performs a bitwise NOT operation on an integer.  
  Parameters:
     n : `int` - The integer to perform the bitwise NOT operation on.
  Returns: `int` - The result of the bitwise NOT operation.
 bShiftLeft(n, step) 
  Performs a bitwise left shift operation on an integer.  
  Parameters:
     n : `int` - The integer to perform the bitwise left shift operation on.
     step : `int` - The number of positions to shift the bits to the left.
  Returns: `int` - The result of the bitwise left shift operation.
 bShiftRight(n, step) 
  Performs a bitwise right shift operation on an integer.  
  Parameters:
     n : `int` - The integer to perform the bitwise right shift operation on.
     step : `int` - The number of bits to shift by.
  Returns: `int` - The result of the bitwise right shift operation.
 bRotateLeft(n, step) 
  Performs a bitwise right shift operation on an integer.
  Parameters:
     n : `int` - The int to perform the bitwise Left rotation on the bits.                        
     step : `int` - The number of bits to shift by.
  Returns: `int`- The result of the bitwise right shift operation.
 bRotateRight(n, step) 
  Performs a bitwise right shift operation on an integer.
  Parameters:
     n : `int` - The int to perform the bitwise Right rotation on the bits.
     step : `int` - The number of bits to shift by.
  Returns: `int` - The result of the bitwise right shift operation.
 bSetCheck(n, pos) 
  Checks if the bit at the given position is set to 1.
  Parameters:
     n : `int` - The integer to check.
     pos : `int` - The position of the bit to check.
  Returns: `bool` - True if the bit is set to 1, False otherwise.
 bClear(n, pos) 
  Clears a particular bit of an integer (changes from 1 to 0) passes if bit at pos is 0.
  Parameters:
     n : `int` - The integer to clear a bit from.
     pos : `int` - The zero-based index of the bit to clear.
  Returns: `int` - The result of clearing the specified bit.
 bFlip0s(n) 
  Flips all 0 bits in the number to 1.
  Parameters:
     n : `int` - The integer to flip the bits of.
  Returns: `int` - The result of flipping all 0 bits in the number.
 bFlip1s(n) 
  Flips all 1 bits in the number to 0.
  Parameters:
     n : `int` - The integer to flip the bits of.
  Returns: `int` - The result of flipping all 1 bits in the number.
 bFlipAll(n) 
  Flips all bits in the number.
  Parameters:
     n : `int` - The integer to flip the bits of.
  Returns: `int` - The result of flipping all bits in the number.
 bSet(n, pos, newBit) 
  Changes the value of the bit at the given position.
  Parameters:
     n : `int` - The integer to modify.
     pos : `int` - The position of the bit to change.
     newBit : `int` - na = flips bit at pos reguardless 1 or 0 | The new value of the bit (0 or 1).
  Returns: `int` - The modified integer.
 changeDigit(n, pos, newDigit) 
  Changes the value of the digit at the given position.
  Parameters:
     n : `int` - The integer to modify.
     pos : `int` - The position of the digit to change.
     newDigit : `int` - The new value of the digit (0-9).
  Returns: `int` - The modified integer.
 bSwap(n, i, j) 
  Switch the position of 2 bits of an int
  Parameters:
     n : `int` - int to manipulate
     i : `int` - bit pos to switch with j
     j : `int` - bit pos to switch with i
  Returns: `int` - new int with bits switched
 bPalindrome(n) 
  Checks to see if the binary form is a Palindrome (reads the same left to right and vice versa)
  Parameters:
     n : `int` - int to check
  Returns: `bool` - result of check
 bEven(n) 
  Checks if n is Even
  Parameters:
     n : `int` - The integer to check.
  Returns: `bool` - result.
 bOdd(n) 
  checks if n is Even if not even Odd
  Parameters:
     n : `int` - The integer to check.
  Returns: `bool` - result.
 bPowerOfTwo(n) 
  Checks if n is a Power of 2.
  Parameters:
     n : `int` - number to check.
  Returns: `bool` - result.
 bCount(n, to_count) 
  Counts the number of bits that are equal to 1 in an integer.
  Parameters:
     n : `int` - The integer to count the bits in.
     to_count  `string` -   the bits to count
  Returns: `int` - The number of bits that are equal to 1 in n.
 GCD(a, b) 
  Finds the greatest common divisor (GCD) of two numbers.
  Parameters:
     a : `int` - The first number.
     b : `int` - The second number.
  Returns: `int` - The GCD of a and b.
 LCM(a, b) 
  Finds the least common multiple (LCM) of two integers.
  Parameters:
     a : `int` - The first integer.
     b : `int` - The second integer.
  Returns: `int` - The LCM of a and b.
 aLCM(nums) 
  Finds the LCM of an array of integers.
  Parameters:
     nums : `int ` - The list of integers.
  Returns: `int` - The LCM of the integers in nums.
 adjustedLCM(nums, LCM) 
  adjust an array of integers to Least Common Multiple (LCM)
  Parameters:
     nums : `int ` - The first integer
     LCM : `int` - The second integer
  Returns: `int ` - array of ints with LCM
 charAt(str, pos) 
  gets a Char at a given position.
  Parameters:
     str : `string` - string to pull char from.
     pos : `int` - pos to get char from string (left to right index).
  Returns: `string` - char from pos of string or "" if pos is not within index range
 decimalToBinary(num) 
  Converts a decimal number to binary
  Parameters:
     num : `int` - The decimal number to convert to binary
  Returns: `string` - The binary representation of the decimal number
 decimalToBinary(num, to_binary_int) 
  Converts a decimal number to binary
  Parameters:
     num : `int` - The decimal number to convert to binary
     to_binary_int : `bool` - bool to convert to int or to string (true for int, false for string)
  Returns: `string` - The binary representation of the decimal number
 binaryToDecimal(binary) 
  Converts a binary number to decimal
  Parameters:
     binary : `string` - The binary number to convert to decimal
  Returns: `int` - The decimal representation of the binary number
 decimal_len(n) 
  way of finding decimal length using arithmetic
  Parameters:
     n  `float` - floating decimal point to get length of.
  Returns: `int` - number of decimal places
 int_len(n) 
  way of finding number length using arithmetic
  Parameters:
     n : `int`- value to find length of number
  Returns: `int` - lenth of nunber i.e. 23 == 2
 float_decimal_to_whole(n) 
  Converts a float decimal number to an integer `0.365 to 365`.
  Parameters:
     n : `string` - The decimal number represented as a string.
  Returns: `int` - The integer obtained by removing the decimal point and leading zeroes from s.
 fractional_part(x) 
  Returns the fractional part of a float.
  Parameters:
     x : `float` - The float to get the fractional part of.
  Returns: `float` - The fractional part of the float.
 form_decimal(a, b, zero_fix) 
  helper to form 2 ints into 1 float seperated by the decimal
  Parameters:
     a : `int` - a int
     b : `int` - b int
     zero_fix : `bool` - fix for trailing zeros being truncated when converting to float
  Returns: ` ` - float = float decimal of ints | string = string version of b for future use to ref length
 bEncode(n1, n2) 
  Encodes two numbers into one using bit OR. (fastest)
  Parameters:
     n1 : `int` - The first number to Encodes.
     n2 : `int` - The second number to Encodes.
  Returns: `int` - The result of combining the two numbers using bit OR.
 bDecode(n) 
  Decodes an integer created by the bCombine function.(fastest)
  Parameters:
     n : `int` - The integer to decode.
  Returns: ` ` - A tuple containing the two decoded components of the integer.
 Encode(a, b) 
  Encodes by seperating ints into left and right of decimal float
  Parameters:
     a : `int` - a int
     b : `int` - b int
  Returns: `float` - new float of encoded ints one on left of decimal point one on right
 Decode(encoded) 
  Decodes float of 2 ints seperated by decimal point
  Parameters:
     encoded : `float` - the encoded float value
  Returns: ` ` - tuple of the 2 ints from encoded float
 encode_heavy(a, b) 
  Encodes by combining numbers and tracking size in the
decimal of a floating number (slowest)
  Parameters:
     a : `int` - a int
     b : `int` - b int
  Returns: `float` - new decimal of encoded ints
 decode_heavy(encoded) 
  Decodes encoded float that tracks size of ints in float decimal 
  Parameters:
     encoded : `float` - encoded float
  Returns: ` ` - tuple of decoded ints
 decimal of float (slowest) 
  Parameters:
     encoded : `float` - the encoded float value
  Returns: ` ` - tuple of the 2 ints from encoded float
 Bitwise, Encode, Decode Docs  
 
  In the documentation you may notice the word decimal   
not used as normal this is because when referring to   
binary a decimal number is a number that  
can be represented with base 10 numbers 0-9   
(the wiki below explains better)  
  A rule of thumb for the two integers being   
encoded it to keep both numbers   
less than 65535 this is because anything lower uses 16 bits or less   
this will maintain 100% accuracy when decoding   
although it is possible to do numbers up to 2147483645 with   
this library doesnt seem useful enough  
to explain or demonstrate.  
  The functions provided work within this 32-bit range,   
where the highest number is all 1s and   
the lowest number is all 0s. These functions were created   
to overcome the lack of built-in bitwise functions in Pinescript.   
By combining two integers into a single number,  
the code can access both values i.e when   
indexing only one array index  
for a matrices row/column, thus improving execution time.   
This technique can be applied to various coding   
scenarios to enhance performance.  
  Bitwise functions are a way to use integers in binary form      
that can be used to speed up several different processes      
most languages have operators to perform these function such as      
`<<, >>, &, ^, |, ~` 
 
 en.wikipedia.org  
Divergence for Many [Dimkud - v5]Strategy is based on "Divergence for Many Indicators v4 ST" strategy by CannyTolany01
which is based on "Divergence for Many Indicator" indicator by LonesomeTheBlue
This strategy is searching for divergences on 18 indicators which you can select and optimise one by one.
Additionally you can connect any other External Indicator value. (just add this indicator the the chart and select option in settings)
To the original indicator/strategy I have added 9 additional indicators:
( Money Flow Index, Williams_Vix, Stochastic RSI , SMI Ergodic Oscillator, Volume Weighted MACD , Bull Bear Power, Balance of Power , Relative Volatility Index , Logistic Settings).
Converted strategy to v5 of Pine Script.
Added Static SL/TP in percents (%).
Added filters to filter enters:
1. Volume Weighted MACD - Multi-TimeFrame Filter
(It checks for histogram to falling or rising for a set periods of bars)
2. Money Flow Index - Multi-TimeFrame Filter
(It checks if MFI Oscillator is in the set diapason.
Also It checks if MFI is falling or rising for a set periods of bars )
3. ATR filter
(check changes in fast ATR to slow ATR )
Strategy shows good backtest results on many crypto tokens on 45m - 1h periods. (with parameters optimisation for every indicator)
To find best parameters - you can enable indicators one-by one, and optimise best parameters for each of them.
Then enable all indicators with successful results.
Optimise SL/TP.
Then try to enable and optimise filters (channels etc.)
The better is to optimise parameters separately for Short and Long trading. And run two separate bots (in settings enable only Long or only Short.)
Updates:
- Added visualisation for open trades (SL/TP)
- Added Volatility filter by ATR with many options for tests.
- Fixed some small bugs.
- Added second RSI filter (you can use two RSIs with different TF or settings)
- Updated ATR volatility and MFI filter. Removed non-effective options
- Added CCI filter
- Added option to Enable/Disable visualisation of TP/SL on chart
- Fixed one small quick bug. ("ATR filter short" was not working)
- Added Super Trend filter
- Added Momentum filter
- Added Volume Filter
- All "request.security" MultiTimeFrame calls changed to 100% non-repait function "f_security()"
RSIOMA with Volume Index ConfirmationThis indicator is called "RSIOMA with Volume Index Confirmation". It is a technical analysis tool that plots buy and sell signals on a chart based on the Relative Strength Index (RSI) and the Negative Volume Index (NVI) and Positive Volume Index (PVI) indicators.
The indicator has the following input parameters:
- RSI Length: determines the number of periods used to calculate the RSI. Default value is 14.
- Overbought Level: determines the RSI level at which a security is considered overbought. Default value is 70.
- Oversold Level: determines the RSI level at which a security is considered oversold. Default value is 30.
- NVI Length: determines the number of periods used to calculate the Negative Volume Index. Default value is 255.
- PVI Length: determines the number of periods used to calculate the Positive Volume Index. Default value is 255.
The indicator calculates the RSI using the RSI Length input parameter and the close price of the security. It also calculates the NVI and PVI by looping through the volume data and the close price data of the security over the specified periods.
The indicator then uses the RSI, NVI, and PVI to determine buy and sell signals. A bearish divergence signal is generated when the RSI from one period ago is greater than the Overbought Level, the current RSI is less than the Overbought Level, and the close price from one period ago is greater than the current close price. A bullish divergence signal is generated when the RSI from one period ago is less than the Oversold Level, the current RSI is greater than the Oversold Level, and the close price from one period ago is less than the current close price. A sell signal is generated when a bearish divergence signal occurs and the current NVI is less than the previous NVI value. A buy signal is generated when a bullish divergence signal occurs and the current PVI is greater than the previous PVI value.
The indicator plots the buy and sell signals on the chart as green and red triangles, respectively. The "overlay=true" parameter in the indicator function indicates that the signals are plotted on top of the security's price chart.
Strategy: Range BreakoutWhat? 
In the price action, levels have a significant role to play. Based on the price moving above/below the levels - the underlying instrument shows some price-action in the direction of breakout/breakdown.
There are plenty of ways level can be determined. Levels are the decision point to take a trade or not.  But  if we make the level derivation complex, then the execution may get hamper. 
This strategy script, developed in PineScript v5, is our attempt at solving this problem at the core by providing this simple, yet elegant solution to this problem.
It's essentially an attempt to  Trade Simple  by drawing logical (horizontal) lines in the chart and take actions, after multiple associated parameters confirmation, on the  breakout  /  breakdown  of the levels.
 How? 
Let us explain how we are drawing the levels. 
We are depending on some of the parameters as described below:
 
   Open Range : During intraday movement, often if prices move beyond a particular level, it exibits more movement in the same swing in same direction. We found out, through our back testing for Indian Indices like  NSE:NIFTY ,  NSE:BANKNIFTY  or  NSE:CNXFINANCE  the first 15m (i.e 09:15 AM to 09:30 AM, IST) is one of such range. For Indian stocks, it is 9:15 to 9:45. And for MCX  MCX:CRUDEOIL1!  it's 5:00 pm to 6:00 pm. There are our first levels.
   PDHCL : Previous Day High, Close, Low. This is our next level
   VWAP : The rolling VWAP (volume weighted average price)
 
In the breakout/breakdown of the Open Range and Previous Day High/Low, we are taking the trade decisions as follows using  CEST  principle:
 C onditions : 
  If current bar's (say you are in 5m timeframe) closing is broken out the Open Range High or Previous Day High, taken a Buy/Long decision (let's say buying a Call Option CE or selling a Put Option PE or buying the future or cash).
  If current bar's (say you are in 5m timeframe) closing is broken down the Open Range Low or Previous Day Low, taken a Sell/Short decision (let's say buying a Put Option CE or selling a Call Option PE or selling the future or cash).
  Additionally, and optionally (default ON, one can turn off): we are checking various other associated multiple confirmations as follows:
         1.  Momentum : Checking 14-period RSI value is more than 50 or less than 50 (all parameters like period, OB, OS ranges are configurable through settings)
         2. Current bar's volume is more than the last 20 bars volume average. How much more - that multiplier is also configurable. (default is 1)
         3. The breakout candle is bullish (green) or bearish (red).
 E ntry : 
  All of these happens  only on the closing of the candle . Means:  Non Repainting! . 
  Clearly in the chart we are showing as green up arrow BO (breakout for buy) and red down arrow BD (breakdown for sell) to take your decision process smooth.
  So, on the closing of the decision BO/BD candle we are entering the trade (with a thumping heart and nail biting ...)
 S top Loss : 
  We are relying on the time tasted (last 40 years) mechanism of Average True Range (ATR) of default 14 period. This default period is also configurable. 
  So for Long trades: the 14 period ATR low band is the SL.
  For Short trades: the 14 period ATR high band is the SL.
 T arget : 
  We are depending on the thump rule of 1:2 Risk Reward. It's simple and effective. No fancy thing. We are closing the trade on double the favorable price movement compared to the SL placed. Of course, this RR ratio is confiurable from the settings, as usual.
 
 What's Unqiue in it? 
The  utter simplicity  of this trading mechanism. No fancy things like complex chart pattern, OI data, multiple candlestick patterns, Order flow analysis etc. 
  Simple level determination, 
  Marking clearly in the chart.
  Making each parameter configurable in Settings and showing tooltip adjacent to the parameter to make you understand it better for your customization,
  Wait for the candle close, thus eliminating the chances of repainting menace (as much as possible)
  Additional momentum and volume check to trade entry confirmation.
  Works with normal candlestick (nothing special ones like HA ...)
  Showing everything as a  Summary Table  (which, again can be turned off optionally) overlaying at the bottom-right corner of the chart,
  Optionally the Summary Table can be configured to alert you back (say you get it notified in your email or SMS).
That way, a single, simple, effective trade setup will ease your journey as smooth sail as possible. 
 Mentions 
  There are plenty of friends from whom time to time we borrowed some of the ideas while working closely together over last one year. 
  From tradingview community, we took the spirit of @zzzcrypto123 awesome work done long back (in 2020) as the indicator "ORB - Opening Range Breakout". (We tried to reach him for his explicit consent, unable to catch hold of him).
  Some other publicly available materials we have consulted to get the additional checks (like RSI, volume).
 Lat word 
Use it please and thank you for your constant patronage in following us in this awesome platform. Let's keep growing together. 
 Disclaimer :
This piece of software does not come up with any warrantee or any rights of not changing it over the future course of time.
We are not responsible for any trading/investment decision you are taking out of the outcome of this indicator.
Strategy Myth-Busting #5 - POKI+GTREND+ADX - [MYN]This is part of a new series we are calling "Strategy Myth-Busting" where we take open public manual trading strategies and automate them. The goal is to not only validate the authenticity of the claims but to provide an automated version for traders who wish to trade autonomously.
Our fifth one we are automating is one of the strategies from "The Best 3 Buy And Sell Indicators on Tradingview + Confirmation Indicators ( The Golden Ones ))" from "Online Trading Signals (Scalping Channel)". No formal backtesting was done by them and resuructo messaged me asking if we could validate their claims.
Originally, we mimic verbatim the settings Online Trading Signals was using however weren't getting promising results. So before we stopped there we thought we might want to see if this could be improved on. So we adjusted the Renko Assignment modifier from ATR to Traditional and adjusted the value to be higher from 30 to 47. We also decided to try adding another signal confirmation to eliminate some of the ranged market conditions so we choose our favorite, ADX . Also, given we are using this on a higher time-frame we adjusted the G-Channel Trend detection source from close to OHLC4 to get better average price action indication and more accurate trend direction.
This strategy uses a combination of 2 open-source public indicators:
 poki buy and sell Take profit and stop loss  by RafaelZioni
 G-Channel Trend Detection  by jaggedsoft
Trading Rules
15m - 4h timeframe. We saw best results at the recommended 1 hour timeframe.
Long Entry:
When POKI triggers a buy signal
When G-Channel Trend Detection is in an upward trend (Green)
ADX Is above 25
Short Entry:
When POKI triggers a sell signal
When G-Channel Trend Detection is in an downward trend (red)
ADX Is above 25
If you know of or have a strategy you want to see myth-busted or just have an idea for one, please feel free to message me.
Flying Dragon Trend IndicatorFlying Dragon Trend Indicator can be used to indicate the trend on all timeframes by finetuning the input settings.
The Flying Dragon Trend family includes both the strategy and the indicator, where the strategy supports of selecting the optimal set of inputs for the indicator in each scenario. Highly recommended to get familiar with the strategy first to get the best out of the indicator.
Flying Dragon Trend plots the trend bands into the ribbon, where the colours indicate the trend of each band. The plotting of the bands can be turned off in the input settings. Based on the user selectable Risk Level the trend pivot indicator is shown for the possible trend pivot when the price crosses the certain moving average line, or at the Lowest risk level all the bands have the same colour. The trend pivot indicator is not shown on the Lowest risk level, but the colour of the trend bands is the indicator instead . 
The main idea is to combine two different moving averages to cross each other at the possible trend pivot point, but trying to avoid any short term bounces to affect the trend indication. The ingenuity resides in the combination of selected moving average types, lengths and especially the offsets. The trend bands give visual hint for the user while observing the price interaction with the bands, one could say that when "the Dragon swallows the candles the jaws wide open", then there is high possibility for the pivot. The leading moving average should be fast while the lagging moving average should be, well, lagging behind the leading one. There is Offset selections for each moving average, three for leading one and one for the lagging one, those are where the magic happens. After user has selected preferred moving average types and lengths, by tuning each offset the optimal sweet spot for each timeframe and equity will be found. The default values are good enough starting points for longer (4h and up) timeframes, but shorter timeframes (minutes to hours) require different combination of settings, some hints are provided in tooltips. Basically the slower the "leading" moving average (like HMA75 or HMA115) and quicker the "lagging" moving average (like SMA12 or SMA5) become, the better performance at the Lowest risk level on minute scales. This "reversed" approach at the minute scales is shown also as reversed colour for the "lagging" moving average trend band, which seems to make it work surprisingly well.
The Flying Dragon Trend does not necessarily work well on zig zag and range bounce scenarios without additional finetuning of the input settings to fit the current condition.
Flying Dragon Trend StrategyFlying Dragon Trend Strategy can be used to indicate the trend on all timeframes by finetuning the input settings.
The Flying Dragon Trend family includes both the strategy and the indicator, where the strategy supports of selecting the optimal set of inputs for the indicator in each scenario. Highly recommended to get familiar with the strategy first to get the best out of the indicator.
Flying Dragon Trend plots the trend bands into the ribbon, where the colours indicate the trend of each band. The plotting of the bands can be turned off in the input settings. Based on the user selectable Risk Level the strategy is executed when the price crosses the certain moving average line, or at the Lowest risk level all the bands have the same colour.
The main idea is to combine two different moving averages to cross each other at the possible trend pivot point, but trying to avoid any short term bounces to affect the trend indication. The ingenuity resides in the combination of selected moving average types, lengths and especially the offsets. The trend bands give visual hint for the user while observing the price interaction with the bands, one could say that when "the Dragon swallows the candles the jaws wide open", then there is high possibility for the pivot. The leading moving average should be fast while the lagging moving average should be, well, lagging behind the leading one. There is Offset selections for each moving average, three for leading one and one for the lagging one, those are where the magic happens. After user has selected preferred moving average types and lengths, by tuning each offset the optimal sweet spot for each timeframe and equity will be found. The default values are good enough starting points for longer (4h and up) timeframes, but shorter timeframes (minutes to hours) require different combination of settings, some hints are provided in tooltips. Basically the slower the "leading" moving average (like HMA75 or HMA115) and quicker the "lagging" moving average (like SMA12 or SMA5) become, the better performance at the Lowest risk level on minute scales. This "reversed" approach at the minute scales is shown also as reversed colour for the "lagging" moving average trend band, which seems to make it work surprisingly well.
The Flying Dragon Trend does not necessarily work well on zig zag and range bounce scenarios without additional finetuning of the input settings to fit the current condition.
Strategy direction selector by DashTrader.
Immediate Trend - VHXIMMEDIATE TREND - VULNERABLE_HUMAN_X 
This indicator is used to identify the immediate trend in the market. 
When a Short Term High (STH) is engulfed and closed above, we consider that as a bullish trend. 
And Similarly, when a Short Term Low (STL) is engulfed and closed below, we consider that as a bullish trend. 
STH - A candle that is higher than the one candle towards it's left and one candle towards it's right. 
STL - A candle that is lower than the one candle towards it's left and one candle towards it's right. 
HOW TO USE:
1. Do not take trades purely based on the immediate trend showcased by the indicator. Rather, use them as confluence with your trading strategy. 
2. When you are expecting price to reverse at your point of interest (Denamd/Supply zone), this indicator can help you predict the reversal by showcasing the current trend. 
3. Using this indicator you can travel the trend as long as there is a change of trend predicted by this indicator. 
Profitunity - Beginner [TC]This indicator aggregates the knowledges of the first level of the Trading Chaos approach by Bill Williams. It uses the Market Facilitation Index (MFI) in conjunction with the type of bar(candle) to generate strong long and strong short signals. 
 General information 
 Bars numeration  
All bars or candles could be numbered with the following algorithm. If we divide the candle for 3 equal parts from high to low. The highest third have the number 1, the middle one - 2, the lowest one - 3. Hence we can define the first number as the number of the third where the price opened, second - where the price closed. For example, if the price opened at the highest third and closed at the lowest one this candle has the number 13. 
 Trend defining 
Also candles could be divided into three groups according to the trend condition: uptrend, downtrend, sideways. If the middle of the candle's trading range is above the high of the previous candle - it's uptrend candle, if below the low of the previous candle - it's downtrend candle, sideways in other candles.
 Profitunity windows 
According to Bill Williams MFI has 4 windows - fake, green, fade and squat. I am not going to describe here the methodology of MFI, but one thing you should know that the most valuable windows are green and squat. Green state is an indication of the true move on the market. Squat the sign that the increase in volume have not triggered the trend continuation and reverse is about to happen. 
 How to use? 
You can use this script as the helper in automatic defining the type of candle. Indicator shows only green (green candle color) and squat (red candle color) MFI states. Add script to any timeframe and asset chart to see labels. 
 The "strong long" label flashes when 3 conditions are met:  
1. Squat candle
2. Candle number 13
3. Downtrend candle
 "Strong short" label flashes when: 
1. Squat candle 
2. Candle number 31
3. Uptrend candle
This indicator helps to find the trend reversal points, can be used in conjunction with other TA tools to find the entry points.
Day Trading Booster by DGTTiming when day trading can be everything 
In  Stock markets  typically more volatility (or price activity) occurs at market opening and closings  
 
When it comes to  Forex  (foreign exchange market),  the world’s most traded market, unlike other financial markets, there is no centralized marketplace, currencies trade over the counter in whatever market is open at that time, where time becomes of more importance and key to get better trading opportunities. There are four major forex trading sessions, which are  Sydney ,  Tokyo ,  London  and  New York  sessions 
Forex market is traded 24 hours a day, 5 days a week across by banks, institutions and individual traders worldwide, but that doesn’t mean it’s always active the entire day.  It may be very difficult time trying to make money when the market doesn’t move at all. The busiest times with highest trading volume occurs during the overlap of the London and New York trading sessions, because U.S. dollar (USD) and the Euro (EUR) are the two most popular currencies traded. Typically most of the trading activity for a specific currency pair will occur when the trading sessions of the individual currencies overlap. For example, Australian Dollar (AUD) and Japanese Yen (JPY) will experience a higher trading volume when both Sydney and Tokyo sessions are open
There is one influence that impacts Forex matkets and should not be forgotten : the release of the significant news and reports. When a major announcement is made regarding economic data, currency can lose or gain value within a matter of seconds
 Cryptocurrency markets  on the other hand remain open 24/7, even during public holidays
Until 2021, the Asian impact was so significant in Cryptocurrency markets but recent reasearch reports shows that those patterns have changed and the correlation with the U.S. trading hours is becoming a clear evolving trend. 
Unlike any other market Crypto doesn’t rest on weekends, there’s a drop-off in participation and yet algorithmic trading bots and market makers (or liquidity providers) can create a high volume of activity. Never trust the weekend’ is a good thing to remind yourself
One more factor that needs to be taken into accout is Blockchain transaction fees, which are responsive to network congestion and can change dramatically from one hour to the next
In general, Cryptocurrency markets are highly volatile, which means that the price of a coin can change dramatically over a short time period in either direction
 The Bottom Line 
The more traders trading, the higher the trading volume, and the more active the market. The more active the market, the higher the liquidity (availability of counterparties at any given time to exit or enter a trade), hence the tighter the spreads (the difference between ask and bid price) and the less slippage (the difference between the expected fill price and the actual fill price) - in a nutshell, yield to many good trading opportunities and better order execution (a process of filling the requested buy or sell order)
The best time to trade is when the market is the most active and therefore has the largest trading volume, trading all day long will not only deplete a trader's reserves quickly, but it can burn out even the most persistent trader. Knowing when the markets are more active will give traders peace of mind, that opportunities are not slipping away when they take their eyes off the markets or need to get a few hours of sleep
 What does the Day Trading Booster do? 
Day Trading Booster is designed ;
  - to assist in determining market peak times, the times where better trading opportunities may arise
  - to assist in determining the probable trading opportunities
  - to help traders create their own strategies. An example strategy of when to trade or not is presented below
For Forex markets specifically includes
  - Opening channel of Asian session, Europien session or both  
  - Opening price, opening range (5m or 15m) and day (session) range of the major trading center sessions, including Frankfurt
  - A tabular view of the major forex markets oppening/closing hours, with a countdown timer
  - A graphical presentation of typically traded volume and various forext markets oppening/clossing events (not only the major markets but many other around the world)
For All type of markets Day Trading Booster plots 
   - Day (Session) Open, 5m, 15m or 1h Opening Range 
   - Day (Session) Referance Levels, based on Average True Range (ATR) or Previous Day (Session) Range (PH - PL)
   - Week and Month Open
Day Trading Booster also includes some of the day trader's preffered indicaotrs, such as ;
   - VWAP - A custom interpretaion of VWAP is presented here with Auto, Interactive and Manual anchoring options. 
   - Pivot High/Low detection - Another custom interpretation of Pivot Points High Low indicator.  
   - A Moving Average with option to choose among SMA, EMA, WMA and HMA
 An example strategy - Channel Bearkout Strategy 
When day trading a trader usually monitors/analyzes lower timeframe charts and from time to time may loose insight of what really happens on the market from higher time porspective.  Do not to forget to look at the larger time frame (than the one chosen to trade with) which gives the bigger picture of market price movements and thus helps to clearly define the trend
 Disclaimer : Trading success is all about following your trading strategy and the indicators should fit within your trading strategy, and not to be traded upon solely
The script is for informational and educational purposes only. Use of the script does not constitutes professional and/or financial advice. You alone the sole responsibility of evaluating the script output and risks associated with the use of the script. In exchange for using the script, you agree not to hold dgtrd TradingView user liable for any possible claim for damages arising from any decision you make based on use of the script
TMO ScalperTMO - (T)rue (M)omentum (O)scillator) MTF Scalper Version
TMO Scalper is a special custom version of the popular TMO Oscillator. Scalper version was designed specifically for the lower time frames (1-5min intraday scalps). This version prints in the signals directly on top of the oscillator only when the higher aggregations are aligned with the current aggregation (the big wheels must be spinning in order for a small wheel to spin). The scalper consist of three MTF TMO oscillators. First one is the one that plot signals (should be the fastest aggregation), second serves as a short term trend gauge (good rule of thumb is to us 2-5x of the chart time frame or the first aggregation). The third one (optional) is shaded in the background & should only serve as a trend gauge for the day (usually higher time frames 30min+).
Time Frames Preffered by Traders:
1. 1m / 5m / 30m - This one is perfect for catching the fastest moves. However, during choppy days the 1min can produce more false signals..
2. 2m / 10m / 30m - Healthy middle, the 2min aggregation nicely smooths out the 1min mess. Short term gauge is turning slowly (10min for a signal to confirm).
3. 3m / 30m / 60m - This TF is awesome for day traders that prefer to take it slow. Obviously, this combination will produce far less signals during the day.
Hope it helps.
Price Correction to fix data manipulation and mispricingPrice Correction corrects for index and security mispricing to the extent possible in TradingView on both daily and intraday charts.   Price correction addresses mispricing issues for specific securities with known issues, or the user can build daily candles from intraday data instead of relying on exchange reported daily OHLC prices, which can include both legitimate special auction and off-exchange trades or illegitimate mispricing.  The user can also detect daily OHLC prices that don’t reflect the intraday price action within a specified percent deviation.  Price Correction functions as normal candles or bars for any time frame when correction is not needed.
On the 4th of October 2022, the AMEX exchange, owned by the New York Stock Exchange, decided to misprice the daily OHLC data for the SPY, the world’s largest ETF fund.  The exchange eliminated the overnight gap that should have occurred in the daily chart that represents regular trading hours by showing a wick connecting near the close of the previous day.  Neither the SPX, the SP500 cash index that the SPY ETF tracks, nor other SPX ETFs such as VOO or IVV show such a wick because significant price action at that level never occurred.  The intraday SPY chart never shows the price drop below 372.31 that day, but there is a wick that extends to 366.57.  On the 6th of October, they continued this practice of using a wick that connects with the close of the previous day to eliminate gaps in daily price action.  The objective of this indicator is to fix such inconsistent mispricing practices in the SPY, NYA, and other indices or securities.
Price Correction corrects for the daily mispricing in the SPY to agree with the price action that actually occurred in the SPX index it tracks, as well as the other SPX ETFs, by using intraday data.  The chart below compares the Price Correction of the SPY (top) to the SPX (middle) and the original mispriced SPY (bottom) with incorrect wicks.  Price correction (top) removes those incorrect wicks (bottom) to match the SPX (middle).
  
The daily mispricing of the SPY follows after the successful deployment of the NYSE Composite Index mispricing, NYA, an index that represents all common stocks within the New York Stock Exchange, the largest exchange in the world.  The importance of the NYA should not be understated.  It is the price counterpart to NYSE’s market internals or statistics.  Beginning in 2021, the New York Stock Exchange eliminated gaps in daily OHLC data for the NYA by using the close of the previous day as the open for the following day, in violation of their own NYSE Index Series Methodology.  The Methodology states for the opening price that “The first index level is calculated and published around 09:30 ET, when the U.S. equity markets open for their regular trading session. The calculation of that level utilizes the most updated prices available at that moment.”  You can verify for yourself that this is simply not the case. The first update of the NYA price for each day matches the close of the previous day, not the “most updated prices available at that moment”, causing data providers to often represent the first intraday bar with a huge sudden price change when an overnight price change occurred instead.  For example, on 13 Jun 2022, TradingView shows a one-minute bar drop 2.3%. With a market capitalization of roughly 23 trillion dollars, the NYSE composite capitalization did not suddenly drop a half-trillion dollars in just one minute as the intraday chart data would have you believe. All major US indices, index ETFs, and even foreign indices like the Toronto TAX, the Australian ASXAL, the Bombay SENSEX, and German DAX had down gaps that day, except for the mispriced NYSE index.  Price Correction corrects for this mispricing in daily OHLC data, as shown in the main chart at the top of this page comparing the original NYA (top) to the Price Corrected NYA (bottom).
Price Correction also corrects for the intraday mispricing in the NYA.  The chart below shows how the Price Correction (top) replaces the incorrect first one-minute candles with gaps (bottom) from 22 Sep 2022 to 29 Sep 2022.  TradingView is inconsistent in how intraday data is reported for overnight gaps by sometimes connecting the first intraday bar of the day to the close of the previous day, and other times not.  This inconsistency may be due to manually changing the intraday data based on user support tickets.  For example, after reporting the lack of a major gap in the NYA daily OHLC prices that existed intraday for 13 Jun 2022, TradingView opted to remove the true gap in intraday prices by creating a 2.3% half-a-trillion-dollar one-minute bar that connected the close of the previous day to show a sudden drop in price that didn’t occur, instead of adding the gap in the daily OHLC data that actually took place from overnight price action.
  
Price Correction allows users to detect daily OHLC data that does not reflect the intraday price action within a certain percent difference by changing the color of those candles or bars that deviate.  The chart below clearly shows the start of the NYSE disinformation campaign for NYA that started in 2021 by painting blue those candles with daily OHLC values that deviated from the intraday values by 0.1%.  Before 2021, the number of deviating candles is relatively sparse, but beginning in 2021, the chart is littered with deviating candles.
  
If there are other index or security mispricing or data issues you are aware of that can be incorporated into Price Correction, please let me know.  Accurate financial data is indispensable in making accurate financial decisions.  Assert your right to accurate financial data by reporting incorrect data and mispricing issues.
How to use the Price Correction
Simply add this “indicator” to your chart and remove the mispriced default candles or bars by right clicking on the chart, selecting Settings, and de-selecting Body, Wick, and Border under the Symbol tab.  The Presets settings automatically takes care of mispricing in the NYA and SPY to the extent possible in TradingView.   The user can also build their own daily candles based off of intraday data to address other securities that may have mispricing issues.
cbndLibrary   "cbnd" 
 Description: 
A standalone Cumulative Bivariate Normal Distribution (CBND) functions that do not require any external libraries. 
This includes 3 different CBND calculations: Drezner(1978), Drezner and Wesolowsky (1990), and Genz (2004)
 Comments: 
The standardized cumulative normal distribution function returns the probability that one random 
variable is less than a and that a second random variable is less than b when the correlation 
between the two variables is p. Since no closed-form solution exists for the bivariate cumulative 
normal distribution, we present three approximations. The first one is the well-known 
Drezner (1978) algorithm. The second one is the more efficient Drezner and Wesolowsky (1990) 
algorithm. The third is the Genz (2004) algorithm, which is the most accurate one and therefore
our recommended algorithm. West (2005b) and Agca and Chance (2003) discuss the speed and 
accuracy of bivariate normal distribution approximations for use in option pricing in 
ore detail.
 Reference: 
The Complete Guide to Option Pricing Formulas, 2nd ed. (Espen Gaarder Haug)
 CBND1(A, b, rho) 
  Returns the Cumulative Bivariate Normal Distribution (CBND) using Drezner 1978 Algorithm
  Parameters:
     A : float, 
     b : float, 
     rho : float, 
  Returns: float.
 CBND2(A, b, rho) 
  Returns the Cumulative Bivariate Normal Distribution (CBND) using Drezner and Wesolowsky (1990) function
  Parameters:
     A : float, 
     b : float, 
     rho : float, 
  Returns: float.
 CBND3(x, y, rho) 
  Returns the Cumulative Bivariate Normal Distribution (CBND) using Genz (2004) algorithm (this is the preferred method)
  Parameters:
     x : float, 
     y : float, 
     rho : float, 
  Returns: float.
Cox-Ross-Rubinstein Binomial Tree Options Pricing Model [Loxx]Cox-Ross-Rubinstein Binomial Tree Options Pricing Model   is an options pricing panel calculated using an N-iteration (limited to 300 in Pine Script due to matrices size limits) "discrete-time" (lattice based) method to approximate the closed-form Black–Scholes formula. Joshi (2008)  outlined varying binomial options pricing model  furnishes a numerical approach for the valuation of options. Significantly, the American analogue can be estimated using the binomial tree. This indicator is the complex calculation for Binomial option pricing. Most folks take a shortcut and only calculate 2 iterations. I've coded this to allow for up to 300 iterations. This can be used to price American Puts/Calls and European Puts/Calls.  I'll be updating this indicator will be updated with additional features over time. If you would like to learn more about options, I suggest you check out the book textbook  Options, Futures and other Derivative by John C Hull. 
***This indicator only works on the daily timeframe!***
 A quick graphic of what this all means:  
In the graphic, "n" are the steps, in this case we can do up to 300, in production we'd need to do 5-15K. That's a lot of steps! You can see here how the binomial tree fans out. As I said previously, most folks only calculate 2 steps, here we are calculating up to 300. 
  
Want to learn more about Simple Introduction to Cox, Ross Rubinstein (1979) ? 
 Watch this short series "Introduction to Basic Cox, Ross and Rubinstein (1979) model."  
 Limitations of Black Scholes options pricing model  
This is a widely used and well-known options pricing model, factors in current stock price, options strike price, time until expiration (denoted as a percent of a year), and risk-free interest rates. The Black-Scholes Model is quick in calculating any number of option prices. But the model cannot accurately calculate American options, since it only considers the price at an option's expiration date. American options are those that the owner may exercise at any time up to and including the expiration day.
 What are Binomial Trees in options pricing?  
A useful and very popular technique for pricing an option involves constructing a binomial tree. This is a diagram representing different possible paths that might be followed by the stock price over the life of an option. The underlying assumption is that the stock price follows a random walk. In each time step, it has a certain probability of moving up by a certain percentage amount and a certain probability of moving down by a certain percentage amount. In the limit, as the time step becomes smaller, this model is the same as the Black–Scholes–Merton model.
 What is the Binomial options pricing model ?  
This model uses a tree diagram with volatility factored in at each level to show all possible paths an option's price can take, then works backward to determine one price. The benefit of the Binomial Model is that you can revisit it at any point for the possibility of early exercise. Early exercise is executing the contract's actions at its strike price before the contract's expiration. Early exercise only happens in American-style options. However, the calculations involved in this model take a long time to determine, so this model isn't the best in rushed situations.
 What is the Cox-Ross-Rubinstein Model? 
The Cox-Ross-Rubinstein binomial model can be used to price European and American options on stocks without dividends, stocks and stock indexes paying a continuous dividend yield, futures, and currency options. Option pricing is done by working backwards, starting at the terminal date. Here we know all the possible values of the underlying price. For each of these, we calculate the payoffs from the derivative, and find what the set of possible derivative prices is one period before. Given these, we can find the option one period before this again, and so on. Working ones way down to the root of the tree, the option price is found as the derivative price in the first node.
 Inputs  
 
 Spot price: select from 33 different types of price inputs
 Calculation Steps: how many iterations to be used in the Binomial model. In practice, this number would be anywhere from 5000 to 15000, for our purposes here, this is limited to 300
 Strike Price: the strike price of the option you're wishing to model
 % Implied Volatility: here you can manually enter implied volatility
 Historical Volatility Period: the input period for historical volatility; historical volatility isn't used in the CRRBT process, this is to serve as a sort of benchmark for the implied volatility,
 Historical Volatility Type: choose from various types of implied volatility, search my indicators for details on each of these
 Option Base Currency: this is to calculate the risk-free rate, this is used if you wish to automatically calculate the risk-free rate instead of using the manual input. this uses the 10 year bold yield of the corresponding country
 % Manual Risk-free Rate: here you can manually enter the risk-free rate
 Use manual input for Risk-free Rate? : choose manual or automatic for risk-free rate
 % Manual Yearly Dividend Yield: here you can manually enter the yearly dividend yield
 Adjust for Dividends?: choose if you even want to use use dividends
 Automatically Calculate Yearly Dividend Yield? choose if you want to use automatic vs manual dividend yield calculation
 Time Now Type: choose how you want to calculate time right now, see the tool tip
 Days in Year: choose how many days in the year, 365 for all days, 252 for trading days, etc
 Hours Per Day: how many hours per day? 24, 8 working hours, or 6.5 trading hours
 Expiry date settings: here you can specify the exact time the option expires
 
 Take notes: 
 
 Futures don't risk free yields. If you are pricing options of futures, then the risk-free rate is zero. 
 Dividend yields are calculated using TradingView's internal dividend values
 This indicator only works on the daily timeframe
 
 Included 
 
 Option pricing panel
 Loxx's Expanded Source Types
Barndorff-Nielsen and Shephard Jump Statistic [Loxx]The following comments and descriptions are from from "Problems in the Application of Jump Detection Tests to Stock Price Data" by Michael William Schwert; Professor George Tauchen, Faculty Advisor.
This indicator applies several jump detection tests to intraday stock price data sampled at various frequencies. It finds that the choice of sampling frequency has an effect on both the amount of jumps detected by these tests, as well as the timing of those jumps. Furthermore, although these tests are designed to identify the same phenomenon, they find different amounts and timing of jumps when performed on the same data. These results suggest that these jump detection tests are probably identifying different types of jump behavior in stock price data, so they are not really substitutes for one another.
In recent years there has been a great deal of interest in studying jumps in asset price movements. Reasons why it is important to know when and how frequently jumps occur include risk management and the pricing and hedging of derivative contracts. Investors would benefit greatly from knowing the properties of jumps, since large instantaneous drops in asset prices result in large instantaneous losses. The effect of jumps on derivative pricing is equally significant, especially considering the important role derivatives play in modern financial markets. When asset price movements are continuous, investors can perfectly hedge derivative contracts such as options, but when jumps occur, they cause a change in the derivative price that is non-linear to the change in the price of the underlying asset. Thus, jumps introduce an unhedgeable risk to the holders of derivative contracts.
The ability to identify realized jumps in the financial markets could provide helpful information such as how frequently jumps occur, how large the jumps are, and whether they tend to occur in clusters. With this goal in mind, several authors have developed tests to determine whether or not an asset price movement is a statistically significant jump. These tests take advantage of the high-frequency intraday price data available today through electronic sources. Barndorff-Nielsen and Shephard (2004, 2006) use the difference between an estimate of variance and a jump-robust measure of variance to detect jumps over the course of a day. Approaching the problem differently, Jiang and Oomen (2007) exploit high order sample moments of returns to identify days that include jumps. Aїt-Sahalia and Jacod (2008) also exploit high order sample moments of returns to detect jumps by comparing price data sampled at two different frequencies. Lee and Mykland (2007) test for jumps at individual price observations by scaling returns by a local volatility measure. While these tests employ different strategies for detecting jumps, they are all designed to identify the same phenomenon.
For this indicator we are focused on the Barndorff-Nielsen and Shephard  jump statistic. 
Barndorff-Nielsen and Shephard (2004, 2006) developed a test that uses high-frequency price data to determine whether there is a jump over the course of a day. Their test compares two measures of variance: Realized Variance, which converges to the integrated variance plus a jump component as the time between observations approaches zero; and Bipower Variation, which converges to the integrated variance as the time between observations approaches zero, and is robust to jumps in the price path, an important fact for this application. The integrated variance of a price process is the integral of the square of the σ(t) term in (2.2.2), taken over the course of a day. Since prices cannot be observed continuously, one cannot calculate integrated variance exactly, and must estimate it instead.
For our purposes here, this is calculated as:
r = log(p /p )
This the geometric return from time ti-1 to time ti. 
Then, Realized Variance and Bipower Variation are described by the following functions (see code for details)
realizedVariance(float src, int per) 
and
bipowerVariance(float src, int per)
Huang and Tauchen (2005) also consider Relative Jump, a measure that approximates the percentage of total variance attributable to jumps:
RJ = (RV - BV) / RV
This statistic approximates the ratio of the sum of squared jumps to the total variance and is useful because it scales out long-term trends in volatility so one can compare the relative contribution of jumps to the variance of two price series with different volatilities.
To develop a statistical test to determine whether there is a significant difference between RV and BV, one needs an estimate of integrated quarticity. Andersen, Bollerslev, and Diebold (2004) recommend using a jump-robust realized Tri-Power Quarticity, I've included commentary in code to better explain how this indicator is collocated. See code for details.  
 How to use this indicator 
When the bars turn gray, it's an indication that a jump has occurred in the market. It serves a warning that price jumped. I've included a percent point function (or inverse cumulative distribution function) to cutoff Z-score values depicted by histogram values. The top line at 3 is the empirical maximum Z-score value a serves merely as a point of reference. The Red line is the cutoff line calculated using PPF. When the histogram is green, no jumps have been detected. This indicator also includes alerts, signals, and bar coloring. I've also expanded the possible source types using my own Expanded Source Types library so you can test different log return methods as inputs. It is recommended to use window sizes of 7, 16, 78, 110, 156, and 270 returns for sampling intervals of 1 week, 1 day, 1 hour, 30 minutes, 15 minutes, and 5 minutes, respectively. 
If you'ed like to better understand PPF, see here:  Distributions in python   
 Included: 
 
 Bar coloring
 Signals
 Alerts
 Loxx's Expanded Source Types
Stochastic of Two-Pole SuperSmoother [Loxx]Stochastic of Two-Pole SuperSmoother   is a Stochastic Indicator that takes as input Two-Pole SuperSmoother of price. Includes gradient coloring and Discontinued Signal Lines signals with alerts. 
 What is Ehlers ; Two-Pole Super Smoother? 
From "Cycle Analytics for Traders Advanced Technical Trading Concepts" by John F. Ehlers
A SuperSmoother filter is used anytime a moving average of any type would otherwise be used, with the result that the SuperSmoother filter output would have substantially less lag for an equivalent amount of smoothing produced by the moving average. For example, a five-bar SMA has a cutoff period of approximately 10 bars and has two bars of lag. A SuperSmoother filter with a cutoff period of 10 bars has a lag a half bar larger than the two-pole modified Butterworth filter.Therefore, such a SuperSmoother filter has a maximum lag of approximately 1.5 bars and even less lag into the attenuation band of the filter. The differential in lag between moving average and SuperSmoother filter outputs becomes even larger when the cutoff periods are larger.
Market data contain noise, and removal of noise is the reason for using smoothing filters. In fact, market data contain several kinds of noise. I’ll group one kind of noise as systemic, caused by the random events of trades being exercised. A second kind of noise is aliasing noise, caused by the use of sampled data. Aliasing noise is the dominant term in the data for shorter cycle periods.
It is easy to think of market data as being a continuous waveform, but it is not. Using the closing price as representative for that bar constitutes one sample point. It doesn’t matter if you are using an average of the high and low instead of the close, you are still getting one sample per bar. Since sampled data is being used, there are some dSP aspects that must be considered. For example, the shortest analysis period that is possible (without aliasing)2 is a two-bar cycle.This is called the Nyquist frequency, 0.5 cycles per sample.A perfect two-bar sine wave cycle sampled at the peaks becomes a square wave due to sampling. However, sampling at the cycle peaks can- not be guaranteed, and the interference between the sampling frequency and the data frequency creates the aliasing noise.The noise is reduced as the data period is longer. For example, a four-bar cycle means there are four samples per cycle. Because there are more samples, the sampled data are a better replica of the sine wave component. The replica is better yet for an eight-bar data component.The improved fidelity of the sampled data means the aliasing noise is reduced at longer and longer cycle periods.The rate of reduction is 6 dB per octave. My experience is that the systemic noise rarely is more than 10 dB below the level of cyclic information, so that we create two conditions for effective smoothing of aliasing noise:
1. It is difficult to use cycle periods shorter that two octaves below the Nyquist frequency.That is, an eight-bar cycle component has a quantization noise level 12 dB below the noise level at the Nyquist frequency. longer cycle components therefore have a systemic noise level that exceeds the aliasing noise level.
2. A smoothing filter should have sufficient selectivity to reduce aliasing noise below the systemic noise level. Since aliasing noise increases at the rate of 6 dB per octave above a selected filter cutoff frequency and since the SuperSmoother attenuation rate is 12 dB per octave, the Super- Smoother filter is an effective tool to virtually eliminate aliasing noise in the output signal.
 What are DSL Discontinued Signal Line? 
A lot of indicators are using signal lines in order to determine the trend (or some desired state of the indicator) easier. The idea of the signal line is easy : comparing the value to it's smoothed (slightly lagging) state, the idea of current momentum/state is made.
Discontinued signal line is inheriting that simple signal line idea and it is extending it : instead of having one signal line, more lines depending on the current value of the indicator.
"Signal" line is calculated the following way :
When a certain level is crossed into the desired direction, the EMA of that value is calculated for the desired signal line
When that level is crossed into the opposite direction, the previous "signal" line value is simply "inherited" and it becomes a kind of a level
This way it becomes a combination of signal lines and levels that are trying to combine both the good from both methods.
In simple terms, DSL uses the concept of a signal line and betters it by inheriting the previous signal line's value & makes it a level.
 Included: 
 
 Bar coloring
 Alerts
 Signals
 Loxx's Expanded Source Types
 
Adaptive Two-Pole Super Smoother Entropy MACD [Loxx]Adaptive Two-Pole Super Smoother Entropy (Math) MACD is an Ehlers Two-Pole Super Smoother that is transformed into an  MACD oscillator using entropy mathematics. Signals are generated using Discontinued Signal Lines. 
 What is Ehlers; Two-Pole Super Smoother?  
From "Cycle Analytics for Traders Advanced Technical Trading Concepts" by John F. Ehlers
A SuperSmoother filter is used anytime a moving average of any type would otherwise be used, with the result that the SuperSmoother filter output would have substantially less lag for an equivalent amount of smoothing produced by the moving average. For example, a five-bar SMA has a cutoff period of approximately 10 bars and has two bars of lag. A SuperSmoother filter with a cutoff period of 10 bars has a lag a half bar larger than the two-pole modified Butterworth filter.Therefore, such a SuperSmoother filter has a maximum lag of approximately 1.5 bars and even less lag into the attenuation band of the filter. The differential in lag between moving average and SuperSmoother filter outputs becomes even larger when the cutoff periods are larger.
Market data contain noise, and removal of noise is the reason for using smoothing filters. In fact, market data contain several kinds of noise. I’ll group one kind of noise as systemic, caused by the random events of trades being exercised. A second kind of noise is aliasing noise, caused by the use of sampled data. Aliasing noise is the dominant term in the data for shorter cycle periods.
It is easy to think of market data as being a continuous waveform, but it is not. Using the closing price as representative for that bar constitutes one sample point. It doesn’t matter if you are using an average of the high and low instead of the close, you are still getting one sample per bar. Since sampled data is being used, there are some dSP aspects that must be considered. For example, the shortest analysis period that is possible (without aliasing)2 is a two-bar cycle.This is called the Nyquist frequency, 0.5 cycles per sample.A perfect two-bar sine wave cycle sampled at the peaks becomes a square wave due to sampling. However, sampling at the cycle peaks can- not be guaranteed, and the interference between the sampling frequency and the data frequency creates the aliasing noise.The noise is reduced as the data period is longer. For example, a four-bar cycle means there are four samples per cycle. Because there are more samples, the sampled data are a better replica of the sine wave component. The replica is better yet for an eight-bar data component.The improved fidelity of the sampled data means the aliasing noise is reduced at longer and longer cycle periods.The rate of reduction is 6 dB per octave. My experience is that the systemic noise rarely is more than 10 dB below the level of cyclic information, so that we create two conditions for effective smoothing of aliasing noise:
1. It is difficult to use cycle periods shorter that two octaves below the Nyquist frequency.That is, an eight-bar cycle component has a quantization noise level 12 dB below the noise level at the Nyquist frequency. longer cycle components therefore have a systemic noise level that exceeds the aliasing noise level.
2. A smoothing filter should have sufficient selectivity to reduce aliasing noise below the systemic noise level. Since aliasing noise increases at the rate of 6 dB per octave above a selected filter cutoff frequency and since the SuperSmoother attenuation rate is 12 dB per octave, the Super- Smoother filter is an effective tool to virtually eliminate aliasing noise in the output signal.
 What are DSL Discontinued Signal Line? 
A lot of indicators are using signal lines in order to determine the trend (or some desired state of the indicator) easier. The idea of the signal line is easy : comparing the value to it's smoothed (slightly lagging) state, the idea of current momentum/state is made.
Discontinued signal line is inheriting that simple signal line idea and it is extending it : instead of having one signal line, more lines depending on the current value of the indicator.
"Signal" line is calculated the following way :
When a certain level is crossed into the desired direction, the EMA of that value is calculated for the desired signal line
When that level is crossed into the opposite direction, the previous "signal" line value is simply "inherited" and it becomes a kind of a level
This way it becomes a combination of signal lines and levels that are trying to combine both the good from both methods.
In simple terms, DSL uses the concept of a signal line and betters it by inheriting the previous signal line's value & makes it a level.
 Included: 
 
 Bar coloring
 Alerts
 Signals
 Loxx's Expanded Source Types
Filtered, N-Order Power-of-Cosine, Sinc FIR Filter [Loxx]Filtered, N-Order Power-of-Cosine, Sinc FIR Filter   is a Discrete-Time, FIR Digital Filter that uses Power-of-Cosine Family of FIR filters. This is an N-order algorithm that allows up to 50 values for alpha, orders, of depth. This one differs from previous Power-of-Cosine filters I've published in that it this uses Windowed-Sinc filtering. I've also included a Dual Element Lag Reducer using Kalman velocity, a standard deviation filter, and a clutter filter. You can read about each of these below.  
 Impulse Response 
  
 What are FIR Filters? 
In discrete-time signal processing, windowing is a preliminary signal shaping technique, usually applied to improve the appearance and usefulness of a subsequent Discrete Fourier Transform. Several window functions can be defined, based on a constant (rectangular window), B-splines, other polynomials, sinusoids, cosine-sums, adjustable, hybrid, and other types. The windowing operation consists of multipying the given sampled signal by the window function. For trading purposes, these FIR filters act as advanced weighted moving averages.
A finite impulse response (FIR) filter is a filter whose impulse response (or response to any finite length input) is of finite duration, because it settles to zero in finite time. This is in contrast to infinite impulse response (IIR) filters, which may have internal feedback and may continue to respond indefinitely (usually decaying).
The impulse response (that is, the output in response to a Kronecker delta input) of an Nth-order discrete-time FIR filter lasts exactly {\displaystyle N+1}N+1 samples (from first nonzero element through last nonzero element) before it then settles to zero.
FIR filters can be discrete-time or continuous-time, and digital or analog.
A FIR filter is (similar to, or) just a weighted moving average filter, where (unlike a typical equally weighted moving average filter) the weights of each delay tap are not constrained to be identical or even of the same sign. By changing various values in the array of weights (the impulse response, or time shifted and sampled version of the same), the frequency response of a FIR filter can be completely changed.
An FIR filter simply CONVOLVES the input time series (price data) with its IMPULSE RESPONSE. The impulse response is just a set of weights (or "coefficients") that multiply each data point. Then you just add up all the products and divide by the sum of the weights and that is it; e.g., for a 10-bar SMA you just add up 10 bars of price data (each multiplied by 1) and divide by 10. For a weighted-MA you add up the product of the price data with triangular-number weights and divide by the total weight.
 What is a Standard Deviation Filter? 
If price or output or both don't move more than the (standard deviation) * multiplier then the trend stays the previous bar trend. This will appear on the chart as "stepping" of the moving average line. This works similar to Super Trend or Parabolic SAR but is a more naive technique of filtering.
 What is a Clutter Filter? 
For our purposes here, this is a filter that compares the slope of the trading filter output to a threshold to determine whether to shift trends. If the slope is up but the slope doesn't exceed the threshold, then the color is gray and this indicates a chop zone. If the slope is down but the slope doesn't exceed the threshold, then the color is gray and this indicates a chop zone. Alternatively if either up or down slope exceeds the threshold then the trend turns green for up and red for down. Fro demonstration purposes, an EMA is used as the moving average. This acts to reduce the noise in the signal.
 What is a Dual Element Lag Reducer? 
Modifies an array of coefficients to reduce lag by the Lag Reduction Factor uses a generic version of a Kalman velocity component to accomplish this lag reduction is achieved by applying the following to the array:
2 * coeff - coeff
The response time vs noise battle still holds true, high lag reduction means more noise is present in your data! Please note that the beginning coefficients which the modifying matrix cannot be applied to (coef whose indecies are < LagReductionFactor) are simply multiplied by two for additional smoothing .
 Whats a Windowed-Sinc Filter? 
Windowed-sinc filters are used to separate one band of frequencies from another. They are very stable, produce few surprises, and can be pushed to incredible performance levels. These exceptional frequency domain characteristics are obtained at the expense of poor performance in the time domain, including excessive ripple and overshoot in the step response. When carried out by standard convolution, windowed-sinc filters are easy to program, but slow to execute.
The sinc function sinc (x), also called the "sampling function," is a function that arises frequently in signal processing and the theory of Fourier transforms.
In mathematics, the historical unnormalized sinc function is defined for x ≠ 0 by
sinc x = sinx / x
In digital signal processing and information theory, the normalized sinc function is commonly defined for x ≠ 0 by
sinc x = sin(pi * x) / (pi * x)
For our purposes here, we are used a normalized Sinc function
 Included 
 
 Bar coloring
 Loxx's Expanded Source Types
 Signals
 Alerts
 
 Related indicators 
Variety, Low-Pass, FIR Filter Impulse Response Explorer   
  
STD-Filtered, Variety FIR Digital Filters w/ ATR Bands   
  
STD/C-Filtered, N-Order Power-of-Cosine FIR Filter  
  
STD/C-Filtered, Truncated Taylor Family FIR Filter  
  
STD/Clutter-Filtered, Kaiser Window FIR Digital Filter  
  
STD/Clutter Filtered, One-Sided, N-Sinc-Kernel, EFIR Filt  
 






















