Linear Regression Histogram [LuxAlgo]This indicator is inspired by traditional statistical histograms. It will return the number of occurrences of price falling within each interval (bins) of the linear regression channel. This can be useful to highlight zones of interest within a trend.
Settings
Length: Number of recent closing prices used for the computation of the linear regression.
Bins Number: Number of intervals constructed from the linear regression channel.
Mult: Multiplicative factor for the RMSE. Controls the width of the linear regression channel.
Src: Input source of the indicator.
Usage
The indicator is constructed by dividing the linear regression channel range into a series of intervals (bins) of equal width. We then count the number of price values falling within each interval.
If a significant number of price values fall within a specific interval then that interval can highlight a potential zone of interest within a trend.
The zone of interest is highlighted in blue.
LUX
Nadaraya-Watson Envelope [LuxAlgo]This indicator builds upon the previously posted Nadaraya-Watson smoothers. Here we have created an envelope indicator based on Kernel Smoothing with integrated alerts from crosses between the price and envelope extremities. Unlike the Nadaraya-Watson estimator, this indicator follows a contrarian methodology.
Please note that by default this indicator can be subject to repainting. Users can use a non-repainting smoothing method available from the settings. The triangle labels are designed so that the indicator remains useful in real-time applications.
🔶 USAGE
🔹 Non Repainting
This tool can outline extremes made by the prices. This is achieved by estimating the underlying trend in the price, then calculating the mean absolute deviations from it, the obtained result is added/subtracted to the estimated underlying trend.
The non-repainting method estimates the underlying trend in price using an "endpoint Nadaraya-Watson estimator", and would return similar results to more classical band indicators.
🔹 Repainting
The repainting method makes use of the Nadaraya-Watson estimator to estimate the underlying trend in the price. The construction of the band extremities is the same as in the non-repainting method.
We can expect the price to reverse when crossing one of the envelope extremities. Crosses between the price and the envelopes extremities are indicated with triangles on the chart.
For real-time applications, triangles are always displayed when a cross occurs and remain displayed at the location it first appeared even if the cross is no longer visible after a recalculation of the envelope.
By popular demand, we have integrated alerts for this indicator from the crosses between the price and the envelope extremities. However, we do not recommend this precise method to be used alone or for solely real-time applications. We do not have data supporting the performance of this tool over more classical bands/envelope/channels indicators.
🔶 SETTINGS
Bandwidth: Controls the degree of smoothness of the envelopes, with higher values returning smoother results.
Mult: Controls the envelope width.
Source: Input source of the indicator.
Repainting Smoothing: Determine if a repainting or non-repainting method should be used for the calculation of the indicator.
🔶 RELATED SCRIPTS
For more information on the Nadaraya-Watson estimator see:
Linear Regression Fan [LuxAlgo]This indicator displays a fan using a linear regression fit to the price as a base. All lines are equidistant and are drawn from the first point of the linear regression to the most recent point of the linear regression plus the root-mean-square deviation (RMSD) multiplied by a certain factor.
Settings
Length: Lookback period for the linear regression.
Mult: Multiplier for the RMSD, allows returning wider fans.
Lines Per Side: Number of lines on each side of the fan.
Src: Input source of the indicator.
Usage
Traders often use the lines of fans to determine significant points of support or resistance at which they might expect price variations to reverse.
The length can be adjusted so that the starting point of the linear regression is located at a pivot high/low.
Some technical analysts use the measure rule of broadening wedges with fans when price breaks one of the extremities. This allows setting precise take-profits/stop-losses.
To learn more about the measure rule see:
The Echo Forecast [LuxAlgo]This indicator uses a simple time series forecasting method derived from the similarity between recent prices and similar/dissimilar historical prices. We named this method "ECHO".
This method originally assumes that future prices can be estimated from a historical series of observations that are most similar to the most recent price variations. This similarity is quantified using the correlation coefficient. Such an assumption can prove to be relatively effective with the forecasting of a periodic time series. We later introduced the ability to select dissimilar series of observations for further experimentation.
This forecasting technique is closely inspired by the analogue method introduced by Lorenz for the prediction of atmospheric data.
1. Settings
Evaluation Window: Window size used for finding historical observations similar/dissimilar to recent observations. The total evaluation window is equal to "Forecast Window" + "Evaluation Window"
Forecast Window: Determines the forecasting horizon.
Forecast Mode: Determines whether to choose historical series similar or dissimilar to the recent price observations.
Forecast Construction: Determines how the forecast is constructed. See "Usage" below.
Src: Source input of the forecast
Other style settings are self-explanatory.
2. Usage
This tool can be used to forecast future trends but also to indicate which historical variations have the highest degree of similarity/dissimilarity between the observations in the orange zone.
The forecasting window determines the prices segment (in orange) to be used as a reference for the search of the most similar/dissimilar historical price segment (in green) within the gray area.
Most forecasting techniques highly benefit from a detrended series. Due to the nature of this method, we highly recommend applying it to a detrended and periodic series.
You can see above the method is applied on a smooth periodic oscillator and a momentum oscillator.
The construction of the forecast is made from the price changes obtained in the green area, denoted as w(t) . Using the "Cumulative" options we construct the forecast from the cumulative sum of w(t) . Finally, we add the most recent price value to this cumulated series.
Using the "Mean" options will add the series w(t) with the mean of the prices within the orange segment.
Finally the "Linreg" will add the series w(t) to an extrapolated linear regression fit to the prices within the orange segment.
Liquidity Levels [LuxAlgo]The Peak Activity Levels indicator displays support and resistance levels from prices accompanied by significant volume. The indicator includes a histogram returning the frequency of closing prices falling between two parallel levels, each bin shows the number of bullish candles within the levels.
1. Settings
Length: Lookback for the detection of volume peaks.
Number Of Levels: Determines the number of levels to display.
Levels Color Mode: Determines how the levels should be colored. "Relative" will color the levels based on their location relative to the current price. "Random" will apply a random color to each level. "Fixed" will use a single color for each level.
Levels Style: Style of the displayed levels. Styles include solid, dashed, and dotted.
1.1 Histogram
Show Histogram: Determines whether to display the histogram or not.
Histogram Window: Lookback period of the histogram calculation.
Bins Colors: Control the color of the histogram bins.
2. Usage
The indicator can be used to display ready-to-use support and resistance. These are constructed from peaks in volume. When a peak occurs, we take the price where this peak occurred and use it as the value for our level.
If one of the levels was previously tested, we can hypothesize that the level might be used as support/resistance in the future. Additional analysis using volume can be done in order to confirm a potential bounce.
The histogram can return various information to the user. It can show if the price stayed within two levels for a long time and if the price within two levels was mostly made of bullish or bearish candles.
In the chart above, we can see that over the most recent 200 bars (determined by Histogram Window) 68 closing prices fall between levels A and B, with 27 bars being bullish.
Additionally, the width of a bin and its length can sometimes give information about the volatility of a specific price variation. If a bin is very wide but short (a low number of closing prices fallen within the levels) then we can conclude a most of the movement was done on a short amount of time.
Multi-Length Stochastic Average [LuxAlgo]This indicator returns the average of stochastic oscillators with periods ranging from 4 to length . This allows for a slightly more reactive oscillator as well as having information regarding the position of the price relative to rolling maximums/minimums of different periods.
We introduce settings that allow for pre and post-smoothing, with selectable smoothing methods and periods for both steps.
Settings
Length: Period of the indicator, determine the maximum period of the stochastic oscillator used in the average
Source: Source input of the indicator
Pre-Smoothing (1st Input): Degree of smoothing applied to the source input
Pre-Smoothing (2nd Input): Pre-Smoothing Method
Post-Smoothing (1st Input): Degree of smoothing applied to the final oscillator output
Post-Smoothing (2nd Input): Post-Smoothing Method
Smoothing methods include a simple moving average, a triangular moving average, and a least-squares moving average (this method can induce overshoots during the post-smoothing step). The user can also select "None".
Usages
The "multi-length" aspect of technical indicators is something that hasn't been deeply explored yet such indicators can give us information regarding both short-term and long-term information which was the motivation for the creation of the indicator.
The Multi-length Stochastic Average allows us to quantify the price position relative to a multitude of highest/lowest levels.
In the example above the oscillator returns the average of stochastic oscillators with periods ranging from 4 to 20, as well as multiple rolling minimums with periods ranging from 4 to 20. We can see that when the price is equal to all rolling minimums the oscillator is equal to 0, the oscillator would return 100 if the price were equal to all rolling maximums with periods in that same range.
The oscillator can be interpreted like any scaled oscillator and can be used to estimate trend direction as well as trend strength.
Here we only make of use pre-smoothing by using a period 20 simple moving average. The indicator graphical elements such as colors/circles can help us determine potential directions trends might take.
Circles are displayed when the oscillator crosses over/under the 20/80 level. Such conditions offer better timing than waiting for the oscillator to be greater/lower than 50 and are less subjective to noise than simply looking at the direction taken by the oscillator. However, it can suffer from potential retracements in a trend more easily, this is illustrated in the chart above.
Risk Management Tool [LuxAlgo]Good money management is one of the fundamental pillars of successful trading. With this indicator, we propose a simple way to manage trading positions. This tool shows Profit & Loss (P&L), suggests position size given a certain risk, sets stop losses and take profit levels using fixed price value/percentage/ATR/Range, and can also determine entries from crosses with technical indicators which is particularly handy if you don't want to set an entry manually.
1. Settings
Position Type: Determines if the position should be a "Long" or "Short".
Account Size: Determines the total capital of the trading account.
Risk: The maximum risk amount for a trade. Can be set as a percentage of the account size or as a fixed amount.
Entry Price: Determines the entry price of the position.
Entry From Cross: When enabled, allows to set the entry price where a cross with an external source was produced.
1.1 Stop Loss/Take Profit
Take Profit: Determines the take profit level, which can be determined by a value or percentage.
Stop Loss: Determines the stop loss level, which can be determined by a value or percentage.
2. Usage
One of the main usages of position management tools is to determine the position size to allocate given a specific risk amount and stop-loss. 2% of your capital is often recommended as a risk amount.
Our tool allows setting stop losses and take profits with different methods.
The ATR method sets the stop loss/take profit one ATR away from the entry price, with the ATR period being determined in the drop-down menu next to the selected methods. The range method works similarly but instead of using the ATR, we use a rolling range with a period determined in the drop-down menu next to the selected methods as well.
Unlike the available position management tool on TradingView, the entry can be determined from a cross between the price an an external source. The image above shows entries from the Volatility Stop indicator. This is particularly useful if you set positions based on trailing stops.
Pivot High/Low Analysis & Forecast [LuxAlgo]Returns pivot points high/low alongside the percentage change between one pivot and the previous one (Δ%) and the distance between the same type of pivots in bars (Δt). The trailing mean for each of these metrics is returned on a dashboard on the chart. The indicator also returns an estimate of the future time position of the pivot points.
This indicator by its very nature is not real-time and is meant for descriptive analysis alongside other components of the script. This is normal behavior for scripts detecting pivots as a part of a system and it is important you are aware the pivot labels are not designed to be traded in real-time themselves
🔶 USAGE
The indicator can provide information helping the user to infer the position of future pivot points. This information is directly used in the indicator to provide such forecasting. Note that each metric is calculated relative to the same type of pivot points.
It is also common for analysts to use pivot points for the construction of various figures, getting the percentage change and distance for each pivot point can allow them to eventually filter out points of non-interest.
🔹 Forecast
We use the trailing mean of the distance between respective pivots to estimate the time position of future pivot points, this can be useful to estimate the location of future tops/bottoms. The time position of the forecasted pivot is given by a vertical dashed line on the chart.
We can see a successful application of this method below:
Above we see the forecasted pivots for BTCUSD15. The forecast of interest being the pivot high. We highlight the forecast position with a blue dotted line for reference.
After some time we obtain a new pivot high with a new forecast. However, we can see that the time location of this new pivot high matches perfectly with the prior forecast.
The position in time for the forecast is given by:
x1_ph + E
x1_pl + E
where x1_ph denotes the position in time of the most recent pivot high. x1_pl denotes the position in time of the most recent pivot low and E the average distance between respective pivot points.
🔶 SETTINGS
Length: Window size for the detection of pivot points.
Show Forecasted Pivots: Display forecast of future pivot points.
🔹 Dashboard
Dashboard Location: Location of the dashboard on the chart
Dashboard Size: Size of the dashboard on the chart
Text/Frame Color: Determines the color of the frame grid as well as the text color
Zig Zag Channels [LuxAlgo]The Zig Zag indicator is a useful indicator when it comes to visualizing past underlying trends in the price and can make the process of using drawing tools easier. The indicator consists of a series of lines connecting points where the price deviates more than a specific percentage from a maximum/minimum point ultimately connecting local peaks and troughs.
This indicator by its very nature backpaints by default, meaning that the displayed components are offset in the past.
🔶 USAGE
The Zig Zag indicator is commonly used to returns points of references for the usage of specific drawing tools, such as Fibonacci retracements, fans, squares...etc.
The proposed indicator estimates peaks and troughs by using rolling maximums/minimums with a window size determining their significance. This window size approach allows us to have an indicator that works with a certain regularity no matter the scale of the price, something the percentage-based approach struggles with. Additionally, one upper and lower extremity are displayed, highlighting the price point that deviates the most from the Zig Zag lines.
A common usage also includes the easy determination of Elliot wave patterns in the price.
The Zig Zag indicator above highlights a downtrending motive wave.
🔹 Extremities
The novel approach taken by this Zig Zag indicator is the addition of two extremities derived from the distance between the price and the Zig Zag line, thus returning channels. It is uncommon seeing extremities in Zig Zag indicators since the line connecting peaks and troughs has rarely any other utility than seeing trend variations with more clarity and is not meant to provide an accurate estimate of underlying local trends in the price.
This channel can be useful to study the potential relationship between underlying trends and the Zig Zag line. A low width between the Zig Zag and the upper extremity indicates price variations mostly located below the Zig Zag while equal width indicates more linear trends.
When the indicator is extended to the last line, the extremities provide potential support and resistances, thus making this indicator able to forecast price variations.
🔶 SETTINGS
Length: Determines the significance of the detected peaks and troughs.
Extend To Last Bar: Extend the most recent line to the most recent closing price value.
Show Extremities: Displays the extremities.
Show Labels: Display labels highlighting the high/low prices located at peaks and troughs.
🔹 Style
Upper Extremity Color: Color of the upper extremity displayed by the indicator.
Zig Zag Color: Color of the ZigZag lines.
Lower Extremity Color: Color of the lower extremity displayed by the indicator.
Normalized Oscillators Spider Chart [LuxAlgo]This indicator displays a spider chart overlaid on the user’s current chart allowing the visualization of information given by various normalized oscillators. It is possible to customize the spider chart by hiding certain oscillators from within the settings which removes their corresponding spokes from the chart.
Users can control the length settings of each oscillator individually or use a global length setting that applies to every oscillator. An additional meter element is displayed and aims to give the overall sentiment returned by the oscillators. This can also be used to gauge whether the market is trending or ranging.
This is a relatively simple application of a spider chart but can prove to be useful to some users.
1. Settings
RSI: Displays the Relative Strength Index spoke on the spider chart, includes the length setting on the right of the toggle.
%K: Displays the Stochastic Oscillator "%K" spoke on the spider chart, includes the length setting on the right of the toggle.
COR: Displays the Correlation Oscillator spoke on the spider chart, includes the length setting on the right of the toggle.
MFI: Displays the Money Flow Index oscillator spoke on the spider chart, includes the length setting on the right of the toggle.
WPR: Displays the Williams Percent Rank oscillator spoke on the spider chart, includes the length setting on the right of the toggle.
%UP: Displays the percentage of upward variations spoke on the spider chart, includes the length setting on the right of the toggle.
CMO: Displays the Chande Momentum Oscillator spoke on the spider chart, includes the length setting on the right of the toggle.
AOS: Displays the Aroon oscillator spoke on the spider chart, includes the length setting on the right of the toggle.
Global Oscillators Length: Determines whether all oscillators should use the same length settings, determined by the setting on the right of the toggle.
1.1 Style Settings
Spider Chart Length: Determines the horizontal width of the spider chart.
Spider Chart Offset: Offset between the most recent bar and the left extremity of the spider chart.
2. Usage
A spider chart can be a very useful visualization tool when it comes to seeing the individual characteristics of various variables at the same time.
Here, the tool can give a general sentiment on the direction of the trend without adding each indicator to your chart. It is also possible to determine when an oscillator is considered overbought or oversold with this indicator.
The dashed line represents the central value for each oscillator.
Disabling any of the oscillators from the settings will return a spider chart using fewer spokes.
The script also displays a meter that can be used to determine the overall sentiment given by all oscillators. This metric is based on the average value between each oscillator. An overall sentiment closer to 50 would indicate a ranging market.
PineGIF - Display Gifs & Images In Tradingview [LuxAlgo]Pinescript is not designed to create or display images, let alone gifs, but it's very fun to try, and that's what this script does. This script allows the user to display three different gifs. In this post, we explain how we managed to display images/gif's using pinescript tables.
1. Image Pre-Processing
Due to pinescript limitations, we can't possibly display images with an excessively high resolution. As such we targeted pixel art as a primary image source. We used a pixel art gif of the magnificent Octocat (the mascot for the source-code hosting service GitHub) for our first try.
We first extract each frame from the gif and resize them to a 50x50 resolution which returns frames made of 2500 pixels. This process was done using python.
Getting Individual Pixels RGBA Values
Python can easily return a matrix containing each pixel's rgba value. For convenience, we converted the rgba values to hex.
We then create a simple code allowing us to return a pinescript array containing the 2500 pixel hex colors. We do this process for each frame.
2. Defining Table Cell Color
In the code, each frame is its own array. We create a new table with dimensions equal to len(frame1)^2 (we assume height = width).
The color of a cell is defined by the color of the image pixel at the same exact location. When a new bar is created, we do this exact process using a different frame which ultimately allows a new frame to be displayed.
3. Playing The GIFs
By default, the script will play the gif of the Tradingview cloud logo raining. In order to play the gif, simply use the replay mode. The replay speed allows the user to determine the frame rate (0.1 for the raining cloud and Nyan cat works best, 0.5 for Octocat).
We included the frames of the Octocat and Nyan cat gifs in the script.
4. Some Other Cool Images
Displaying static images is possible and involves the same process described above.
An original idea of the lizard, implemented by the wizard.
Directional Matrix [LuxAlgo]Returns a dashboard showing the direction taken by 4 overlay indicators, SMA (simple moving average), TMA (triangular moving average), WMA (weighted moving average), and REG (linear regression), all using different length periods.
The user can select the minimum and maximum length of these indicators and introduce an increment.
1. Settings
Maximum Length: The end value of sequences of the indicator periods to analyze
Minimum Length: The starting value of sequences of the indicator periods to analyze
Step: Determines the spacing between each indicator periods values
Src: Data source for each of the 4 indicators
1.1 Style settings
Normalized Change Mode: Allows the user to access a different interpretation of the indicator by showing the normalized first differences of each indicator in the dashboard instead of their sign
Dashboard Location: Location of the dashboard on the chart
Dashboard Size: Size of the dashboard on the chart
Text/Frame Color: Determines the color of the frame grid as well as the text color
Bullish Cell Color: Determines the color of cell associated with a rising indicator direction
Bearish Cell Color: Determines the color of cell associated with a decreasing indicator direction
Cell Transparency: Transparency of each cell
2. Usage
Each of the indicators included in the dashboard aim to give an estimate of the underlying trend in the price. Knowing which direction they are taking can help us have a broader view regarding the direction of shorter/longer-term trends. We will later see that this is not the only kind of information that we can get from this indicator.
Rising indicators are represented by blue cells (or the color selected in the Bullish Cell Color setting) while decreasing indicators are represented by red cells (or the color selected in the Bearish Cell Color setting).
The percentage of bullish cells is given in the top-left cell of the dashboard.
2.1 Normalized change mode
Enabling the Normalized Change mode will display the normalized changes returned by the indicators over different length periods. This metric is within a range (0,1), with 1 indicating the highest change over the selected length periods, while 0 indicates the lowest one.
When enabling this mode the color of the cells makes use of a gradient with a color palette ranging from the color selected in the Bearish Cell setting to the color selected in the Bullish Cell setting.
2.1 Other Usage
The direction taken by certain indicators can give more information than one would think. Indeed, the sign of the change of one indicator can often be given by different indicators.
A positive change in a simple moving average indicates that the price is greater than the price p bars ago, where p is the period of the simple moving average.
A positive change in a triangular moving average indicates that a simple moving average of period p is above a simple moving average of period p × 2 , where p is the period of the triangular moving average (note that we assume here that the TMA is given by cascading two SMAs of period p ).
A positive change in a weighted moving average indicates that the price is above a simple moving average of period p+1 , where p is the period of the WMA.
Finally, a positive change in a linear regression indicates that a weighted moving average is above a simple moving average of period p , where p is the period of the linear regression.
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.
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.