Periodic Linear Regressions [LuxAlgo]The Periodic Linear Regressions (PLR) indicator calculates linear regressions periodically (similar to the VWAP indicator) based on a user-set period (anchor).
This allows for estimating underlying trends in the price, as well as providing potential supports/resistances.
🔶 USAGE
The Periodic Linear Regressions indicator calculates a linear regression over a user-selected interval determined from the selected "Anchor Period".
The PLR can be visualized as a regular linear regression (Static), with a fit readjusting for new data points until the end of the selected period, or as a moving average (Rolling), with new values obtained from the last point of a linear regression fitted over the calculation interval. While the static method line is prone to repainting, it has value since it can further emphasize the linearity of an underlying trend, as well as suggest future trend directions by extrapolating the fit.
Extremities are included in the indicator, these are obtained from the root mean squared error (RMSE) between the price and calculated linear regression. The Multiple setting allows the users to control how far each extremity is from the other.
Periodic Linear Regressions can be helpful in finding support/resistance areas or even opportunities when ranging in a channel.
The anchor - where a new period starts - can be shown (in this case in the top right corner).
The shown bands can be visualized by enabling Show Extremities in settings ( Rolling or Static method).
The script includes a background gradient color option for the bands, which only applies when using the Rolling method.
The indicator colors can be suggestive of the detected trend and are determined as follows:
Method Rolling: a gradient color between red and green indicates the trend; more green if the output is rising, suggesting an uptrend, and more red if it is decreasing, suggesting a downtrend.
Method Static: green if the slope of the line is positive, suggesting an uptrend, red if negative, suggesting a downtrend.
🔶 DETAILS
🔹 Anchor Type
When the Anchor Type is set to Periodic , the indicator will be reset when the "Anchor Period" changes, after which calculations will start again.
An anchored rolling line set at First Bar won't reset at a new session; it will continue calculating the linear regression from the first bar to the last; in other words, every bar is included in the calculation. This can be useful to detect potential long-term tops/bottoms.
Note that a linear regression needs at least two values for its calculation, which explains why you won't see a static line at the first bar of the session. The rolling linear regression will only show from the 3rd bar of the session since it also needs a previous value.
🔹 Rolling/Static
When Anchor Type is set at Periodic , a linear regression is calculated between the first bar of the chosen session and the current bar, aiming to find the line that best fits the dataset.
The example above shows the lines drawn during the session. The offered script, though, shows the last calculated point connected to the previous point when the Rolling method is chosen, while the Static method shows the latest line.
Note that linear regression needs at least two values, which explains why you won't see a static line at the first bar of the session. The rolling line will only show from the 3rd bar of the session since it also needs a previous value.
🔶 SETTINGS
Method: Indicator method used, with options: "Static" (straight line) / "Rolling" (rolling linear regression).
Anchor Type: "Periodic / First Bar" (the latter works only when "Method" is set to "Rolling").
Anchor Period: Only applicable when "Anchor Type" is set at "Periodic".
Source: open, high, low, close, ...
Multiple: Alters the width of the bands when "Show Extremities" is enabled.
Show Extremities: Display one upper and one lower extremity.
🔹 Color Settings
Mono Color: color when "Bicolor" is disabled
Bicolor: Toggle on/off + Colors
Gradient: Background color when "Show extremities" is enabled + level of gradient
🔹 Dashboard
Show Dashboard
Location of dashboard
Text size
Periodic
Periodic Activity Tracker [LuxAlgo]The Periodic Activity Tracker tool periodically tracks the cumulative buy and sell volume in a user-defined period and draws the corresponding matching bars and volume delta for each period.
Users can select a predefined aggregation period from the following options: Hourly, Daily, Weekly, and Monthly.
🔶 USAGE
This tool provides a simple and clear way of analyzing volumes for each aggregated period and is made up of the following elements:
Buy and sell volumes by period as red and green lines with color gradient area
Delta (difference) between buy & sell volume for each period
Buy & sell volume bars for each period
Separator between lines and bars, and period tags below each pair of bars for ease of reading
On the chart above we can see all the elements displayed, the volume level on the lines perfectly matches the volume level on the bars for each period.
In this case, the tool has the default settings so the anchor period is set to Daily and we can see how the period tag (each day of the week) is displayed below each pair of bars.
Users can disable the delta display and adjust the bar size.
🔹 Reading The Tool
In trading, assessing the strength of the bulls (buyers) and bears (sellers) is key to understanding the current trading environment. Which side, if any, has the upper hand? To answer this question, some traders look at volume in relation to price.
This tool provides you with a view of buy volume versus sell volume, allowing you to compare both sides of the market.
As with any volume tool, the key is to understand when the forces of the two groups are balanced or unbalanced.
As we can observe on the chart:
NOV '23: Buy volume greater than sell volume, both moving up close together, flat delta. We can see that the price is in range.
DEC '23: Buy volume bigger than Sell volume, both moving up but with a bigger difference, bigger delta than last month but still flat. We can see the price in the range above last month's range.
JAN '24: Buy and sell volume tied together, no delta whatsoever. We can see the price in range but testing above and below last month's range.
FEB '24: Buy volume explodes higher and sell volume cannot keep up, big growing delta. Price explodes higher above last month's range.
Traders need to understand that there is always an equal number of buyers and sellers in a liquid market, the quality here is how aggressive or passive they are. Who is 'attacking' and who is 'defending', who is using market orders to move prices, and who is using limit orders waiting to be filled?
This tool gives you the following information:
Lines: if the top line is green, the buyers are attacking, if it is red, the sellers are attacking.
Delta: represents the difference in their strength, if it is above 0 the buyers are stronger, if it is below 0 the sellers are stronger.
Bars: help you to see the difference in strength between buyers and sellers for each period at a glance.
🔹 Anchor Period
By default, the tool is set to Hourly. However, users can select from a number of predefined time periods.
Depending on the user's selection, the bars are displayed as follows:
Hourly : hours of the current day
Daily : days of the current week
Weekly : weeks of the current month
Monthly : months of the current year
On the chart above we can see the four periods displayed, starting at the top left and moving clockwise we have hourly, daily, weekly, and monthly.
🔶 DETAILS
🔹 Chart TimeFrame
The chart timeframe has a direct impact on the visualization of the tool, and the user should select a chart timeframe that is compatible with the Anchor period in the tool's settings panel.
For the chart timeframe to be compatible it must be less than the Anchor period parameter. If the user selects an incompatible chart timeframe, a warning message will be displayed.
As a rule of thumb, the smaller the chart timeframe, the more data the tool will collect, returning indications for longer-term price variations.
These are the recommended chart timeframes for each period:
Hourly : 5m charts or lower
Daily : 1H charts or lower
Weekly : 4H charts or lower
Monthly : 1D charts or lower
🔹 Warnings
This chart shows both types of warnings the user may receive
At the top, we can see the warning that is given when the 'Bar Width' parameter exceeds the allowed value.
At the bottom is the incompatible chart timeframe warning, which prompts the user to select a smaller chart timeframe or a larger "Anchor Period" parameter.
🔶 SETTINGS
🔹 Data Gathering
Anchor period: Time period representing each bar: hours of the day, days of the week, weeks of the month, and months of the year. The timeframe of the chart must be less than this parameter, otherwise a warning will be displayed.
🔹 Style
Bars width: Size of each bar, there is a maximum limit so a warning will be displayed if it is reached.
Volume color
Delta: Enable/Disable Delta Area Display
Volume Forecasting [LuxAlgo]The Volume Forecasting indicator provides a forecast of volume by capturing and extrapolating periodic fluctuations. Historical forecasts are also provided to compare the method against volume at time t .
This script will not work on tickers that do not have volume data.
🔶 SETTINGS
Median Memory: Number of days used to compute the median and first/third quartiles.
Forecast Window: Number of bars forecasted in the future.
Auto Forecast Window: Set the forecast window so that the forecast length completes an interval.
🔶 USAGE
The periodic nature of volume on certain securities allows users to more easily forecast using historical volume. The forecast can highlight intervals where volume tends to be more important, that is where most trading activity takes place.
More pronounced periodicity will tend to return more accurate forecasts.
The historical forecast can also highlight intervals where high/low volume is not expected.
The interquartile range is also highlighted, giving an area where we can expect the volume to lie.
🔶 DETAILS
This forecasting method is similar to the time series decomposition method used to obtain the seasonal component.
We first segment the chart over equidistant intervals. Each interval is delimited by a change in the daily timeframe.
To forecast volume at time t+1 we see where the current bar lies in the interval, if the bar is the 78th in interval then the forecast on the next bar is made by taking the median of the 79th bar over N intervals, where N is the median memory.
This method ensures capturing the periodic fluctuation of volume.
Morphed Sine WaveIntroduction
If you rescale a sine wave to the price you will need to correlate it with it in order to show good results, today i present a different method that does not involve correlation to "morph" a sine wave to the price in order to provide forecast's and highlight market periodic patterns.
Parameters
length control the period of the sine wave, power control the "morphing" amount, if you see for example that the results are going nuts try to increase power , if the results are just the price and the delayed price try to decrease power .
power = 1
power = 100
Those settings might be different depending on which market you are in.
Various Uses
You can do a lot of things with this indicator, use filters as source :
Use the indicator as source for oscillators in order to create cycles indicators :
And certainly many more things
Conclusion
I presented a way to morph a sine wave to the price i order to highlight cycles. You can use any function that return a value between -1 and 1 instead of sin , this can be a scaled rsi/stochastic or correlation coefficient, its up to you :)
If you need help don't hesitate to commend or pm me. I hope you will like the indicator and that it will inspire you to make great things.
Thanks for reading !
Recursive StochasticThe Self Referencing Stochastic Oscillator
The stochastic oscillator bring values in range of (0,100). This process is called Feature scaling or Unity-Based Normalization
When a function use recursion you can highlights cycles or create smoother results depending on various factors, this is the goal of a recursive stochastic.
For example : k = s(alpha*st+(1-alpha)*nz(k )) where st is the target source.
Using inputs with different scale level can modify the result of the indicator depending on which instrument it is applied, therefore the input must be normalized, here the price is first passed through a stochastic, then this result is used for the recursion.
In order to control the level of the recursion, weights are distributed using the alpha parameter. This parameter is in a range of (0,1), if alpha = 1, then the indicator act as a normal stochastic oscillator, if alpha = 0, then the indicator return na since the initial value for k = 0. The smaller the alpha parameter, the lower the correlation between the price and the indicator, but the indicator will look more periodic.
Comparison
Recursive Stochastic oscillator with alpha = 0.1 and bellow a classic oscillator (alpha = 1)
The use of recursion can both smooth the result and make it more reactive as well.
Filter As Source
It is possible to stabilize the indicator and make it less affected by outliers using a filter as input.
Lower alpha can be used in order to recover some reactivity, this will also lead to more periodic results (which are not inevitably correlated with price)
Hope you enjoy
For any questions/demands feel free to pm me, i would be happy to help you