SuperTrend Oscillator [LuxAlgo]This oscillator is made of three components, all derived from the SuperTrend indicator. This approach allows the user to easily determine overbought/sold zones, identify whether a retracement is present or if the price is ranging or trending. It also allows for the anticipation of the potential price cross with the SuperTrend.
We provide additional information including whether a signal returned by the SuperTrend was false, as well as the percentage of false signals.
Settings
Length: Period of the "average true range" used in the calculation of the SuperTrend
Mult: Multiplicative factor for the "average true range"
Smooth: Determines the degree of smoothing of the histogram
Misc:
Fixed Transparency: Use a fixed transparency for the main oscillator
Show Lines: Show the lines displayed by the indicator
Show Labels: Show the labels displayed by the indicator
Usage
The indicator is in a range of (-100,100) with values closer to 100/-100 indicating a stronger trend. The main oscillator value above 0 indicates that the price is above the SuperTrend.
It is possible to identify when a retracement is present in a trend. This is often indicated by an oscillator value moving within 50/-50.
Each overbought/oversold level can be used to determine potential exit points.
The indicator also includes two additional oscillators derived from the main oscillator. A smoothed version of the main oscillator (Signal), and a smoothed version of the difference between the Main and Signal oscillators (Histogram), thus making the oscillator part of the indicator more similar to MACD.
One can use the histogram to anticipate when the price might cross the SuperTrend by comparing the sign between the main and histogram. Potential false signals can also be filtered with this method.
Certain crosses between the price and SuperTrend can be filtered out when the histogram and main oscillator have a different sign (here main = 1, histogram = -1).
We include various indications in order to analyze the signals returned by the SuperTrend. The indicator displays symbols indicating whether a signal was false or not.
A cross symbol will be displayed at the top of the displayed lines when the previous Buy signal was false, else a checkmark is displayed. Symbols displayed at the bottom of the lines are referring to sell signals. We also provide a percentage of false signals, calculated over the entire chart history.
Details
The scaling method used is similar to max-min normalization. We first compute the difference between the price and SuperTrend and divide the result by the difference between the upper and lower extremity used to compute the SuperTrend. Values higher than (1,-1) can occur when price crosses the SuperTrend and as such we use the max and min functions to attenuate these.
The filter used to compute the signal line is based on exponential averaging and is fully adaptive. The smoothing factor used for its computation is the squared value of the main oscillator, divided by length . Since higher values of the oscillator are associated with trending markets, the filter will be closer to the main oscillator when the market is ranging.
Luxalgo
Adjustable MA & Alternating Extremities [LuxAlgo]Returns a moving average allowing the user to control the amount of lag as well as the amplitude of its overshoots thanks to a parametric kernel. The indicator displays alternating extremities and aims to provide potential points where price might reverse.
Due to user requests, we added the option to display the moving average as candles instead of a solid line.
Settings
Length: MA period, refers to the number of most recent data points to use for its calculation.
Mult: Multiplicative factor for each extremity.
As Smoothed Candles: Allows the user to show the MA as a series of candles instead of a solid line.
Show Alternating Extremities : Determines whether to display the alternating extremities or not.
Lag: Controls the amount of lag of the MA, with higher values returning a MA with more lag.
Overshoot: Controls the amplitude of the overshoots returned by the MA, with higher values increasing the amplitude of the overshoots.
Usage
Moving averages using parametric kernels allows users to have more control over characteristics such as lag or smoothness; this can greatly benefit the analyst. A moving average with reduced lag can be used as a leading moving average in a MA crossover system, while lag will benefit moving averages used as slow MA in a crossover system.
Increasing 'Lag' will increase smoothness while increasing 'overshoot' will reduce lag.
The following indicator puts more emphasis on its alternating extremities, an upper extremity will be shown once the high price crosses the upper extremity, while a low extremity will be shown once the low price crosses the lower extremity. These can be interpreted like extremities of a band indicator.
The MA using a length value of 200 with a multiplicative factor of 1.
In general, extremities will effectively return points where price might potentially bounce in ranging markets while closing prices under trending markets will often be found above an upper extremity and under a lower extremity.
Reducing the lag of the moving average allows the user to obtain a more timely estimate of the underlying trend in the price, with a better fit overall. This allows the user to obtain potentially pertinent extremities where price might reverse upon a break, even under trending markets.
In the above chart, the price initially breaks the upper extremity, however, we can observe that the upper extremity eventually reaches back the price, goes above it, provides a resistance, and effectively indicates a reversal.
Users can plot candles from the moving average, these are fairly similar to heikin-ashi candles in the sense that CandleOpen(t) ≠ CandleClose(t-1) , each point of the candle is calculated as follows for our indicator:
Open = Average between MA(t-1) and MA(t-2)
High = MA using the high price as input
Low = MA using the low price as input
Close = MA using the closing price as input
Details
Lag is defined as the effect of moving averages to reflect past price variations instead of new ones, lag can be observed by the user and is the main cause of false signals. Lag is proportional to the degree of filtering returned by the moving average.
Overshooting is a common effect encountered in non-lagging moving averages, and is defined as the tendency of a moving average to exceed a maximum level (or minimum level, which can be defined as undershooting )
MA and rolling maximum/minimum, both using a length of 50 bars. While we can think of lag as a cost of smoothness, we can think of overshooting as a cost for reduced lag on some occasions.
Explaining the kernel design behind our moving average requires understanding of the logic behind lag reduction in moving averages. This can prove to be complex for non informed users, but let's just focus on the simpler part; moving averages can be defined as a weighted sum between past prices and a set of coefficients (kernel).
MA(t) = b(0)C(t) + b(1)C(t-1) + b(2)C(t-2) + ... + b(n-1)C(t-n-1)
Where n is the period of the moving average. Lag is (non optimally) reduced by "underweighting" past prices - that is multiplying them by negative numbers.
The kernel used in our moving average is based on a modified sinewave. A weighted sum making use of a sinewave as a kernel would return an oscillator centered at 0. We can divide this sinewave by an increasing linear function in order to obtain a kernel allowing us to obtain a low lag moving average instead of a centered oscillator. This is the main idea in the design of the kernel used by our moving average.
The kernel equation of our moving average is:
sin(2πx^α)(1 - x^β)
With 1>x>0 , and where α controls the lag, while β controls the overshoot amplitude.
Using this equation we can obtain the following kernels:
Here only α is changed, while β is equal to 1. Values to the left would represent the coefficients for the most recent prices. Notice how the most significant coefficients are given to the oldest prices in the case where α increases.
Higher overshoot would require more negative values, this is controlled by β
Here only β is changed, while α is equal to 1. Notice how higher values return lower negative coefficients. This effectively increases the overshoots amplitude in our moving average. We can decrease α in order for these negative coefficients to underweight more recent values.
Using α = 0 allows us to simplify the kernel equation to:
1 - x^β
Using this kernel we can obtain more classical moving averages, this can be seen from the following results:
Using β = 1 allows us to obtain a linearly decreasing kernel (the one of a WMA), while increasing allows the kernel to converge toward a rectangular kernel (the one of SMA).
Volume Profile [LuxAlgo]Displays the estimate of a volume profile, with the option to show a rolling POC (point of control). Users can change the lookback, row size, and various visual aspects of the volume profile.
Settings
Basic:
Lookback: Number of most recent bars to use for the calculation of the volume profile
Row Size: Determines the number of rows used for the calculation of the volume profile
Show Rolling POC: Determines whether to display the rolling POC of the volume profile
Style:
Width (% of the box): Determines the length of the bars relative to the Lookback value
Bar Width: Width of each bar
Flip Histogram: Flips the histogram, when enabled, the histogram base will be located at the most recent candle
Gradient: Allows to color the volume profile bars with a gradient, with a color intensity determined by the length of each bar
Rows Solid Color: Color of each bar when 'Gradient' is disabled
POC Solid Color: Color of the POC when 'Gradient' is disabled
Usage
It is very common to display volume over time in order to visualize the trading activity made over a specific candle, however this is not the only way to display volume and it can be interesting to put it in relation with the price, which is what volume profiles do.
Volume profiles are displayed as price relative histograms showing the accumulated volume within certain price areas, the number of areas are determined by the row size of the volume profile. Knowing which price's area accumulated the most volume allow highlighting areas of interest to market participants.
Most accumulated volume will be encountered in zones of equilibrium between buyers and sellers; that is zones of local price stationarity. These zones are highlighted by high volume nodes in the volume profile. Imbalance between buyers and sellers are highlighted by thinner zones of the volume profile.
The price level with the most accumulated volume is highlighted by the "point of control" (POC), displayed by the dotted line in the indicator.
The POC is often considered an important level, commonly used as support/resistance by traders. One can verify the accuracy of this use case by using the rolling POC (assuming one would use the POC over time as SR).
Indicator Limitations
Volume profiles are calculated using tick data, which is not the case of this estimate, as such you won't have an accurate representation of an actual volume profile.
The rolling POC can introduce time outs in the script computation, use lower lookback and row size value to display it.
Parallel Pivot Lines [LuxAlgo]Displays lines connecting past pivot high/low points with each line having the slope of a linear regression. This slope can also be controlled by the user with the 'Slope' setting. Each line can be used as a support or resistance by the user.
Settings
Length : Pivot length. Use higher values for having lines connected to more significant pivots points.
Lookback : Number of lines connecting a pivot high/low to display, with a total of lines equal to Lookback*2
Slope : Allows the user to multiply the linear regression slope by a number within -1 and 1
Limitations
The script has currently several real time behavior limitations. Lines are displayed retrospectively and will not update with the arrival of new bars. Readjusting the indicator to newer pivots will require the user to either hide/unhide the indicator or change its settings.
High Length or Lookback values might not return any lines if the location of a pivot point is outside the defined buffer size of the indicator (set as 5000 bars).
How To Use
The indicator can be used to get supports and resistances and is more so closer to a drawing tool due to its limitations. The lines not updating with the arrival of new bars have the advantage of providing fixed supports/resistances.
The Slope setting allows the user to control the angle and direction of the lines. Using a Slope of 1 will return lines with the same slope as the one of a linear regression fit from the farthest pivot point displayed by the indicator to the most recent bar.
The chart above shows the indicators and a linear regression in orange.
If you want to have horizontal lines, use a Slope equal to 0.
Finally using a negative slope value will allow the user to have lines in opposite directions to the main trend.
Conclusion
We hope you like this indicator (drawing tool) and find it useful for drawing your support & resistances in a unique way!
Donchian Zig-Zag [LuxAlgo]The following indicator returns a line bouncing of the extremities of a Donchian channel, with the aim of replicating a "zig-zag" indicator. The indicator can both be lagging or lagging depending on the settings user uses.
Various extended lines are displayed in order to see if the peaks and troughs made by the Donchian zig-zag can act as potential support/resistance lines.
User Settings
Length : Period of the Donchian channel indicator, higher values will return fewer changes of directions from the zig-zag line
Bounce Speed : Determine the speed of bounces made by the zig-zag line, with higher values making the zig-zag line converge faster toward the extremities of the Donchian channel.
Gradient : Determine whether to use a gradient to color the area between each Donchian channel extremities, "On" by default.
Transparency : Transparency of the area between each Donchian channel extremities.
Usage
It is clear that this is not a very common indicator to see, as such usages can be limited and very hypothetical. Nonetheless, when a bounce speed value of 1 is used, the zig-zag line will have the tendency to lag behind the price, and as such can provides crosses with the prices which can provide potential entries.
The advantage of this approach against most indicators relying on crosses with the price is that the linear nature of the indicator allows avoiding retracements, thus potentially holding a position for the entirety of the trend.
Altho this indicator would not necessarily be the most adapted to this kind of usage.
When using a bounce speed superior to 1, we can see the predictive aspects of the indicator:
We can link the peaks/troughs made by the zig-zag with the precedent ones made to get potential support and resistance lines, while such a method is not necessarily accurate it still allows for an additional to interpret the indicator.
Conclusions
We presented an indicator aiming to replicate the behaviour of a zig-zag indicator. While somehow experimental, it has the benefits of being innovative and might inspire users in one way or another.
Rainbow Adaptive RSI [LuxAlgo]The following oscillator uses an adaptive moving average as an input for another RSI oscillator and aims to provide a way to minimize the impact of retracements over the oscillator output without introducing significant lag.
An additional trigger line is present in order to provide entry points from the crosses between the oscillator and the trigger line. More details are given below.
Settings
Length : period of the oscillator
Power : controls the sensitivity of the oscillator to retracements, with higher values minimizing the sensitivity to retracements.
Src : source input of the indicator
The indicator also includes the following graphical settings:
Gradient : Determines the color mode to use for the gradient, options include "Red To Green", "Red To Blue" and "None", with "None" displaying no gradient.
Color fill : Determines whether to fill the area between the oscillator and the trigger line or not, by default "On".
Circles : Determines whether to show circles highlighting the crosses between the oscillator and the trigger line.
Usage
The indicator can be used like any normalized oscillator, but unlike a classical RSI, it does not converge toward 50 with higher length values. This is caused by the RSI using a smooth input.
The power setting will minimize the impact of certain variations on the oscillator:
Here the oscillator at the bottom uses a power value of 1.5.
The trigger line is a smoothed RSI using an EMA as input, and it won't remain as near to 100 and 0 as the main oscillator. Using a moving average of the main oscillator as a trigger line would create faster crosses, but this approach allows us to have no crosses when a retracement is present.
Details
As previously discussed the main oscillator uses an adaptive moving average as input; this adaptive moving average is computed using a smoothing factor derived from an RSI oscillator, a similar adaptive moving average known as ARSI, but unlike ARSI which uses a classical RSI of the closing price for the calculation of the smoothing factor, our smoothing factor makes use of RSI on the adaptive moving average error, which provides a higher level of adaptiveness.
Trend Regularity Adaptive Moving Average [LuxAlgo]The following moving average adapt to the average number of highest high/lowest low made over a specific period, thus adapting to trend strength. Interesting results can be obtained when using the moving average in a MA crossover system or as a trailing support/resistance.
Settings
Length : Period of the indicator, with higher values returning smoother results.
Src : Source input of the indicator.
Usage
The trend regularity adaptive moving average (TRAMA) can be used like most moving averages, with the advantage of being smoother during ranging markets.
Notice how the moving closer to the price the longer a trend last, such effect can be practical to have early entry points when using the moving average in a MA crossover system, such effect is due to the increasing number of average highest high/lowest low made during longer trends. Note that in the case of a significant uptrend followed by a downtrend, the moving average might penalize the start of the downtrend (and vice versa).
The moving average can also act as an interesting trailing support/resistance.
Details
The moving average is calculated using exponential averaging, using as smoothing factor the squared simple moving average of the number of highest high/lowest low previously made, highest high/lowest low are calculated using rolling maximums/minimums.
Using higher values of length will return fewer highest high/lowest low which explains why the moving average is smoother for higher length values. Squaring allows the moving average to penalize lower values, thus appearing more stationary during ranging markets, it also allows to have some consistency regarding the length setting.
🧙 this moving average would not be possible without the existence of corn syrup 🦎
Trend Volume Accumulations [LuxAlgo]Deeply inspired by the Weiss wave indicator, the following indicator aims to return the accumulations of rising and declining volume of a specific trend. Positive waves are constructed using rising volume while negative waves are using declining volume.
The trend is determined by the sign of the rise of a rolling linear regression.
Settings
Length : Period of the indicator.
Src : Source of the indicator.
Linearity : Allows the output of the indicator to look more linear.
Mult : the multiplicative factor of both the upper and lower levels
Gradient : Use a gradient as color for the waves, true by default.
Usages
The trend volume accumulations (TVA) indicator allows determining the current price trend while taking into account volume, with blue colors representing an uptrend and red colors representing a downtrend.
The first motivation behind this indicator was to see if movements mostly made of declining volume were different from ones made of rising volume.
Waves of low amplitude represent movements with low trading activity.
Using higher values of Linearity allows giving less importance to individual volumes values, thus returning more linear waves as a result.
The indicator includes two levels, the upper one is derived from the cumulative mean of the waves based on rising volume, while the lower one is based on the cumulative mean of the waves based on declining volume, when a wave reaches a level we can expect the current trend to reverse. You can use different values of mult to control the distance from 0 of each level.
Triangular Momentum Oscillator & Real Time Divergences [LuxAlgo]Oscillators are widely used in technical analysis and can return a large amount of information to the trader depending on their design. It is common to use oscillators to detect divergences with the price, divergences occur when the tops/bottoms made by the oscillator and price are negatively correlated.
The following oscillator is based on the momentum of a triangular moving average, hence the name "triangular momentum" because of the very smooth property of the triangular moving average, we aimed at a real-time detection of divergences instead of using more common methods such as relying on pivot high/low detection which are suitable for more noisy oscillators.
The oscillator can also be colored based on a gradient derived from the correlation between its output and the price which can be useful to detect when the oscillator is out of phase (significantly lagging or leading the price).
Settings
length : Period of the oscillator, higher values return a smoother output.
src : Input source of the indicator.
Show Lines : Show lines connecting the current top/bottom with the previous one made by the oscillator when a divergence is detected. True by default.
Color Based On Price/Oscillator Correlation : Allows the color of the oscillator to change based on its correlation with the price, with red colors suggesting a negative correlation.
Usages
The advantage of having a smoother oscillator for divergences detection is that it can be done in real-time since a top or bottom is present when the oscillator first difference cross 0. Smoother oscillators are also easier to interpret, however, they will still suffer from lag.
The divergences detected by the oscillator are regular divergences, where the oscillator leads price variations.
Using higher values of length allows the oscillator to filter out longer-term variations thus being smoother as a result.
By using the color mode based on the price/oscillator correlation we can see where the oscillator leads or lag the price, and since divergences are based on the price and oscillator going in the opposite direction we can have information where price might reverse.
It is also possible to interpret the oscillator without relying on the divergence detection, with a decreasing value of the oscillator indicating a downtrend and an increasing value indicating an uptrend.
ArcTan Oscillator [LuxAlgo]The following indicator is a normalized oscillator making use of the arc tangent sigmoid function (ArcTan), this allows to "squarify" the output result, thus visually filtering out certain variations originally in the oscillator. The magnitude of this effect can be controlled by the user. The indicator contains a gradient that shows the possibility of a reversal, with red colors indicating that a reversal might occur.
Settings
Length : Period of the oscillator
Pre-Gain : Changes the amplitude of the oscillator before passing through the ArcTan function, this allows to amplify/reduce the "squarification" effect introduced by this function. In order to make it easier for the user, the setting is in a (-10,10) range, with negative values reducing the amplitude and positive one increasing it.
Src : Source input of the indicator
Usage
The oscillator can be used to determine the direction of the trend by looking at its sign, if the oscillator is positive, market is up-trending, else down-trending, based on this usage the user might not be interested to look at every variations produced by the oscillator, this is where the hyperbolic tangent function and pre-gain setting can be useful, by using an high value of pre-gain the user will be able to only focus on the sign of the oscillator.
Here pre-gain is set to 5, we can see that the oscillator is now easier to visualize. However, the use of sigmoid functions remove useful information for a trader that needs to find divergences, this is where using a negative value of the pre-gain setting will result useful.
Here pre-gain is set to -5.
The indicator makes use of a gradient to show potential reversals, this gradient is determined by the correlation between the oscillator and the price (this is a way to measure potential divergences). If the color is closer to red it means that a potential reversal might occur, it is possible to say in which direction price might go by looking at the sign of the oscillator, so if the gradient is red and the oscillator is negative price might rise. The gradient is not affected by the pre-gain setting.
Support and Resistance Levels with Breaks [LuxAlgo]This script provides basic pivot point Support and Resistance Levels to the user whilst displaying Break signal tags. It also has the ability to let the user display more significant breaks by filtering using the Volume Oscillator.
Only more significant breaks of these basic levels are displayed to the user when optimized which avoids noise and messy signals.
It will also display breaks with candles it deems to be bullish (e.g. having a longer upper or lower wick).
Notation
The notation of "B" denotes a break of either a Support or Resistance level with a volume greater than the threshold.
The notation of "Bull or Bear Wick" denotes a bullish or bearish candle on the break.
Settings:
Left Bars - the number of bars left hand side of the pivot.
Right Bars - the number of bars right hand side of the pivot.
Volume Threshold - the threshold value (%) for the Volume Oscillator.
Usage & Details:
Knowing when a pivot S/R level is broken with significance can be of great help to a trader. Many times significant levels may not be broken with significant force and the move is therefore weaker and possibly not worth trading.
Swing Highs/Lows & Candle Patterns [LuxAlgo]This script labels swing highs and swing lows as well as the candle pattern that occurred at that precise point. The script can detect the following 6 candle patterns: hammer, inverse hammer, bullish engulfing, hanging man, shooting star, and bearish engulfing.
This indicator by its very nature backpaints by default, meaning that the displayed components are offset in the past.
🔶 USAGE
It can be interesting to see if a top or bottom is associated with a specific candle pattern, this allows us to study the potential of such a pattern to indicate a reversal. You can hover on a label with a specific pattern to see more details about it.
The notations HH, HL, LH, and LL you can see on the labels are defined as follows:
HH : Higher high
HL : Higher low
LH : Lower high
LL : Lower low
🔶 SETTING
Length: Sensitivity of the swing high/low detection, with lower values returning the maximum/minimum of shorter-term price variations.
Percentile Nearest Rank Using Arrays [LuxAlgo]The new array feature is extremely powerful, as it will allow pinescript users to do more complex things, or compute existing calculations more efficiently, it will also be possible to shine some light to some already existing functions, one of them being percentile_nearest_rank .
We have been working on this new feature with our pal alexgrover, and made this script which computes a rolling percentile using the nearest rank method.
Settings
Length: Window of the rolling percentile, determine the number of past data to be used.
Percentage: Return the current value if Percentage % of the data fall below that value, the setting is in a range (0,100).
Src: Input source of the indicator.
Usage
A rolling percentile can have many usages when it comes to technical analysis, this is due to its ability to return the value of three common rolling statistics, the rolling median, which can be obtained using a percentage equal to 50, the rolling maximum, obtained with a percentage equal to 100, and the rolling minimum, obtained with a percentage equal to 0.
When we use our rolling percentile as a rolling median, we can obtain a robust estimation of the underlying trend in the price, while using it as a rolling maximum/minimum can allow us to determine if the market is trending, and at which direction. The rolling maximum/minimum is a rolling statistic used to calculate the well known stochastic oscillator and Donchian channel indicator.
We can also compute rolling quartiles, which can be obtained using a percentage of 25 or 75, with one of 25 returning the lower quartile and 75 the upper quartile.
In blue the upper rolling quartile (%75), in orange the lower rolling quartile (%25), both using a window size of 100.
Details
In order to compute a rolling percentile nearest rank, we must first take the most recent length closing prices, then order them in ascending order, we then return the value of the ordered observations at index (percentage/100*length) - 1 (we use - 1 because our array index starts at 0).