Linear Moments█ OVERVIEW
The Linear Moments indicator, also known as L-moments, is a statistical tool used to estimate the properties of a probability distribution. It is an alternative to conventional moments and is more robust to outliers and extreme values.
█ CONCEPTS
█ Four moments of a distribution
We have mentioned the concept of the Moments of a distribution in one of our previous posts. The method of Linear Moments allows us to calculate more robust measures that describe the shape features of a distribution and are anallougous to those of conventional moments. L-moments therefore provide estimates of the location, scale, skewness, and kurtosis of a probability distribution.
The first L-moment, λ₁, is equivalent to the sample mean and represents the location of the distribution. The second L-moment, λ₂, is a measure of the dispersion of the distribution, similar to the sample standard deviation. The third and fourth L-moments, λ₃ and λ₄, respectively, are the measures of skewness and kurtosis of the distribution. Higher order L-moments can also be calculated to provide more detailed information about the shape of the distribution.
One advantage of using L-moments over conventional moments is that they are less affected by outliers and extreme values. This is because L-moments are based on order statistics, which are more resistant to the influence of outliers. By contrast, conventional moments are based on the deviations of each data point from the sample mean, and outliers can have a disproportionate effect on these deviations, leading to skewed or biased estimates of the distribution parameters.
█ Order Statistics
L-moments are statistical measures that are based on linear combinations of order statistics, which are the sorted values in a dataset. This approach makes L-moments more resistant to the influence of outliers and extreme values. However, the computation of L-moments requires sorting the order statistics, which can lead to a higher computational complexity.
To address this issue, we have implemented an Online Sorting Algorithm that efficiently obtains the sorted dataset of order statistics, reducing the time complexity of the indicator. The Online Sorting Algorithm is an efficient method for sorting large datasets that can be updated incrementally, making it well-suited for use in trading applications where data is often streamed in real-time. By using this algorithm to compute L-moments, we can obtain robust estimates of distribution parameters while minimizing the computational resources required.
█ Bias and efficiency of an estimator
One of the key advantages of L-moments over conventional moments is that they approach their asymptotic normal closer than conventional moments. This means that as the sample size increases, the L-moments provide more accurate estimates of the distribution parameters.
Asymptotic normality is a statistical property that describes the behavior of an estimator as the sample size increases. As the sample size gets larger, the distribution of the estimator approaches a normal distribution, which is a bell-shaped curve. The mean and variance of the estimator are also related to the true mean and variance of the population, and these relationships become more accurate as the sample size increases.
The concept of asymptotic normality is important because it allows us to make inferences about the population based on the properties of the sample. If an estimator is asymptotically normal, we can use the properties of the normal distribution to calculate the probability of observing a particular value of the estimator, given the sample size and other relevant parameters.
In the case of L-moments, the fact that they approach their asymptotic normal more closely than conventional moments means that they provide more accurate estimates of the distribution parameters as the sample size increases. This is especially useful in situations where the sample size is small, such as when working with financial data. By using L-moments to estimate the properties of a distribution, traders can make more informed decisions about their investments and manage their risk more effectively.
Below we can see the empirical dsitributions of the Variance and L-scale estimators. We ran 10000 simulations with a sample size of 100. Here we can clearly see how the L-moment estimator approaches the normal distribution more closely and how such an estimator can be more representative of the underlying population.
█ WAYS TO USE THIS INDICATOR
The Linear Moments indicator can be used to estimate the L-moments of a dataset and provide insights into the underlying probability distribution. By analyzing the L-moments, traders can make inferences about the shape of the distribution, such as whether it is symmetric or skewed, and the degree of its spread and peakedness. This information can be useful in predicting future market movements and developing trading strategies.
One can also compare the L-moments of the dataset at hand with the L-moments of certain commonly used probability distributions. Finance is especially known for the use of certain fat tailed distributions such as Laplace or Student-t. We have built in the theoretical values of L-kurtosis for certain common distributions. In this way a person can compare our observed L-kurtosis with the one of the selected theoretical distribution.
█ FEATURES
Source Settings
Source - Select the source you wish the indicator to calculate on
Source Selection - Selec whether you wish to calculate on the source value or its log return
Moments Settings
Moments Selection - Select the L-moment you wish to be displayed
Lookback - Determine the sample size you wish the L-moments to be calculated with
Theoretical Distribution - This setting is only for investingating the kurtosis of our dataset. One can compare our observed kurtosis with the kurtosis of a selected theoretical distribution.
Gestione portafoglio
Historical Volatility EstimatorsHistorical volatility is a statistical measure of the dispersion of returns for a given security or market index over a given period. This indicator provides different historical volatility model estimators with percentile gradient coloring and volatility stats panel.
█ OVERVIEW There are multiple ways to estimate historical volatility. Other than the traditional close-to-close estimator. This indicator provides different range-based volatility estimators that take high low open into account for volatility calculation and volatility estimators that use other statistics measurements instead of standard deviation. The gradient coloring and stats panel provides an overview of how high or low the current volatility is compared to its historical values.
█ CONCEPTS We have mentioned the concepts of historical volatility in our previous indicators, Historical Volatility, Historical Volatility Rank, and Historical Volatility Percentile. You can check the definition of these scripts. The basic calculation is just the sample standard deviation of log return scaled with the square root of time. The main focus of this script is the difference between volatility models.
Close-to-Close HV Estimator: Close-to-Close is the traditional historical volatility calculation. It uses sample standard deviation. Note: the TradingView build in historical volatility value is a bit off because it uses population standard deviation instead of sample deviation. N – 1 should be used here to get rid of the sampling bias.
Pros:
• Close-to-Close HV estimators are the most commonly used estimators in finance. The calculation is straightforward and easy to understand. When people reference historical volatility, most of the time they are talking about the close to close estimator.
Cons:
• The Close-to-close estimator only calculates volatility based on the closing price. It does not take account into intraday volatility drift such as high, low. It also does not take account into the jump when open and close prices are not the same.
• Close-to-Close weights past volatility equally during the lookback period, while there are other ways to weight the historical data.
• Close-to-Close is calculated based on standard deviation so it is vulnerable to returns that are not normally distributed and have fat tails. Mean and Median absolute deviation makes the historical volatility more stable with extreme values.
Parkinson Hv Estimator:
• Parkinson was one of the first to come up with improvements to historical volatility calculation. • Parkinson suggests using the High and Low of each bar can represent volatility better as it takes into account intraday volatility. So Parkinson HV is also known as Parkinson High Low HV. • It is about 5.2 times more efficient than Close-to-Close estimator. But it does not take account into jumps and drift. Therefore, it underestimates volatility. Note: By Dividing the Parkinson Volatility by Close-to-Close volatility you can get a similar result to Variance Ratio Test. It is called the Parkinson number. It can be used to test if the market follows a random walk. (It is mentioned in Nassim Taleb's Dynamic Hedging book but it seems like he made a mistake and wrote the ratio wrongly.)
Garman-Klass Estimator:
• Garman Klass expanded on Parkinson’s Estimator. Instead of Parkinson’s estimator using high and low, Garman Klass’s method uses open, close, high, and low to find the minimum variance method.
• The estimator is about 7.4 more efficient than the traditional estimator. But like Parkinson HV, it ignores jumps and drifts. Therefore, it underestimates volatility.
Rogers-Satchell Estimator:
• Rogers and Satchell found some drawbacks in Garman-Klass’s estimator. The Garman-Klass assumes price as Brownian motion with zero drift.
• The Rogers Satchell Estimator calculates based on open, close, high, and low. And it can also handle drift in the financial series.
• Rogers-Satchell HV is more efficient than Garman-Klass HV when there’s drift in the data. However, it is a little bit less efficient when drift is zero. The estimator doesn’t handle jumps, therefore it still underestimates volatility.
Garman-Klass Yang-Zhang extension:
• Yang Zhang expanded Garman Klass HV so that it can handle jumps. However, unlike the Rogers-Satchell estimator, this estimator cannot handle drift. It is about 8 times more efficient than the traditional estimator.
• The Garman-Klass Yang-Zhang extension HV has the same value as Garman-Klass when there’s no gap in the data such as in cryptocurrencies.
Yang-Zhang Estimator:
• The Yang Zhang Estimator combines Garman-Klass and Rogers-Satchell Estimator so that it is based on Open, close, high, and low and it can also handle non-zero drift. It also expands the calculation so that the estimator can also handle overnight jumps in the data.
• This estimator is the most powerful estimator among the range-based estimators. It has the minimum variance error among them, and it is 14 times more efficient than the close-to-close estimator. When the overnight and daily volatility are correlated, it might underestimate volatility a little.
• 1.34 is the optimal value for alpha according to their paper. The alpha constant in the calculation can be adjusted in the settings. Note: There are already some volatility estimators coded on TradingView. Some of them are right, some of them are wrong. But for Yang Zhang Estimator I have not seen a correct version on TV.
EWMA Estimator:
• EWMA stands for Exponentially Weighted Moving Average. The Close-to-Close and all other estimators here are all equally weighted.
• EWMA weighs more recent volatility more and older volatility less. The benefit of this is that volatility is usually autocorrelated. The autocorrelation has close to exponential decay as you can see using an Autocorrelation Function indicator on absolute or squared returns. The autocorrelation causes volatility clustering which values the recent volatility more. Therefore, exponentially weighted volatility can suit the property of volatility well.
• RiskMetrics uses 0.94 for lambda which equals 30 lookback period. In this indicator Lambda is coded to adjust with the lookback. It's also easy for EWMA to forecast one period volatility ahead.
• However, EWMA volatility is not often used because there are better options to weight volatility such as ARCH and GARCH.
Adjusted Mean Absolute Deviation Estimator:
• This estimator does not use standard deviation to calculate volatility. It uses the distance log return is from its moving average as volatility.
• It’s a simple way to calculate volatility and it’s effective. The difference is the estimator does not have to square the log returns to get the volatility. The paper suggests this estimator has more predictive power.
• The mean absolute deviation here is adjusted to get rid of the bias. It scales the value so that it can be comparable to the other historical volatility estimators.
• In Nassim Taleb’s paper, he mentions people sometimes confuse MAD with standard deviation for volatility measurements. And he suggests people use mean absolute deviation instead of standard deviation when we talk about volatility.
Adjusted Median Absolute Deviation Estimator:
• This is another estimator that does not use standard deviation to measure volatility.
• Using the median gives a more robust estimator when there are extreme values in the returns. It works better in fat-tailed distribution.
• The median absolute deviation is adjusted by maximum likelihood estimation so that its value is scaled to be comparable to other volatility estimators.
█ FEATURES
• You can select the volatility estimator models in the Volatility Model input
• Historical Volatility is annualized. You can type in the numbers of trading days in a year in the Annual input based on the asset you are trading.
• Alpha is used to adjust the Yang Zhang volatility estimator value.
• Percentile Length is used to Adjust Percentile coloring lookbacks.
• The gradient coloring will be based on the percentile value (0- 100). The higher the percentile value, the warmer the color will be, which indicates high volatility. The lower the percentile value, the colder the color will be, which indicates low volatility.
• When percentile coloring is off, it won’t show the gradient color.
• You can also use invert color to make the high volatility a cold color and a low volatility high color. Volatility has some mean reversion properties. Therefore when volatility is very low, and color is close to aqua, you would expect it to expand soon. When volatility is very high, and close to red, you would it expect it to contract and cool down.
• When the background signal is on, it gives a signal when HVP is very low. Warning there might be a volatility expansion soon.
• You can choose the plot style, such as lines, columns, areas in the plotstyle input.
• When the show information panel is on, a small panel will display on the right.
• The information panel displays the historical volatility model name, the 50th percentile of HV, and HV percentile. 50 the percentile of HV also means the median of HV. You can compare the value with the current HV value to see how much it is above or below so that you can get an idea of how high or low HV is. HV Percentile value is from 0 to 100. It tells us the percentage of periods over the entire lookback that historical volatility traded below the current level. Higher HVP, higher HV compared to its historical data. The gradient color is also based on this value.
█ HOW TO USE If you haven’t used the hvp indicator, we suggest you use the HVP indicator first. This indicator is more like historical volatility with HVP coloring. So it displays HVP values in the color and panel, but it’s not range bound like the HVP and it displays HV values. The user can have a quick understanding of how high or low the current volatility is compared to its historical value based on the gradient color. They can also time the market better based on volatility mean reversion. High volatility means volatility contracts soon (Move about to End, Market will cooldown), low volatility means volatility expansion soon (Market About to Move).
█ FINAL THOUGHTS HV vs ATR The above volatility estimator concepts are a display of history in the quantitative finance realm of the research of historical volatility estimations. It's a timeline of range based from the Parkinson Volatility to Yang Zhang volatility. We hope these descriptions make more people know that even though ATR is the most popular volatility indicator in technical analysis, it's not the best estimator. Almost no one in quant finance uses ATR to measure volatility (otherwise these papers will be based on how to improve ATR measurements instead of HV). As you can see, there are much more advanced volatility estimators that also take account into open, close, high, and low. HV values are based on log returns with some calculation adjustment. It can also be scaled in terms of price just like ATR. And for profit-taking ranges, ATR is not based on probabilities. Historical volatility can be used in a probability distribution function to calculated the probability of the ranges such as the Expected Move indicator. Other Estimators There are also other more advanced historical volatility estimators. There are high frequency sampled HV that uses intraday data to calculate volatility. We will publish the high frequency volatility estimator in the future. There's also ARCH and GARCH models that takes volatility clustering into account. GARCH models require maximum likelihood estimation which needs a solver to find the best weights for each component. This is currently not possible on TV due to large computational power requirements. All the other indicators claims to be GARCH are all wrong.
Expected Move BandsExpected move is the amount that an asset is predicted to increase or decrease from its current price, based on the current levels of volatility.
In this model, we assume asset price follows a log-normal distribution and the log return follows a normal distribution.
Note: Normal distribution is just an assumption, it's not the real distribution of return
Settings:
"Estimation Period Selection" is for selecting the period we want to construct the prediction interval.
For "Current Bar", the interval is calculated based on the data of the previous bar close. Therefore changes in the current price will have little effect on the range. What current bar means is that the estimated range is for when this bar close. E.g., If the Timeframe on 4 hours and 1 hour has passed, the interval is for how much time this bar has left, in this case, 3 hours.
For "Future Bars", the interval is calculated based on the current close. Therefore the range will be very much affected by the change in the current price. If the current price moves up, the range will also move up, vice versa. Future Bars is estimating the range for the period at least one bar ahead.
There are also other source selections based on high low.
Time setting is used when "Future Bars" is chosen for the period. The value in time means how many bars ahead of the current bar the range is estimating. When time = 1, it means the interval is constructing for 1 bar head. E.g., If the timeframe is on 4 hours, then it's estimating the next 4 hours range no matter how much time has passed in the current bar.
Note: It's probably better to use "probability cone" for visual presentation when time > 1
Volatility Models :
Sample SD: traditional sample standard deviation, most commonly used, use (n-1) period to adjust the bias
Parkinson: Uses High/ Low to estimate volatility, assumes continuous no gap, zero mean no drift, 5 times more efficient than Close to Close
Garman Klass: Uses OHLC volatility, zero drift, no jumps, about 7 times more efficient
Yangzhang Garman Klass Extension: Added jump calculation in Garman Klass, has the same value as Garman Klass on markets with no gaps.
about 8 x efficient
Rogers: Uses OHLC, Assume non-zero mean volatility, handles drift, does not handle jump 8 x efficient
EWMA: Exponentially Weighted Volatility. Weight recently volatility more, more reactive volatility better in taking account of volatility autocorrelation and cluster.
YangZhang: Uses OHLC, combines Rogers and Garmand Klass, handles both drift and jump, 14 times efficient, alpha is the constant to weight rogers volatility to minimize variance.
Median absolute deviation: It's a more direct way of measuring volatility. It measures volatility without using Standard deviation. The MAD used here is adjusted to be an unbiased estimator.
Volatility Period is the sample size for variance estimation. A longer period makes the estimation range more stable less reactive to recent price. Distribution is more significant on a larger sample size. A short period makes the range more responsive to recent price. Might be better for high volatility clusters.
Standard deviations:
Standard Deviation One shows the estimated range where the closing price will be about 68% of the time.
Standard Deviation two shows the estimated range where the closing price will be about 95% of the time.
Standard Deviation three shows the estimated range where the closing price will be about 99.7% of the time.
Note: All these probabilities are based on the normal distribution assumption for returns. It's the estimated probability, not the actual probability.
Manually Entered Standard Deviation shows the range of any entered standard deviation. The probability of that range will be presented on the panel.
People usually assume the mean of returns to be zero. To be more accurate, we can consider the drift in price from calculating the geometric mean of returns. Drift happens in the long run, so short lookback periods are not recommended. Assuming zero mean is recommended when time is not greater than 1.
When we are estimating the future range for time > 1, we typically assume constant volatility and the returns to be independent and identically distributed. We scale the volatility in term of time to get future range. However, when there's autocorrelation in returns( when returns are not independent), the assumption fails to take account of this effect. Volatility scaled with autocorrelation is required when returns are not iid. We use an AR(1) model to scale the first-order autocorrelation to adjust the effect. Returns typically don't have significant autocorrelation. Adjustment for autocorrelation is not usually needed. A long length is recommended in Autocorrelation calculation.
Note: The significance of autocorrelation can be checked on an ACF indicator.
ACF
The multimeframe option enables people to use higher period expected move on the lower time frame. People should only use time frame higher than the current time frame for the input. An error warning will appear when input Tf is lower. The input format is multiplier * time unit. E.g. : 1D
Unit: M for months, W for Weeks, D for Days, integers with no unit for minutes (E.g. 240 = 240 minutes). S for Seconds.
Smoothing option is using a filter to smooth out the range. The filter used here is John Ehler's supersmoother. It's an advance smoothing technique that gets rid of aliasing noise. It affects is similar to a simple moving average with half the lookback length but smoother and has less lag.
Note: The range here after smooth no long represent the probability
Panel positions can be adjusted in the settings.
X position adjusts the horizontal position of the panel. Higher X moves panel to the right and lower X moves panel to the left.
Y position adjusts the vertical position of the panel. Higher Y moves panel up and lower Y moves panel down.
Step line display changes the style of the bands from line to step line. Step line is recommended because it gets rid of the directional bias of slope of expected move when displaying the bands.
Warnings:
People should not blindly trust the probability. They should be aware of the risk evolves by using the normal distribution assumption. The real return has skewness and high kurtosis. While skewness is not very significant, the high kurtosis should be noticed. The Real returns have much fatter tails than the normal distribution, which also makes the peak higher. This property makes the tail ranges such as range more than 2SD highly underestimate the actual range and the body such as 1 SD slightly overestimate the actual range. For ranges more than 2SD, people shouldn't trust them. They should beware of extreme events in the tails.
Different volatility models provide different properties if people are interested in the accuracy and the fit of expected move, they can try expected move occurrence indicator. (The result also demonstrate the previous point about the drawback of using normal distribution assumption).
Expected move Occurrence Test
The prediction interval is only for the closing price, not wicks. It only estimates the probability of the price closing at this level, not in between. E.g., If 1 SD range is 100 - 200, the price can go to 80 or 230 intrabar, but if the bar close within 100 - 200 in the end. It's still considered a 68% one standard deviation move.
3-Daumen-RegelThis indicator evaluates three key market conditions and summarizes them in a compact table using simple thumbs-up / thumbs-down signals. It’s designed specifically for daily timeframes and helps you quickly assess whether a market is showing technical strength or weakness.
The Three Checks
Price Above the 200-Day SMA
Indicates the long-term trend direction. A thumbs-up means the price is trading above the 200-day moving average.
Positive Performance During the First 5 Trading Days of the Year (YTD Start)
Measures early-year strength. If not enough bars are available, a warning is shown.
Price Above the YTD Level
Compares the current price to the first trading day’s close of the year.
Color Coding for Instant Clarity
Green: Condition met
Red: Condition not met
This creates a compact “thumbs check” that gives you a quick read on the market’s technical health.
Note
The indicator is intended for daily charts. A message appears if a different timeframe is used.
Mebane Faber GTAA 5In 2007, Mebane Faber published research that challenged the conventional wisdom of buy-and-hold investing. His paper, titled "A Quantitative Approach to Tactical Asset Allocation" and published in the Journal of Wealth Management, demonstrated that a simple timing mechanism could reduce portfolio volatility and drawdowns while maintaining competitive returns (Faber, 2007). This indicator implements his Global Tactical Asset Allocation strategy, known as GTAA5, following the original methodology.
The core insight of Faber's research stems from a century of market data. By analyzing asset class performance from 1901 onwards, Faber found that a ten-month simple moving average served as an effective trend filter across major asset classes. When an asset trades above its ten-month moving average, it tends to continue its upward trajectory; when it falls below, significant drawdowns often follow (Faber, 2007, pp. 12-16). This observation aligns with momentum research by Jegadeesh and Titman (1993), who documented that intermediate-term momentum persists across equity markets.
The GTAA5 strategy allocates capital equally across five diversified asset classes: domestic equities (SPY), international developed markets (EFA), aggregate bonds (AGG), commodities (DBC), and real estate investment trusts (VNQ). Each asset receives a twenty percent allocation when trading above its ten-month moving average. When an asset falls below this threshold, its allocation moves to short-term treasury bills (SHY), creating a dynamic cash position that scales with market risk (Cambria Investment Management, 2013).
The strategy's historical performance during market crises illustrates its function. During the 2008 financial crisis, traditional sixty-forty portfolios experienced drawdowns exceeding forty percent. The GTAA5 strategy limited losses to approximately twelve percent by reducing equity exposure as prices declined below their moving averages (Faber, 2013). This asymmetric return profile represents the strategy's primary characteristic.
This implementation uses monthly closing prices retrieved via request.security() to calculate the ten-month simple moving average. This distinction matters, as approximations using daily data (such as a 200-day moving average) can generate different signals during volatile periods. Monthly data ensures the indicator produces signals consistent with published academic research.
The indicator provides position monitoring, automatic rebalancing detection on either the first or last trading day of each month, and share calculations based on user-defined capital. A dashboard displays current trend status for each asset class, target versus actual weightings, and trade instructions for rebalancing. Performance metrics including annualized volatility and Sharpe ratio provide ongoing risk assessment.
Several limitations warrant acknowledgment. First, the strategy rebalances monthly, meaning it cannot respond to intra-month market crashes. Second, transaction costs and taxes from monthly rebalancing may reduce net returns for taxable accounts. Third, the ten-month lookback period, while historically robust, offers no guarantee of future effectiveness. As Ilmanen (2011) notes in "Expected Returns", all timing strategies face the risk of regime change, where historical relationships break down.
This indicator serves educational purposes and portfolio monitoring. It does not constitute financial advice.
References:
Cambria Investment Management (2013). Global Tactical Asset Allocation: An Introduction to the Approach. Research Report, Los Angeles.
Faber, M.T. (2007). A Quantitative Approach to Tactical Asset Allocation. Journal of Wealth Management, Spring 2007, pp. 9-79.
Faber, M.T. (2013). Global Asset Allocation: A Survey of the World's Top Asset Allocation Strategies. Cambria Investment Management, Los Angeles.
Ilmanen, A. (2011). Expected Returns: An Investor's Guide to Harvesting Market Rewards. John Wiley and Sons, Chichester.
Jegadeesh, N. and Titman, S. (1993). Returns to Buying Winners and Selling Losers: Implications for Stock Market Efficiency. Journal of Finance, 48(1), pp. 65-91.
️Omega RatioThe Omega Ratio is a risk-return performance measure of an investment asset, portfolio, or strategy. It is defined as the probability-weighted ratio, of gains versus losses for some threshold return target. The ratio is an alternative for the widely used Sharpe ratio and is based on information the Sharpe ratio discards.
█ OVERVIEW
As we have mentioned many times, stock market returns are usually not normally distributed. Therefore the models that assume a normal distribution of returns may provide us with misleading information. The Omega Ratio improves upon the common normality assumption among other risk-return ratios by taking into account the distribution as a whole.
█ CONCEPTS
Two distributions with the same mean and variance, would according to the most commonly used Sharpe Ratio suggest that the underlying assets of the distribution offer the same risk-return ratio. But as we have mentioned in our Moments indicator, variance and standard deviation are not a sufficient measure of risk in the stock market since other shape features of a distribution like skewness and excess kurtosis come into play. Omega Ratio tackles this problem by employing all four Moments of the distribution and therefore taking into account the differences in the shape features of the distributions. Another important feature of the Omega Ratio is that it does not require any estimation but is rather calculated directly from the observed data. This gives it an advantage over standard statistical estimators that require estimation of parameters and are therefore sampling uncertainty in its calculations.
█ WAYS TO USE THIS INDICATOR
Omega calculates a probability-adjusted ratio of gains to losses, relative to the Minimum Acceptable Return (MAR). This means that at a given MAR using the simple rule of preferring more to less, an asset with a higher value of Omega is preferable to one with a lower value. The indicator displays the values of Omega at increasing levels of MARs and creating the so-called Omega Curve. Knowing this one can compare Omega Curves of different assets and decide which is preferable given the MAR of your strategy. The indicator plots two Omega Curves. One for the on chart symbol and another for the off chart symbol that u can use for comparison.
When comparing curves of different assets make sure their trading days are the same in order to ensure the same period for the Omega calculations. Value interpretation: Omega<1 will indicate that the risk outweighs the reward and therefore there are more excess negative returns than positive. Omega>1 will indicate that the reward outweighs the risk and that there are more excess positive returns than negative. Omega=1 will indicate that the minimum acceptable return equals the mean return of an asset. And that the probability of gain is equal to the probability of loss.
█ FEATURES
• "Low-Risk security" lets you select the security that you want to use as a benchmark for Omega calculations.
• "Omega Period" is the size of the sample that is used for the calculations.
• “Increments” is the number of Minimal Acceptable Return levels the calculation is carried on. • “Other Symbol” lets you select the source of the second curve.
• “Color Settings” you can set the color for each curve.
⏰Forex Market Clock Table (DST Auto)⏰ Forex Market Clock Table (DST Auto)
Keep track of key forex session times with this clean, real-time table showing local time, market status (open/closed), and automatic Daylight Saving Time (DST) adjustments for Sydney, Tokyo, London, and New York. Displays countdowns to session open/close and highlights weekends. Fully customizable position, colors, and text size—perfect for multi-session traders.
Futures Risk Manager Pro (v6 stable)This indicator will allow you to calculate your risk management per position.
You must first enter your capital and your risk percentage. Then, when you specify your stop-loss size in ticks, the indicator will immediately tell you the number of contracts to use to stay within your risk percentage.
Futures Risk Manager Pro (v6 stable)This indicator will allow you to calculate your risk management per position.
You must first enter your capital and your risk percentage. Then, when you specify your stop-loss size in ticks, the indicator will immediately tell you the number of contracts to use to stay within your risk percentage.
Futures Risk Manager Pro (v6 stable)This indicator will allow you to calculate your risk management per position.
You must first enter your capital and your risk percentage. Then, when you specify your stop-loss size in ticks, the indicator will immediately tell you the number of contracts to use to stay within your risk percentage.
Futures Risk Manager Pro (v6 stable)This indicator will allow you to calculate your risk management per position.
You must first enter your capital and your risk percentage. Then, when you specify your stop-loss size in ticks, the indicator will immediately tell you the number of contracts to use to stay within your risk percentage.
Single AHR DCA (HM) — AHR Pane (customized quantile)Customized note
The log-regression window LR length controls how long a long-term fair value path is estimated from historical data.
The AHR window AHR window length controls over which historical regime you measure whether the coin is “cheap / expensive”.
When you choose a log-regression window of length L (years) and an AHR window of length A (years), you can intuitively read the indicator as:
“Within the last A years of this regime, relative to the long-term trend estimated over the same A years, the current price is cheap / neutral / expensive.”
Guidelines:
In general, set the AHR window equal to or slightly longer than the LR window:
If the AHR window is much longer than LR, you mix different baselines (different LR regimes) into one distribution.
If the AHR window is much shorter than LR, quantiles mostly reflect a very local slice of history.
For BTC / ETH and other BTC-like assets, you can use relatively long horizons (e.g. LR ≈ 3–5 years, AHR window ≈ 3–8 years).
For major altcoins (BNB / SOL / XRP and similar high-beta assets), it is recommended to use equal or slightly shorter horizons, e.g. LR ≈ 2–3 years, AHR window ≈ 2–3 years.
1. Price series & windows
Working timeframe: daily (1D).
Let the daily close of the current symbol on day t be P_t .
Main length parameters:
HM window: L_HM = maLen (default 200 days)
Log-regression window: L_LR = lrLen (default 1095 days ≈ 3 years)
AHR window (regime window): W = windowLen (default 1095 days ≈ 3 years)
2. Harmonic moving average (HM)
On a window of length L_HM, define the harmonic mean:
HM_t = ^(-1)
Here eps = 1e-10 is used to avoid division by zero.
Intuition: HM is more sensitive to low prices – an extremely low price inside the window will drag HM down significantly.
3. Log-regression baseline (LR)
On a window of length L_LR, perform a linear regression on log price:
Over the last L_LR bars, build the series
x_k = log( max(P_k, eps) ), for k = t-L_LR+1 ... t, and fit
x_k ≈ a + b * k.
The fitted value at the current index t is
log_P_hat_t = a + b * t.
Exponentiate to get the log-regression baseline:
LR_t = exp( log_P_hat_t ).
Interpretation: LR_t is the long-term trend / fair value path of the current regime over the past L_LR days.
4. HM-based AHR (valuation ratio)
At each time t, build an HM-based AHR (valuation multiple):
AHR_t = ( P_t / HM_t ) * ( P_t / LR_t )
Interpretation:
P_t / HM_t : deviation of price from the mid-term HM (e.g. 200-day harmonic mean).
P_t / LR_t : deviation of price from the long-term log-regression trend.
Multiplying them means:
if price is above both HM and LR, “expensiveness” is amplified;
if price is below both, “cheapness” is amplified.
Typical reading:
AHR_t < 1 : price is below both mid-term mean and long-term trend → statistically cheaper.
AHR_t > 1 : price is above both mid-term mean and long-term trend → statistically more expensive.
5. Empirical quantile thresholds (Opp / Risk)
On each new day, whenever AHR_t is valid, add it into a rolling array:
A_t_window = { AHR_{t-W+1}, ..., AHR_t } (at most W = windowLen elements)
On this empirical distribution, define two quantiles:
Opportunity quantile: q_opp (default 15%)
Risk quantile: q_risk (default 65%)
Using standard percentile computation (order statistics + linear interpolation), we get:
Opp threshold:
theta_opp = Percentile( A_t_window, q_opp )
Risk threshold:
theta_risk = Percentile( A_t_window, q_risk )
We also compute the percentile rank of the current AHR inside the same history:
q_now = PercentileRank( A_t_window, AHR_t ) ∈
This yields three valuation zones:
Opportunity zone: AHR_t <= theta_opp
(corresponds to roughly the cheapest ~q_opp% of historical states in the last W days.)
Neutral zone: theta_opp < AHR_t < theta_risk
Risk zone: AHR_t >= theta_risk
(corresponds to roughly the most expensive ~(100 - q_risk)% of historical states in the last W days.)
All quantiles are purely empirical and symbol-specific: they are computed only from the current asset’s own history, without reusing BTC thresholds or assuming cross-asset similarity.
6. DCA simulation (lightweight, rolling window)
Given:
a daily budget B (input: budgetPerDay), and
a DCA simulation window H (input: dcaWindowLen, default 900 days ≈ 2.5 years),
The script applies the following rule on each new day t:
If thresholds are unavailable or AHR_t > theta_risk
→ classify as Risk zone → buy = 0
If AHR_t <= theta_opp
→ classify as Opportunity zone → buy = 2B (double size)
Otherwise (Neutral zone)
→ buy = B (normal DCA)
Daily invested cash:
C_t ∈ {0, B, 2B}
Daily bought quantity:
DeltaQ_t = C_t / P_t
The script keeps rolling sums over the last H days:
Cumulative position:
Q_H = sum_{k=t-H+1..t} DeltaQ_k
Cumulative invested cash:
C_H = sum_{k=t-H+1..t} C_k
Current portfolio value:
PortVal_t = Q_H * P_t
Cumulative P&L:
PnL_t = PortVal_t - C_H
Active days:
number of days in the last H with C_k > 0.
These results are only used to visualize how this AHR-quantile-driven DCA rule would have behaved over the recent regime, and do not constitute financial advice.
ZY Target TerminatorThe indicator generates trading signals. The profitability displayed on the signal at the time it is generated is the maximum profitability of the trade opened with the preceding signal. Therefore, avoid trading pairs and trends where this ratio is insufficient.
Position Sizing Calculator (Real-Time) - Futures Edition█ SUMMARY
The following indicator is a Position Sizing Calculator based on Average True Range (ATR), originally developed by market technician J. Welles Wilder Jr., intended for real-time trading.
This script utilizes the user's account size, acceptable risk percentage, and a stop-loss distance based on ATR to dynamically calculate the appropriate position size for each trade in real time.
█ BACKGROUND
Developed for use on the Micro E-mini Nasdaq-100 futures (MNQ), this script provides traders with continuously updated dynamic position sizes. It enables traders to instantly determine the exact number of contracts to use when entering a trade while staying within their acceptable risk tolerance.
This real-time position sizing tool helps traders make well-informed decisions when planning trade entries and calculating maximum stop-loss levels, ultimately enhancing risk management.
█ USER INPUTS
Trading Account Size: Total dollar value of the user's trading account.
Acceptable Risk (%): Maximum percentage of the trading account that the user is willing to risk per trade.
ATR Multiplier for Stop-Loss: Multiplier used to determine the distance of the stop-loss from the current price, based on the ATR value.
ATR Length: The length of the lookback period used to calculate the ATR value.
Show Target Risk Row: Toggle to hide/show the Target Risk Row
SL Levels Display: Option to see Both, Long Only, Short Only, or None of the Stop Loss Level Values.
Contract Point Value ($): Point value per contract. Tooltip highlights common values.
Tick Size: Minimum Price Movement (Default set to 0.25)
Minimum Contracts: Override the Minimum Contracts per trade to a user selected value.
(May Exceed User's Target Risk)
2-Year Real RateThe 2-year real rate is the inflation-adjusted yield on a 2-year U.S. Treasury—essentially the market’s expectation for short-term “true” interest rates after subtracting expected inflation (often approximated as nominal 2Y yield – breakeven inflation).
It matters because it reflects the actual cost of capital and is one of the cleanest gauges of the Fed’s effective stance: rising real rates mean tightening financial conditions, falling real rates mean loosening. In trading, the 2Y real rate is a powerful macro risk-on/risk-off indicator—equities, long-duration tech, crypto, and EM FX generally weaken when real rates rise, while USD and front-end rate-sensitive trades tend to strengthen. Watching inflections in the 2Y real rate helps you time shifts in liquidity, gauge how aggressively the market is pricing Fed moves, and position for cross-asset trends driven by changes in real funding conditions.
ATR Risk Manager v5.2 [Auto-Extrapolate]If you ever had problems knowing how much contracts to use for a particular timeframe to keep your risk within acceptable levels, then this indicator should help. You just have to define your accepted risk based on ATR and also percetage of your drawdown, then the indicator will tell you how many contracts you should use. If the risk is too high, it will also tell you not to trade. This is only for futures NQ MNQ ES MES GC MGC CL MCL MYM and M2K.
Multi-Ticker Anchored CandlesMulti-Ticker Anchored Candles (MTAC) is a simple tool for overlaying up to 3 tickers onto the same chart. This is achieved by interpreting each symbol's OHLC data as percentages, then plotting their candle points relative to the main chart's open. This allows for a simple comparison of tickers to track performance or locate relationships between them.
> Background
The concept of multi-ticker analysis is not new, this type of analysis can be extremely helpful to get a gauge of the over all market, and it's sentiment. By analyzing more than one ticker at a time, relationships can often be observed between tickers as time progresses.
While seeing multiple charts on top of each other sounds like a good idea...each ticker has its own price scale, with some being only cents while others are thousands of dollars.
Directly overlaying these charts is not possible without modification to their sources.
By using a fixed point in time (Period Open) and percentage performance relative to that point for each ticker, we are able to directly overlay symbols regardless of their price scale differences.
The entire process used to make this indicator can be summed up into 2 keywords, "Scaling & Anchoring".
> Scaling
First, we start by determining a frame of reference for our analysis. The indicator uses timeframe inputs to determine sessions which are used, by default this is set to 1 day.
With this in place, we then determine our point of reference for scaling. While this could be any point in time, the most sensible for our application is the daily (or session) open.
Each symbol shares time, therefore, we can take a price point from a specified time (Opening Price) and use it to sync our analysis over each period.
Over the day, we track the percentage performance of each ticker's OHLC values relative to its daily open (% change from open).
Since each ticker's data is now tracked based on its opening price, all data is now using the same scale.
The scale is simply "% change from open".
> Anchoring
Now that we have our scaled data, we need to put it onto the chart.
Since each point of data is relative to it's daily open (anchor point), relatively speaking, all daily opens are now equal to each other.
By adding the scaled ticker data to the main chart's daily open, each of our resulting series will be properly scaled to the main chart's data based on percentages.
Congratulations, We have now accurately scaled multiple tickers onto one chart.
> Display
The indicator shows each requested ticker as different colored candlesticks plotted on top of the main chart.
Each ticker has an associated label in front of the current bar, each component of this label can be toggled on or off to allow only the desired information to be displayed.
To retain relevance, at the start of each session, a "Session Break" line is drawn, as well as the opening price for the session. These can also be toggled.
Note: The opening price is the opening price for ALL tickers, when a ticker crosses the open on the main chart, it is crossing its own opening price as well.
> Examples
In the chart below, we can see NYSE:MCD NASDAQ:WEN and NASDAQ:JACK overlaid on a NASDAQ:SBUX chart.
From this, we can see NASDAQ:JACK was the top gainer on the day. While this was the case, it also fell roughly 4% from its peak near lunchtime. Unlike the top gainer, we can see the other 3 tickers ended their day near their daily high.
In the explanations above, the daily timeframe is used since it is the default; however, the analysis is not constrained to only days. The anchoring period can be set to any timeframe period.
In the chart below, you can observe the Daily, Weekly, and Monthly anchored charts side-by-side.
This can be used on all tickers, timeframes, and markets. While a typical application may be comparing relevant assets... the script is not limited.
Below we have a chart tracking COMEX:GCV2026 , FX:EURUSD , and COINBASE:DOGEUSD on the AMEX:SPY chart.
While these tickers are not typically compared side-by-side, here it is simply a display of the capabilities of the script.
Enjoy!
Relative Performance Analyzer [AstrideUnicorn]Relative Performance Analyzer (RPA) is a performance analysis tool inspired by the data comparison features found in professional trading terminals. The RPA replicates the analytical approach used by portfolio managers and institutional analysts who routinely compare multiple securities or other types of data to identify relative strength opportunities, make allocation decisions, choose the most optimal investment from several alternatives, and much more.
Key Features:
Multi-Symbol Comparison: Track up to 5 different symbols simultaneously across any asset class or dataset
Two Performance Calculation Methods: Choose between percentage returns or risk-adjusted returns
Interactive Analysis: Drag the start date line on the chart or manually choose the start date in the settings
Professional Visualization: High-contrast color scheme designed for both dark and light chart themes
Live Performance Table: Real-time display of current return values sorted from the top to the worst performers
Practical Use Cases:
ETF Selection: Compare similar ETFs (e.g., SPY vs IVV vs VOO) to identify the most efficient investment
Sector Rotation: Analyze which sectors are showing relative strength for strategic allocation
Competitive Analysis: Compare companies within the same industry to identify leaders (e.g., APPLE vs SAMSUNG vs XIAOMI)
Cross-Asset Allocation: Evaluate performance across stocks, bonds, commodities, and currencies to guide portfolio rebalancing
Risk-Adjusted Decisions: Use risk-adjusted performance to find investments with the best returns per unit of risk
Example Scenarios:
Analyze whether tech stocks are outperforming the broader market by comparing XLK to SPY
Evaluate which emerging market ETF (EEM vs VWO) has provided better risk-adjusted returns over the past year
HOW DOES IT WORK
The indicator calculates and visualizes performance from a user-defined starting point using two methodologies:
Percentage Returns: Standard total return calculation showing percentage change from the start date
Risk-Adjusted Returns: Cumulative returns divided by the volatility (standard deviation), providing insight into the efficiency of performance. An expanding window is used to calculate the volatility, ensuring accurate risk-adjusted comparisons throughout the analysis period.
HOW TO USE
Setup Your Comparison: Enable up to 5 assets and input their symbols in the settings
Set Analysis Period: When you first launch the indicator, select the start date by clicking on the price chart. The vertical start date line will appear. Drag it on the chart or manually input a specific date to change the start date.
Choose Return Type: Select between percentage or risk-adjusted returns based on your analysis needs
Interpret Results
Use the real-time table for precise current values
SETTINGS
Assets 1-5: Toggle on/off and input symbols for comparison (stocks, ETFs, indices, forex, crypto, fundamental data, etc.)
Start Date: Set the initial point for return calculations (drag on chart or input manually)
Return Type: Choose between "Percentage" or "Risk-Adjusted" performance.
Technology Stocks RSPSTechnology Stocks RSPS Indicator - TradingView Description
Overview
The Technology Stocks RSPS (Relative Strength Portfolio System) indicator is a sophisticated portfolio allocation tool designed specifically for technology sector stocks. It calculates relative strength positions and provides dynamic allocation recommendations based on technical price momentum analysis.
Key Features
- Relative Strength Analysis: Compares 15 major technology stocks and the XLK sector ETF
against each other and gold as a baseline
- Dynamic Portfolio Allocation: Automatically calculates optimal position sizes based on relative
performance
- Visual Portfolio Performance: Tracks cumulative portfolio returns with color-coded
performance indicators
- Customizable Table Display: Shows real-time allocation percentages and optional cash values
for each position
- Technical Momentum Filtering: Uses normalized indicators to identify strength and filter out
weak positions
Included Assets
Sector ETF: XLK
Major Tech Stocks: AAPL, MSFT, NVDA, AVGO, CRM, ORCL, CSCO, ADBE, ACN, AMD, IBM, INTC, NOW, TXN
Benchmark: Gold (TVC:GOLD)
How It Works
The indicator calculates a relative strength score for each asset by comparing it against:
Gold (baseline commodity)
All other technology stocks in the pool
The XLK sector ETF
Assets with positive relative strength receive portfolio allocations proportional to their strength scores. Weak or negative performers are automatically filtered out (allocated 0%).
Visual Elements
Red Area: Aggregate strength of major technology stocks
Navy Blue Area: Overall technical positioning index (TPI)
Performance Line: Cumulative portfolio return (blue = cash-heavy, red = equity-heavy)
Allocation Table: Bottom-left display showing current recommended positions
Important Limitations
This indicator primarily uses technical data and has significant limitations:
❌ No fundamental economic data (ISM, CLI, etc.)
❌ Limited monetary data - missing critical components:
comprehensive monetary data
Funding rates
Detailed bond spreads analysis
Collateral data
❌ No sentiment indicators
❌ No options flow or derivatives data
❌ No earnings or valuation metrics
The indicator focuses purely on price-based relative strength and technical momentum. Users should combine this tool with fundamental analysis, economic data, and proper risk management for complete investment decisions.
Settings
Plot Table: Toggle allocation table visibility
Use Cash: Enable to display dollar amounts based on portfolio size
Cash Amount: Set your total portfolio value for cash allocation calculations
Use Cases
Sector rotation within technology stocks
Relative strength-based portfolio rebalancing
Technical momentum screening for tech sector
Dynamic position sizing based on price trends
Technical Notes
The script avoids for-loops to reduce calculation errors and noise
Uses semi-individual calculations for each asset
Requires the Unicorpus/NormalizedIndicators/1 library for normalized momentum calculations
Maximum lookback: 100 bars
Disclaimer: This indicator is a technical tool only and should not be used as the sole basis for investment decisions. It does not incorporate fundamental, economic, or comprehensive monetary data. Always conduct thorough research and consider your risk tolerance before making investment decisions.
2s10s Bull/Bear Steepener/Flattener (Intraday bars)A simple indicator that tracks the curve of the US2y and US10y
Marcaj Ore 07:00 și 18:00 (Stabil v2)For backtesting and remember times that you can be active in the market.
Oracle Protocol — Arch Public (Testing Clone) Oracle Protocol — Arch Public Series (testing clone)
This model implements the Arch Public Oracle structure: a systematic accumulation-and-distribution engine built around a dynamic Accumulation Cost Base (ACB), strict profit-gate exit logic, and a capital-bounded flywheel reinvestment system.
It is designed for transparent execution, deterministic behaviour, and rule-based position management.
Core Function Set
1. Accumulation Framework (ACB-Driven)
The accumulation engine evaluates market movement against defined entry conditions, including:
Percentage-based entry-drop triggers
Optional buy-below-ACB mode
Capital-gated entries tied to available ledger balance
Fixed-dollar and min-dollar entry rules (as seen in Arch public materials)
Automated sizing through flywheel capital
Range-bounded ledger for controlled backtesting input
Each qualifying buy updates the live ACB, maintains the internal ledger, and forms the next reference point for exit evaluation.
No forecasting mechanisms are included.
2. Profit-Gate Exit System
Exits are governed by the standard Arch public approach:
A sealed ACB reference for threshold evaluation
Optional live-ACB visibility
Profit-gate triggers defined per asset class
Candle-confirmation integration (“ProfitGate + Candle” mode)
Distribution only when the smallest active threshold is met
This provides a consistent cadence with published Arch diagrams and PDFs.
3. Once-Per-Rally Governance
After a distribution, the algorithm locks until price retraces below the most recent accumulation base.
Only after re-arming can the next profit gate activate.
This prevents over-frequency selling and aligns with the public-domain Oracle behaviour.
4. Quiet-Bars & Threshold Cluster Control
A volatility-stabilisation layer prevents multiple exits from micro-fluctuations or transient spikes.
This ensures clean execution during fast markets and high volatility.
5. Flywheel Reinvestment
Distribution proceeds automatically return to the capital pool where permitted, creating a closed system of:
Entry sizing
Exit proceeds
Ledger-managed capital state
All sizing respects capital boundaries and does not breach dollar floors or overrides.
6. Automation Hooks and Integration
The script exposes:
3Commas-compatible JSON sizing
Entry/exit signalling via alertcondition()
Deterministic event reporting suitable for external automation
This allows consistent deployment across automated execution environments.
7. Visual Tooling
Optional displays include:
Live ACB line
Exit-guide markers
Capital, state, and ledger panels
Realized/unrealized outcome tracking based on internal logic only
Visual components do not influence execution rules.
Operating Notes
This model is rule-based, deterministic, and non-predictive.
It executes only according to the explicit thresholds, capital limits, and state transitions defined within the script.
No discretionary or forward-looking logic is included.
Stochastic Hash Strat [Hash Capital Research]# Stochastic Hash Strategy by Hash Capital Research
## 🎯 What Is This Strategy?
The **Stochastic Slow Strategy** is a momentum-based trading system that identifies oversold and overbought market conditions to capture mean-reversion opportunities. Think of it as a "buy low, sell high" approach with smart mathematical filters that remove emotion from your trading decisions.
Unlike fast-moving indicators that generate excessive noise, this strategy uses **smoothed stochastic oscillators** to identify only the highest-probability setups when momentum truly shifts.
---
## 💡 Why This Strategy Works
Most traders fail because they:
- **Chase prices** after big moves (buying high, selling low)
- **Overtrade** in choppy, directionless markets
- **Exit too early** or hold losses too long
This strategy solves all three problems:
1. **Entry Discipline**: Only trades when the stochastic oscillator crosses in extreme zones (oversold for longs, overbought for shorts)
2. **Cooldown Filter**: Prevents revenge trading by forcing a waiting period after each trade
3. **Fixed Risk/Reward**: Pre-defined stop-loss and take-profit levels ensure consistent risk management
**The Math Behind It**: The stochastic oscillator measures where the current price sits relative to its recent high-low range. When it's below 25, the market is oversold (time to buy). When above 70, it's overbought (time to sell). The crossover with its moving average confirms momentum is shifting.
---
## 📊 Best Markets & Timeframes
### ⭐ OPTIMAL PERFORMANCE:
**Crude Oil (WTI) - 12H Timeframe**
- **Why it works**: Oil markets have predictable volatility patterns and respect technical levels
**AAVE/USD - 4H to 12H Timeframe**
- **Why it works**: DeFi tokens exhibit strong momentum cycles with clear extremes
### ✅ Also Works Well On:
- **BTC/USD** (12H, Daily) - Lower frequency but high win rate
- **ETH/USD** (8H, 12H) - Balanced volatility and liquidity
- **Gold (XAU/USD)** (Daily) - Classic mean-reversion asset
- **EUR/USD** (4H, 8H) - Lower volatility, requires patience
### ❌ Avoid Using On:
- Timeframes below 4H (too much noise)
- Low-liquidity altcoins (wide spreads kill performance)
- Strongly trending markets without pullbacks (Bitcoin in 2021)
- News-driven instruments during major events
---
## 🎛️ Understanding The Settings
### Core Stochastic Parameters
**Stochastic Length (Default: 16)**
- Controls the lookback period for price comparison
- Lower = faster reactions, more signals (10-14 for volatile markets)
- Higher = smoother signals, fewer trades (16-21 for stable markets)
- **Pro tip**: Use 10 for crypto 4H, 16 for commodities 12H
**Overbought Level (Default: 70)**
- Threshold for short entries
- Lower values (65-70) = more trades, earlier entries
- Higher values (75-80) = fewer but higher-conviction trades
- **Sweet spot**: 70 works for most assets
**Oversold Level (Default: 25)**
- Threshold for long entries
- Higher values (25-30) = more trades, earlier entries
- Lower values (15-20) = fewer but stronger bounce setups
- **Sweet spot**: 20-25 depending on market conditions
**Smooth K & Smooth D (Default: 7 & 3)**
- Additional smoothing to filter out whipsaws
- K=7 makes the indicator slower and more reliable
- D=3 is the signal line that confirms the trend
- **Don't change these unless you know what you're doing**
---
### Risk Management
**Stop Loss % (Default: 2.2%)**
- Automatically exits losing trades
- Should be 1.5x to 2x your average market volatility
- Too tight = death by a thousand cuts
- Too wide = uncontrolled losses
- **Calibration**: Check ATR indicator and set SL slightly above it
**Take Profit % (Default: 7%)**
- Automatically exits winning trades
- Should be 2.5x to 3x your stop loss (reward-to-risk ratio)
- This default gives 7% / 2.2% = 3.18:1 R:R
- **The golden rule**: Never have R:R below 2:1
---
### Trade Filters
**Bar Cooldown Filter (Default: ON, 3 bars)**
- **What it does**: Forces you to wait X bars after closing a trade before entering a new one
- **Why it matters**: Prevents emotional revenge trading and overtrading in choppy markets
- **Settings guide**:
- 3 bars = Standard (good for most cases)
- 5-7 bars = Conservative (oil, slow-moving assets)
- 1-2 bars = Aggressive (only for experienced traders)
**Exit on Opposite Extreme (Default: ON)**
- Closes your long when stochastic hits overbought (and vice versa)
- Acts as an early profit-taking mechanism
- **Leave this ON** unless you're testing other exit strategies
**Divergence Filter (Default: OFF)**
- Looks for price/momentum divergences for additional confirmation
- **When to enable**: Trending markets where you want fewer but higher-quality trades
- **Keep OFF for**: Mean-reverting markets (oil, forex, most of the time)
---
## 🚀 Quick Start Guide
### Step 1: Set Up in TradingView
1. Open TradingView and navigate to your chart
2. Click "Pine Editor" at the bottom
3. Copy and paste the strategy code
4. Click "Add to Chart"
5. The strategy will appear in a separate pane below your price chart
### Step 2: Choose Your Market
**If you're trading Crude Oil:**
- Timeframe: 12H
- Keep all default settings
- Watch for signals during London/NY overlap (8am-11am EST)
**If you're trading AAVE or crypto:**
- Timeframe: 4H or 12H
- Consider these adjustments:
- Stochastic Length: 10-14 (faster)
- Oversold: 20 (more aggressive)
- Take Profit: 8-10% (higher targets)
### Step 3: Wait for Your First Signal
**LONG Entry** (Green circle appears):
- Stochastic crosses up below oversold level (25)
- Price likely near recent lows
- System places limit order at take profit and stop loss
**SHORT Entry** (Red circle appears):
- Stochastic crosses down above overbought level (70)
- Price likely near recent highs
- System places limit order at take profit and stop loss
**EXIT** (Orange circle):
- Position closes either at stop, target, or opposite extreme
- Cooldown period begins
### Step 4: Let It Run
The biggest mistake? **Interfering with the system.**
- Don't close trades early because you're scared
- Don't skip signals because you "have a feeling"
- Don't increase position size after a big win
- Don't revenge trade after a loss
**Follow the system or don't use it at all.**
---
### Important Risks:
1. **Drawdown Pain**: You WILL experience losing streaks of 5-7 trades. This is mathematically normal.
2. **Whipsaw Markets**: Choppy, range-bound conditions can trigger multiple small losses.
3. **Gap Risk**: Overnight gaps can cause your actual fill to be worse than the stop loss.
4. **Slippage**: Real execution prices differ from backtested prices (factor in 0.1-0.2% slippage).
---
## 🔧 Optimization Guide
### When to Adjust Settings:
**Market Volatility Increased?**
- Widen stop loss by 0.5-1%
- Increase take profit proportionally
- Consider increasing cooldown to 5-7 bars
**Getting Too Few Signals?**
- Decrease stochastic length to 10-12
- Increase oversold to 30, decrease overbought to 65
- Reduce cooldown to 2 bars
**Getting Too Many Losses?**
- Increase stochastic length to 18-21 (slower, smoother)
- Enable divergence filter
- Increase cooldown to 5+ bars
- Verify you're on the right timeframe
### A/B Testing Method:
1. **Run default settings for 50 trades** on your chosen market
2. Document: Win rate, profit factor, max drawdown, emotional tolerance
3. **Change ONE variable** (e.g., oversold from 25 to 20)
4. Run another 50 trades
5. Compare results
6. Keep the better version
**Never change multiple settings at once** or you won't know what worked.
---
## 📚 Educational Resources
### Key Concepts to Learn:
**Stochastic Oscillator**
- Developed by George Lane in the 1950s
- Measures momentum by comparing closing price to price range
- Formula: %K = (Close - Low) / (High - Low) × 100
- Similar to RSI but more sensitive to price movements
**Mean Reversion vs. Trend Following**
- This is a **mean reversion** strategy (price returns to average)
- Works best in ranging markets with defined support/resistance
- Fails in strong trending markets (2017 Bitcoin, 2020 Tech stocks)
- Complement with trend filters for better results
**Risk:Reward Ratio**
- The cornerstone of profitable trading
- Winning 40% of trades with 3:1 R:R = profitable
- Winning 60% of trades with 1:1 R:R = breakeven (after fees)
- **This strategy aims for 45% win rate with 2.5-3:1 R:R**
### Recommended Reading:
- *"Trading Systems and Methods"* by Perry Kaufman (Chapter on Oscillators)
- *"Mean Reversion Trading Systems"* by Howard Bandy
- *"The New Trading for a Living"* by Dr. Alexander Elder
---
## 🛠️ Troubleshooting
### "I'm not seeing any signals!"
**Check:**
- Is your timeframe 4H or higher?
- Is the stochastic actually reaching extreme levels (check if your asset is stuck in middle range)?
- Is cooldown still active from a previous trade?
- Are you on a low-liquidity pair?
**Solution**: Switch to a more volatile asset or lower the overbought/oversold thresholds.
---
### "The strategy keeps losing money!"
**Check:**
- What's your win rate? (Below 35% is concerning)
- What's your profit factor? (Below 0.8 means serious issues)
- Are you trading during major news events?
- Is the market in a strong trend?
**Solution**:
1. Verify you're using recommended markets/timeframes
2. Increase cooldown period to avoid choppy markets
3. Reduce position size to 5% while you diagnose
4. Consider switching to daily timeframe for less noise
---
### "My stop losses keep getting hit!"
**Check:**
- Is your stop loss tighter than the average ATR?
- Are you trading during high-volatility sessions?
- Is slippage eating into your buffer?
**Solution**:
1. Calculate the 14-period ATR
2. Set stop loss to 1.5x the ATR value
3. Avoid trading right after market open or major news
4. Factor in 0.2% slippage for crypto, 0.1% for oil
---
## 💪 Pro Tips from the Trenches
### Psychological Discipline
**The Three Deadly Sins:**
1. **Skipping signals** - "This one doesn't feel right"
2. **Early exits** - "I'll just take profit here to be safe"
3. **Revenge trading** - "I need to make back that loss NOW"
**The Solution:** Treat your strategy like a business system. Would McDonald's skip making fries because the cashier "doesn't feel like it today"? No. Systems work because of consistency.
---
### Position Management
**Scaling In/Out** (Advanced)
- Enter 50% position at signal
- Add 50% if stochastic reaches 10 (oversold) or 90 (overbought)
- Exit 50% at 1.5x take profit, let the rest run
**This is NOT for beginners.** Master the basic system first.
---
### Market Awareness
**Oil Traders:**
- OPEC meetings = volatility spikes (avoid or widen stops)
- US inventory reports (Wed 10:30am EST) = avoid trading 2 hours before/after
- Summer driving season = different patterns than winter
**Crypto Traders:**
- Monday-Tuesday = typically lower volatility (fewer signals)
- Thursday-Sunday = higher volatility (more signals)
- Avoid trading during exchange maintenance windows
---
## ⚖️ Legal Disclaimer
This trading strategy is provided for **educational purposes only**.
- Past performance does not guarantee future results
- Trading involves substantial risk of loss
- Only trade with capital you can afford to lose
- No one associated with this strategy is a licensed financial advisor
- You are solely responsible for your trading decisions
**By using this strategy, you acknowledge that you understand and accept these risks.**
---
## 🙏 Acknowledgments
Strategy development inspired by:
- George Lane's original Stochastic Oscillator work
- Modern quantitative trading research
- Community feedback from hundreds of backtests
Built with ❤️ for retail traders who want systematic, disciplined approaches to the markets.
---
**Good luck, stay disciplined, and trade the system, not your emotions.**






















