Relative slopeRelative slope metric
Description:
I was in need to create a simple, naive and elegant metric that was able to tell how strong is the trend in a given rolling window. While abstaining from using more complicated and arguably more precise approaches, I’ve decided to use Linearly Weighted Linear Regression slope for this goal. Outright values are useful, but the problem was that I wasn’t able to use it in comparative analysis, i.e between different assets & different resolutions & different window sizes, because obviously the outputs are scale-variant.
Here is the asset-agnostic, resolution-agnostic and window size agnostic version of the metric.
I made it asset agnostic & resolution agnostic by including spread information to the formula. In our case it's weighted stdev over differenced data (otherwise we contaminate the spread with the trend info). And I made it window size agnostic by adding a non-linear relation of length to the output, so finally it will be aprox in (-1, 1) interval, by taking square root of length, nothing fancy. All these / 2 and * 2 in unexpected places all around the formula help us to return the data to it’s natural scale while keeping the transformations in place.
Peace TV
Weighted
[HuD] WMA Fast BandThis personal Indicator was designed for the uncertain market of Bursa Malaysia where traders can only open positions for Buy.
The objective is to trade in fast mode, Fast In Fast Out ( FIFO ) especially when during bearish market.
It is based on Weighted Moving Average and the formula are as followed :
Short WMA = ( wma5 High + wma5 Low ) / 2
Long WMA = ( wma10 High + wma10 Low ) / 2
These Short WMA and Long WMA create a band ( green or red )
Green band appears when Short WMA > Long WMA and vice versa.
1. Green triangle
- appear when it meets all these three criteria
i. Short WMA crossover Long WMA
ii. Price is above ema50
iii. Price is below Top BB ( Bollinger Band )
- when a green triangle appears, traders can choose either to make a "BUY" entry at this point or wait for the next candle
- this green triangle is an early entry signal
2. Red triangle
- appear when Long WMA crossover Short WMA
- this is considered a final exit point for traders.
3. Orange dot
- appear when the price close below grey line. This means it break the previous lowest 3 candles
- when orange dot appears, traders can either exit or wait for red triangle for exit confirmation.
4. Grey Line
- is the lowest low price of the previous 3 candles ( default value is 3. Value can be adjusted )
5. Green Line / Level
- is the highest price level of the previous 5 candles.
- Trader can use this line as take profit (TP ) level depending on "taste" or "appetite"
6. Table Info
- consist of RSI value ( default 14 ), 52Week High Value, Volume , and Transaction Value in RM ( volume * current price )
7. Small Blue dot = Mid BB = SMA 20
8. Purple Line = EMA 50
Happy Trading 😎
Weighted Standard Deviation BandsLinearly weighted standard deviations over linearly weighted mean.
The rationale of the study can be deduced from my latest publications where I go deeper into explaining the benefits of linear weighting, but in short, I can remind that by using linear weighting we are able to increase the information gain by communicating the sequential nature of time series to the calculations via linear weighting.
Note, that multiplier parameters can take both negative and positive values resulting in ability to have, for example, 1st and 6th weighted standard deviations higher than the weighted mean.
Despite the modification of the classic standard deviation formula, I assume that mathematical qualities of standard deviation will hold due to the fact we can alternately weight the window itself, and then apply the classic standard deviation over the weighted window. In both cases, the results will be the same.
Aight that was too formal, but your short strangles should be happy
Here is it, for you
StrengthA mathematically elegant, native & modern way how to measure velocity/ strength/ momentum. As you can see it looks like MACD, but !suddenly! has N times shorter code (disregard the functions), and only 1 parameter instead of 3. OMG HOW DID HE DO IT?!?
MACD: "Let's take one filter (1 parameter), than another filter (2 parameters), then let's take dem difference, then let's place another filter over the difference (3rd parameter + introduction of a nested calculation), and let's write a whole book about it, make thousands of multi-hours YouTube videos about it, and let's never mention about the amount of uncertainty being introduced by multiple parameters & introduction of the nested calculation."
Strength: "let's get real, let's drop a weighted linear regression & usual linear regression over the data of the same length, take dem slopes, then make the difference over these slopes, all good. And then share it with people w/o putting an ® sign".
Fyi, regressions were introduced centuries ago, maybe decades idk, the point is long time ago, and computational power enough to calculate what I'm saying is slightly more than required for macd.
Rationale.
Linearly weighted linear regression has steeper slope (W) than the usual linear regression slope (S) due to the fact that the recent datapoints got more weight. This alone is enough of a metric to measure velocity. But still I've recalled macd and decided to make smth like it cuz I knew it'll might make you happy. I realized that S can be used instead of smoothing the W, thus eliminating the nested calculation and keeping entropy & info loss in place. And see, what we get is natural, simple, makes sense and brings flex. I also wanna remind you that by applying regression we maximize the info gain by using all the data in the window, instead of taking difference between the first and the last datapoints.
This script is dedicated to my friend Fabien. Man, you were the light in the darkness in that company. You'll get your alien green Lambo if you'll really want it, no doubts on my side bout that.
Good hunting
Trapezoidal Weighted Moving Average and Bollinger BandsThis weighting method linearly weights a percentage of values from both the beginning and the end of the rolling window in order to minimize the effect of outliers entering and leaving the window.
Weighted Least Squares Moving AverageLinearly Weighted Ordinary Least Squares Moving Regression
aka Weighted Least Squares Moving Average -> WLSMA
^^ called it this way just to for... damn, forgot the word
Totally pwns LSMA for some purposes here's why (just look up):
- 'realistically' the same smoothness;
- less lag;
- less overshoot;
- more or less same computationally intensive.
"Pretty cool, huh?", Bucky Roberts©, thenewboston
Now, would you please (just look down) and see the comparison of impulse & step responses:
Impulse responses
Step responses
Ain't it beautiful?
"Motivation behind the concept & rationale", by gorx1
Many been trippin' applying stats methods that require normally distributed data to time series, hence all these B*ll**** Bands and stuff don't really work as it should, while people blame themselves and buy snake oil seminars bout trading psychology, instead of using proper tools. Price... Neither population nor the samples are neither normally nor log-normally distributed. So we can't use all the stuff if we wanna get better results. I'm not talking bout passing each rolling window to a stat test in order to get the proper descriptor, that's the whole different story.
Instead we can leverage the fact that our data is time-series hence we can apply linear weighting, basically we extract another info component from the data and use it to get better results. Volume, range weighting don't make much sense (saying that based on both common sense and test results). Tick count per bar, that would be nice tho... this is the way to measure "intensity". But we don't have it on TV unfortunately.
Anyways, I'm both unhappy that no1 dropped it before me during all these years so I gotta do it myself, and happy that I can give smth cool to every1
Here is it, for you.
P.S.: the script contains standalone functions to calculate linearly weighted variance, linearly weighted standard deviation, linearly weighted covariance and linearly weighted correlation.
Good hunting
AveragesLibrary "Averages"
Contains utilities for generating averages from arrays. Useful for manipulated or cleaned data.
triangular(src, startingWeight) Calculates the triangular weighted average of a set of values where the last value has the highest weight.
Parameters:
src : The array to derive the average from.
startingWeight : The weight to begin with when calculating the average. Higher numbers will decrease the bias.
weighted(src, weights, weightDefault) Calculates the weighted average of a set of values.
Parameters:
src : The array to derive the average from.
weights : The array containing the weights for the source.
weightDefault : The default value to use when a weight is NA.
triangularWeighted(src, weights, startingWeight) Calculates the weighted average of a set of values where the last value has the highest triangular multiple.
Parameters:
src : The array to derive the average from.
weights : The array containing the weights for the source.
startingWeight : The multiple to begin with when calculating the average. Higher numbers will decrease the bias.
exponential(src) Calculates the exponential average of a set of values where the last value has the highest weight.
Parameters:
src : The array to derive the average from.
arrayFrom(src, len, omitNA) Creates an array from the provided series (oldest to newest).
Parameters:
src : The array to derive from.
len : The target length of the array.
omitNA : If true, NA values will not be added to the array and the resultant array may be shorter than the target length.
Banknifty Weighted volume by AkramulBanknifty Weighted volume as per share ratio.
HDFC Bank – 27.56%
ICICI Bank – 22.91%
State Bank of India (SBI) – 12.42%
Kotak Mahindra Bank – 11.77%
Axis Bank – 11.49%
IndusInd Bank – 5.20%
AU Small Finance Bank Ltd. – 2.35%
Bandhan Bank – 1.73%
Federal Bank – 1.53%
IDFC First Bank Ltd. – 1.22%
Punjab National Bank (PNB)- 1.03%
RBL Bank – 0.79%
and moving average plotted on volume
Volume, Momentum and Volatility weighted moving averageMoving averages are filters on price data. This moving average creates a filter which factors in:
- the price RSI or it's Momentum
- the volume RSI
- the RVI or Volatility
Each factor is put through a least squares filter to smooth them first.
Then the factors are used to build a coefficient for an exponentially weighted average.
The chart above shows a comparison of standard average types with this script.
This is useful if you are looking for a moving average based trigger and do not wish to react to candle noise price action.
Crypto Top 25 Equal Weight IndexDraws an Equally Weighted Index of 25 securities. The inputs are pre-populated with the Top 25 cryptocurrencies by market cap at the time of publishing the script, but any 25 securities can be used.
Double click on this indicator's pane to view in full screen.
Note: Candle open is always equal to previous candle's close. I did this to avoid problems where sometimes candle open didn't make sense compared to close.
If you're into cryptocurrencies also have a look at these TradingView charts CRYPTOCAP:TOTAL, CRYPTOCAP:TOTAL2 and CRYPTOCAP:OTHERS.
Moving Average Weighted, Volume AdjustedVAWMA = VWMA and WMA combined.
Simply put, this attempts to determine the average price per share over time, weighted heavier for recent values.
Uses triangular algorithm to taper off values in the past (same as WMA does).
Why use this?
Let's say the earliest bar of the VWMA has a huge amount of volume. That means that when the next bar arrives, there will be an abrupt change in the moving average that doesn't represent the current value properly. VAWMA eliminates this problem by triangular weighting each bar.
wMRS | Weighted-Mansfield Relative Strength - 4CR CUPThis version of Mansfield Relative Strength ( MRS ) weights the MRSs with different lookback periods by adding the weight of 2:1:1:1 to MRS (1Q) : MRS (2Q) : MRS (3Q) : MRS (4Q).
Typically, the lookback period of a MRS is reference to a full year, i.e. 260 trading dates or 52 weeks; to better represents the relative strength of a stock to a recent performance, someone suggested to add heavier weight on the most recent quarter MRS , i.e. MR(1Q) and the same weight to other quarters, namely, MRS (2Q), MRS (3Q), MRS (4Q).
For some of the stocks you may be interested was IPO not long ago, the lookback period is relaxed for customizing. Once you set the total lookback period, representing the 4Q, in the indicator, the other shorter lookback periods will be auto-calculated, i.e. 1Q, 2Q, 3Q.
A simple moving average of the wMRS is also added for your easier analysis on the trend development of the strength.
Weighted derivatives premium BTCCan be extended with more derivative or spot pairs, see the comments in the code for instructions. Most importantly, the pairs need to be added to the respective arrays in the same order, so that the weights are applied to the correct pairs.
Delta Volume Weighted - IntradayResets at the start of the day's session (9:50 am on the ASX).
Takes the first candle and checks if its a green candle (close > open), and adds the volume to a total (which starts at 0 at the start of the day).
Subtracts it if the candles in red.
Continues to do this along with all the candles.
The volume is also multiplied by the difference between open and close so that large candles with large volume have more weight and move the indicator more.
Weighted Price OscillatorThis is the study version of the Weighted Price Oscillator (STRATEGY) indicator.
Weighted Price Oscillator is an unique indicator that shows the relationship between two custom variables that trigger signals upon specific conditions. When WPO (short for weighted price oscillator ) crosses over the signal or zero line, it creates a buy signal and conversely below the signal or zero line, it generates a take profit signal. All of which are provided that the specific conditions are met.
Inside the script's options, the following options are: signal sensitivity, enable signal background color, and take profit percentage. The signal sensitivity allows you to adjust the script's trigger sensitivity, so that the script can fire signals appropriate for a specific timeframe. Enabling signal background color will provide a visual on the oscillator when a buy or take profit signal is being created. And lastly, the take profit percentage option is for configuring the trade size percentage of which you want to take profit with.
PM me for access.
Weighted Price Oscillator (STRATEGY)Weighted Price Oscillator is an unique indicator that shows the relationship between two custom variables that trigger signals upon specific conditions. When WPO (short for weighted price oscillator) crosses over the signal or zero line, it creates a buy signal and conversely below the signal or zero line, it generates a take profit signal. All of which are provided that the specific conditions are met.
Inside the script's options, the following options are: signal sensitivity, enable signal background color, and take profit percentage. The signal sensitivity allows you to adjust the script's trigger sensitivity, so that the script can fire signals appropriate for a specific timeframe. Enabling signal background color will provide a visual on the oscillator when a buy or take profit signal is being created. And lastly, the take profit percentage option is for configuring the trade size percentage of which you want to take profit with.
PM me for access.
Volume Weighted DeviationsVolume !weighted!
deviations.
Important: I don't really know how people generally compute deviations from VWAP/VWMA, but smth tells me generally it's just a Av Dev/St Dev based on mean, not on appropriate basis, like volume weighted mean in our case. This version is mathematically correct, it first calculates weighted mean, than utilizes this weighted in mean in AvDev & StDef functions modified to take into account weights.
Volume-Weighted Indicators VWMA/VWAP/EMA_by WWAs traders and investors now urge to console volume factors into their price action analysis. This script is an attempt to combine volume-weighted moving average (VWMA), volume-weighted average price (VWAP), along with the exponential moving average (EMA). I have found that this indicator works quite well with the stock market.
How to use the indicator:
Buy when the VWAP and EMA lines crossing up VWMA.
Sell when the VWAP and EMA crossing down each other OR both VWAP and EMA crossing down VWAP
Any modificatio is welcomed, but please let me know.
Stochastic Weights - Basic [BigBitsIO]This script is a compilation of several different stochastic indicators (and RSI) where the K value of each indicator is equally weighted. The purpose of the indicator is to combine many indicators together in a fashion that weights them easier. By default, the Stochastic and Stochastic RSI are both enabled - the idea is to speed up the relatively slower Stochastic and to slow down the relatively fast Stochastic RSI. Other Stochastics are also available, including some of my own custom calculations that can also be added to the weighted calculation. Only the K value is weighted, as the D value is just a moving average of the weighted K.
Explained:
- Calculates enabled indicators
- Calculates the weighted value of K for enabled indicators
- Calculates a D value from the weighted K
FAQ:
- Why is this script useful?
- To weight multiple indicators together so that you can attempt to find optimal values shared amongst the indicators. Ex: If Stochastic RSI is 100 and Stochastic is 50, K would be 75 and not particularly high. If you add in a 50 RSI, the K would be 67 in this example. If we weight indicators together that all have a high value they could potentially help find elements that align together to produce a stronger signal.
DISCLAIMER: For educational and entertainment purposes only. Nothing in this content should be interpreted as financial advice or a recommendation to buy or sell any sort of security or investment including all types of crypto. DYOR, TYOB.
LWMA: Linear Weighted Moving AverageCouldn't find searching for Linearly Weighted Moving Average (LWMA) in tradingview. Found one with the LWMA title, but it uses plain WMA calculation without the linearity which more heavily weights recent price data, which I need, so I try to made one.
LWMAs are also quicker to react to price changes than SMA and EMA. If you want a moving average with less lag than an SMA, try a LWMA.
It kind of also have a more clarity in defining the price trend and reversals. Trade signals usually based on crossovers, they can also indicate areas of potential support or resistance. But beware though, multiple false signals may also occur before a significant trend develops. Use a filter, some decent volatility oscillator might do the job.
--
The formula for this Linearly Weighted Moving Average is:
LWMA = (( P n∗ W 1)+( P n−1∗ W 2)+( P n−2∗ W 3)...) / ∑W
P = Price for the period
n = The most recent period, n-1 is the prior period, and n-2 is two periods prior
W = The assigned weight to each period, with the highest weight going first and then descending linearly based on the number of periods being used.
I hope I'm doing right translating it to Pine Script 4. Let me know if I miss something.