How to force strategies fire exit alerts not reversalsPineScript has gone a long way, from very simple and little-capable scripting language to a robust coding platform with reliable execution endpoints. However, this one small intuitivity glitch is still there and is likely to stay, because it is traditionally justified and quite intuitive for significant group of traders. I'm sharing this workaround in response to frequent inquiries about it.
What's the glitch? When setting alerts on strategies to be synchronized with TradingView's Strategy Tester events, using simple alert messages such as "buy" or "sell" based on entry direction seems straightforward by inserting {{strategy.order.action}} into the Create Alert's "Message" field. Because "buy" or "sell" are exactly the strings produced by {{strategy.order.action}} placeholder. However, complications arise when attempting to EXIT positions without reversing, whether triggered by price levels like Stop Loss or Take Profit, or logical conditions to close trades. Those bricks fall apart, because on such events {{strategy.order.action}} sends the same "sell" for exiting buy positions and "buy" for exiting sell positions, instead of something more differentiating like "closebuy" or "closesell". As a result reversal trades are opened, instead of simply closing the open ones.
This convention harkens back to traditional stock market practices, where traders either bought shares to enter positions or sold them to exit. However, modern trading encompasses diverse instruments like CFDs, indices, and Forex, alongside advanced features such as Stop Loss, reshaping the landscape. Despite these advancements, the traditional nomenclature persists.
And is poised to stay on TradingView as well, so we need a workaround to get a simple strategy going. Luckily it is here and is called alert_message . It is a parameter, which needs to be added into each strategy.entry() / strategy.exit() / strategy.close() function call - each call, which causes Strategy Tester to produce entry or exit orders. As in this example script:
line 12: strategy.entry(... alert_message ="buy")
line 14: strategy.entry(... alert_message ="sell")
line 19: strategy.exit(... alert_message ="closebuy")
line 20: strategy.exit(... alert_message ="closesell")
line 24: strategy.close(... alert_message ="closebuy")
line 26: strategy.close(... alert_message ="closesell")
These alert messages are compatible with the Alerts Syntax of TradingConnector - a tool facilitating auto-execution of TradingView alerts in MetaTrader 4 or 5. Yes, simple alert messages like "buy" / "sell" / "closebuy" / "closesell" suffice to carry the execution of simple strategy, without complex JSON files with multiple ids and such. Other parameters can be added (actually plenty), but they are only option and that's not a part of this story :)
Last thing left to do is to replace "Message" in Create Alert popup with {{strategy.order.alert_message}} . This placeholder transmits the string defined in the PineScript alert_message= parameter, as outlined in this publication. With this workaround, executing closing alerts becomes seamless within PineScript strategies on TradingView.
Disclaimer: this content is purely educational, especially please don't pay attention to backtest results on any timeframe/ticker.
Stochastic Oscillator
Stochastic / Connectable [Azullian]Advance your market analysis with the Stochastic Oscillator. Identify potential price reversals with precision, aiding in the creation of flexible and accurate strategies.
This connectable Stochastic indicator is part of an indicator system designed to help test, visualize and build strategy configurations without coding. Like all connectable indicators , it interacts through the TradingView input source, which serves as a signal connector to link indicators to each other. All connectable indicators send signal weight to the next node in the system until it reaches either a connectable signal monitor, signal filter and/or strategy.
█ UNIFORM SETTINGS AND A WAY OF WORK
Although connectable indicators may have specific weight scoring conditions, they all aim to follow a standardized general approach to weight scoring settings, as outlined below.
■ Connectable indicators - Settings
• 🗲 Energy: Energy applies an ATR multiplier to the plotted shapes on the chart. A higher value plots shapes farther away from the candle, enhancing visibility.
• ☼ Brightness: Brightness determines the opacity of the shape plotted on the chart, aiding visibility. Indicator weight also influences opacity.
• → Input: Use the input setting to specify a data source for the indicator. Here you can connect the indicator to other indicators.
• ⌥ Flow: Determine where you want to receive signals from:
○ Both: Weights from this indicator and the connected indicator will apply
○ Indicator only: Only weights from this indicator will apply
○ Input only: Only weights from the connected indicator will apply
• ⥅ Weight multiplier: Multiply all weights in the entire indicator by a given factor, useful for quickly testing different indicators in a granular setup.
• ⥇ Threshold: Set a threshold to indicate the minimum amount of weight it should receive to pass it through to the next indicator.
• ⥱ Limiter: Set a hard limit to the maximum amount of weight that can be fed through the indicator.
■ Connectable indicators - Weight scoring settings
▢ Weight scoring conditions
• SM – Signal mode: Enable specific conditions for weight scoring
○ All: All signals will be scored.
○ Entries only: Only entries will score.
○ Exits only: Only exits will score.
○ Entries & exits: Both entries and exits will score.
○ Zone: Continuous scoring for each candle within the zone.
• SP – Signal period: Defines a range of candles within which a signal can score.
• SC - Signal count: Specifies the number of bars to retrospectively examine and score.
○ Single: Score for a single occurrence
○ All occurrences: Score for all occurrences
○ Single + Threshold: Score for single occurrences within the signal period (SP)
○ Every + Threshold: Score for all occurrences within the signal period (SP)
▢ Weight scoring direction
• ES: Enter Short weight
• XL: Exit long weight
• EL: Enter Long weight
• XS: Exit Short weight
▢ Weight scoring values
• Weights can hold either positive or negative scores. Positive weights enhance a particular trading direction, while negative weights diminish it.
█ STOCHASTIC - INDICATOR SETTINGS
■ Main settings
• Enable/Disable Indicator: Toggle the entire indicator on or off.
• S - Source: Choose an alternative data source for the Stochastic calculation.
• T - Timeframe: Select an alternative timeframe for the Stochastic calculation.
• KL - %K Length: Define the number of bars or periods used in the calculation of the %K value.
• OB - Overbought Level: Determine the Stochastic value at which overbought conditions are met.
• OS - Oversold Level: Specify the Stochastic value at which oversold conditions are met.
• %K - %K Smoothing: DDefine the number of bars or periods used to smooth the %K value.
• %D - %D Smoothing: Define the number of bars or periods used to calculate and smooth the %D
■ Scoring functionality
• The Stochastic scores long entries when the %K line crosses above the %D line within the OS (oversold) area.
• The Stochastic scores long exits when the %K line crosses below the %D line after being in the OS (oversold) area.
• The Stochastic scores long zones for the duration the %K is above the %D line within the OS (oversold) area.
• The Stochastic scores short entries when the %K line crosses below the %D line within the OB (overbought) area.
• The Stochastic scores short exits when the %K line crosses above the %D line after being in the OB (overbought) area.
• The Stochastic scores short zones for the duration the %K is below the %D line within the OB (overbought) area.
█ PLOTTING
• Standard: Symbols (EL, XS, ES, XL) appear relative to candles based on set conditions. Their opacity and position vary with weight.
• Conditional Settings: A larger icon appears if global conditions are met. For instance, with a Threshold(⥇) of 12, Signal Period (SP) of 3, and Scoring Condition (SC) set to "EVERY", a Stochastic signaling over two times in 3 candles (scoring 6 each) triggers a larger icon.
█ USAGE OF CONNECTABLE INDICATORS
■ Connectable chaining mechanism
Connectable indicators can be connected directly to the signal monitor, signal filter or strategy , or they can be daisy chained to each other while the last indicator in the chain connects to the signal monitor, signal filter or strategy. When using a signal filter you can chain the filter to the strategy input to make your chain complete.
• Direct chaining: Connect an indicator directly to the signal monitor, signal filter or strategy through the provided inputs (→).
• Daisy chaining: Connect indicators using the indicator input (→). The first in a daisy chain should have a flow (⌥) set to 'Indicator only'. Subsequent indicators use 'Both' to pass the previous weight. The final indicator connects to the signal monitor, signal filter, or strategy.
■ Set up this indicator with a signal filter and strategy
The indicator provides visual cues based on signal conditions. However, its weight system is best utilized when paired with a connectable signal filter, signal monitor, or strategy .
Let's connect the Stochastic to a connectable signal filter and a strategy :
1. Load all relevant indicators
• Load Stochastic / Connectable
• Load Signal filter / Connectable
• Load Strategy / Connectable
2. Signal Filter: Connect the Stochastic to the Signal Filter
• Open the signal filter settings
• Choose one of the three input dropdowns (1→, 2→, 3→) and choose : Stochastic / Connectable: Signal Connector
• Toggle the enable box before the connected input to enable the incoming signal
3. Signal Filter: Update the filter signals settings if needed
• The default settings of the filter enable EL (Enter Long), XL (Exit Long), ES (Enter Short) and XS (Exit Short).
4. Signal Filter: Update the weight threshold settings if needed
• All connectable indicators load by default with a score of 6 for each direction (EL, XL, ES, XS)
• By default, weight threshold (TH) is set at 5. This allows each occurrence to score, as the default score in each connectable indicator is 1 point above the threshold. Adjust to your liking.
5. Strategy: Connect the strategy to the signal filter in the strategy settings
• Select a strategy input → and select the Signal filter: Signal connector
6. Strategy: Enable filter compatible directions
• Set the signal mode of the strategy to a compatible direction with the signal filter.
Now that everything is connected, you'll notice green spikes in the signal filter representing long signals, and red spikes indicating short signals. Trades will also appear on the chart, complemented by a performance overview. Your journey is just beginning: delve into different scoring mechanisms, merge diverse connectable indicators, and craft unique chains. Instantly test your results and discover the potential of your configurations. Dive deep and enjoy the process!
█ BENEFITS
• Adaptable Modular Design: Arrange indicators in diverse structures via direct or daisy chaining, allowing tailored configurations to align with your analysis approach.
• Streamlined Backtesting: Simplify the iterative process of testing and adjusting combinations, facilitating a smoother exploration of potential setups.
• Intuitive Interface: Navigate TradingView with added ease. Integrate desired indicators, adjust settings, and establish alerts without delving into complex code.
• Signal Weight Precision: Leverage granular weight allocation among signals, offering a deeper layer of customization in strategy formulation.
• Advanced Signal Filtering: Define entry and exit conditions with more clarity, granting an added layer of strategy precision.
• Clear Visual Feedback: Distinct visual signals and cues enhance the readability of charts, promoting informed decision-making.
• Standardized Defaults: Indicators are equipped with universally recognized preset settings, ensuring consistency in initial setups across different types like momentum or volatility.
• Reliability: Our indicators are meticulously developed to prevent repainting. We strictly adhere to TradingView's coding conventions, ensuring our code is both performant and clean.
█ COMPATIBLE INDICATORS
Each indicator that incorporates our open-source 'azLibConnector' library and adheres to our conventions can be effortlessly integrated and used as detailed above.
For clarity and recognition within the TradingView platform, we append the suffix ' / Connectable' to every compatible indicator.
█ COMMON MISTAKES, CLARIFICATIONS AND TIPS
• Removing an indicator from a chain: Deleting a linked indicator and confirming the "remove study tree" alert will also remove all underlying indicators in the object tree. Before removing one, disconnect the adjacent indicators and move it to the object stack's bottom.
• Point systems: The azLibConnector provides 500 points for each direction (EL: Enter long, XL: Exit long, ES: Enter short, XS: Exit short) Remember this cap when devising a point structure.
• Flow misconfiguration: In daisy chains the first indicator should always have a flow (⌥) setting of 'indicator only' while other indicator should have a flow (⌥) setting of 'both'.
• Hide attributes: As connectable indicators send through quite some information you'll notice all the arguments are taking up some screenwidth and cause some visual clutter. You can disable arguments in Chart Settings / Status line.
• Layout and abbreviations: To maintain a consistent structure, we use abbreviations for each input. While this may initially seem complex, you'll quickly become familiar with them. Each abbreviation is also explained in the inline tooltips.
• Inputs: Connecting a connectable indicator directly to the strategy delivers the raw signal without a weight threshold, meaning every signal will trigger a trade.
█ A NOTE OF GRATITUDE
Through years of exploring TradingView and Pine Script, we've drawn immense inspiration from the community's knowledge and innovation. Thank you for being a constant source of motivation and insight.
█ RISK DISCLAIMER
Azullian's content, tools, scripts, articles, and educational offerings are presented purely for educational and informational uses. Please be aware that past performance should not be considered a predictor of future results.
Dynamic Momentum Oscillator (DMO) [Angel Algo]Dynamic Momentum Oscillator (DMO)
OVERVIEW: The Dynamic Momentum Oscillator (DMO) is a technical indicator designed to measure the momentum of price movements in financial markets. It combines momentum calculation with dynamic range assessment to provide insights into potential trend reversals and overbought/oversold conditions.
DMO is different from classic momentum oscillators like the RSI or Stochastic Oscillator because it looks at the momentum in relation to how much the price is moving. This helps it give signals that better match what's happening in the market, especially when the market's volatility is changing.
HOW TO USE:
Interpretation:
Thresholds: Horizontal lines mark user-defined threshold levels for overbought (OB) and oversold (OS) conditions, aiding in identifying potential trend pullbacks and reversals.
DMO Line: The primary line on the indicator plot. It reflects momentum in relation to the dynamic price range. Positive values indicate bullish momentum, while negative values indicate bearish momentum.
Filled Area: The area between the DMO line and the zero line is filled with color to enhance visualization of momentum shifts.
Trading Signals:
Thresholds: Monitor for potential trend reversals when the DMO crosses above the overbought threshold or below the oversold threshold.
Crossovers: Look for buy signals when the DMO line crosses above the zero and sell signals when it crosses below.
Filled Area: The green color indicates bullish momentum, red indicates bearish momentum and gray color indicates neutral conditions.
Signals: Circles appear on the chart when the DMO crosses the overbought or oversold thresholds, indicating conditions for potential trend pullbacks or reversals.
SETTINGS:
Length: Adjust the length parameter to vary the number of periods considered in the momentum calculation.
Smoothing: Enable or disable smoothing of the DMO line using the provided option.
Thresholds: Customize the overbought and oversold threshold levels to suit specific market conditions and trading preferences.
Disclaimer: The DMO indicator serves as part of a comprehensive trading strategy and should not be solely relied upon for trading decisions. Past performance is not indicative of future results, and trading involves inherent risks.
Bollinger and Stochastic with Trailing Stop - D.M.P.This trading strategy combines Bollinger Bands and the Stochastic indicator to identify entry opportunities in oversold and overbought conditions in the market. The aim is to capitalize on price rebounds from the extremes defined by the Bollinger Bands, with the confirmation of the Stochastic to maximize the probability of success of the operations.
Indicators Used
- Bollinger Bands Used to measure volatility and define oversold and overbought levels. When the price touches or breaks through the lower band, it indicates a possible oversold condition. Similarly, when it touches or breaks through the upper band, it indicates a possible overbought condition.
- Stochastic: A momentum oscillator that compares the closing price of an asset with its price range over a certain period. Values below 20 indicate oversold, while values above 80 indicate overbought.
Strategy Logic
- Long Entry (Buy): A purchase operation is executed when the price closes below the lower Bollinger band (indicating oversold) and the Stochastic is also in the oversold zone.
- Short Entry (Sell): A sell operation is executed when the price closes above the upper Bollinger band (indicating overbought) and the Stochastic is in the overbought zone.
Stoch + RSI Oscillator @shrilssThis script combines two powerful indicators, the Stochastic Oscillator and the Relative Strength Index (RSI), to offer traders a comprehensive view of market dynamics.
The Stochastic Oscillator, known for its effectiveness in identifying overbought and oversold conditions, is enhanced here with a smoothing mechanism to provide clearer signals. The script calculates the %K and %D lines of the Stochastic Oscillator, then applies a smoothing factor to %K, resulting in a smoother representation of price momentum.
Simultaneously, the RSI component offers insights into the strength of price movements. By comparing the average gains and losses over a specified period, it provides a measure of bullish and bearish sentiment within the market.
This script's innovation lies in its integration of these two indicators. The Stochastic Oscillator's smoothed %K line and the RSI are compared to dynamic thresholds, enabling traders to identify potential trend reversals and confirmations more effectively. When the RSI crosses above or below the Stochastic %D line, it can signal potential shifts in market momentum.
Stochastic Levels on Chart [MisterMoTA]The values of the Stochastic Levels on Chart indicator are calculated using Reverse Engineering calculations starting from default Stochastic formula : 100 * (close - lowest(low, length)) / (highest(high, length) - lowest(low, length)).
I added options for users to define the Extreme Overbought and Oversold values, also simple Oversold and Overbought values of the stochastic, default Extreme Overbought at 100, Extreme Oversold at 0, the 20 for Oversold and 80 as Overbought, plus the middle stochastic level = 50.
The script has included a color coded 20 SMA that will turn red when the 20 SMA is falling and green when it is rising, also there are bollinger bands using 2 standard deviation plus an extra top and bottom bollinger bands with a 2.5 standard deviation.
The users can use Stochastic Levels on Chart along with a simple Stochastic or a Stochastic Rsi indicator, when the price on chart touching extreme levels and Stochastic or Stochastic Rsi K line crossing above or bellow D line users can see on chart the levels where price need to close for getting stochastic overbought or oversold.
In the demo chart we can see at daily stochastic crossed down and the price crossed down all the levels displayed on chart, and same before stochastic was crossing up from oversold and price crossed up the stochastic levels displayed on chart.
In strong bullish moves the Extreme level 100 of the stochastic will be pushed higher, same in a strong bearish move the Extreme Oversold 0 level will be pushed lower, so users need to wait for confirmation of a crossover between K and D lines of stochastic that will signalize a pullback or a reverse of the trend.
For better results you will need to add a dmi or an adx or other indicator that will show you trend strength.
If you have any questions or suggestions to improve the script please send me a PM.
F.B_Stochastic Trend HarmonizerThe "F.B_Stochastic Trend Harmonizer" has been developed to provide insights into market trends. It combines stochastic oscillations with moving averages. Stochastic oscillators are used to measure market fluctuations, while moving averages serve to smooth these fluctuations and identify trends. By linking these elements, the indicator aims to offer an enhanced representation of market dynamics and potential trend reversals.
You can choose various types of moving averages such as SMA, EMA, or WMA and control the sensitivity of the lines by adjusting the smoothing factors. The fast line displays harmonized stochastic values, while the slow line is smoothed by a moving average.
The "Fast Line 2" marks individual candles for better visibility. It is recommended to combine this indicator with other analysis tools to make trading decisions.
If the "Fast Line" is greater than the "Slow Line MA," it indicates an uptrend. Conversely, if the "Fast Line" is smaller than the "Slow Line MA," it signals a downtrend.
Overbought / Oversold Screener## Introduction
**The Versatile RSI and Stochastic Multi-Symbol Screener**
**Unlock a wealth of trading opportunities with this customizable screener, designed to pinpoint potential overbought and oversold conditions across 17 symbols, with alert support!**
## Description
This screener is suitable for tracking multiple instruments continuously.
With the screener, you can see the instant RSI or Stochastic values of the instruments you are tracking, and easily catch the moments when they are overbought / oversold according to your settings.
The purpose of the screener is to facilitate the continuous tracking of multiple instruments. The user can track up to 17 different instruments in different time intervals. If they wish, they can set an alarm and learn overbought oversold according to the values they set for the time interval of the instruments they are tracking.**
Key Features:
Comprehensive Analysis:
Monitors RSI and Stochastic values for 17 symbols simultaneously.
Automatically includes the current chart's symbol for seamless integration.
Supports multiple timeframes to uncover trends across different time horizons.
Personalized Insights:
Adjust overbought and oversold thresholds to align with your trading strategy.
Sort results by symbol, RSI, or Stochastic values to prioritize your analysis.
Choose between Automatic, Dark, or Light mode for optimal viewing comfort.
Dynamic Visual Cues:
Instantly highlights oversold and overbought symbols based on threshold levels.
Timely Alerts:
Stay informed of potential trading opportunities with alerts for multiple oversold or overbought symbols.
## Settings
### Display
**Timeframe**
The screener displays the values according to the selected timeframe. The default timeframe is "Chart". For example, if the timeframe is set to "15m" here, the screener will show the RSI and stochastic values for the 15-minute chart.
** Theme **
This setting is for changing the theme of the screener. You can set the theme to "Automatic", "Dark", or "Light", with "Automatic" being the default value. When the "Automatic" theme is selected, the screener appearance will also be automatically updated when you enable or disable dark mode from the TradingView settings.
** Position **
This option is for setting the position of the table on the chart. The default setting is "middle right". The available options are (top, middle, bottom)-(left, center, right).
** Sort By **
This option is for changing the sorting order of the table. The default setting is "RSI Descending". The available options are (Symbol, RSI, Stoch)-(Ascending, Descending).
It is important to note that the overbought and oversold coloring of the symbols may also change when the sorting order is changed. If RSI is selected as the sorting order, the symbols will be colored according to the overbought and oversold threshold values specified for RSI. Similarly, if Stoch is selected as the sorting order, the symbols will be colored according to the overbought and oversold threshold values specified for Stoch.
From this perspective, you can also think of the sorting order as a change in the main indicator.
### RSI / Stochastic
This area is for selecting the parameters of the RSI and stochastic indicators. You can adjust the values for "length", "overbought", and "oversold" for both indicators according to your needs. The screener will perform all RSI and stochastic calculations according to these settings. All coloring in the table will also be according to the overbought and oversold values in these settings.
### Symbols
The symbols to be tracked in the table are selected from here. Up to 16 symbols can be selected from here. Since the symbol in the chart is automatically added to the table, there will always be at least 1 symbol in the table. Note that the symbol in the chart is shown in the table with "(C)". For example, if SPX is open in the chart, it is shown as SPX(C) in the table.
## Alerts
The screener is capable of notifying you with an alarm if multiple symbols are overbought or oversold according to the values you specify along with the desired timeframe. This way, you can instantly learn if multiple symbols are overbought or oversold with one alarm, saving you time.
Doda StochasticThe Doda Stochastic Indicator is an oscillator designed to identify primary trends in asset price movements, operating on a scale from 0 to 100. It offers potential buying signals when it fluctuates between 0 and 20, and potential selling signals when it trends between 80 and 100. To reinforce the reliability of these signals, traders often complement them with price action indicators.
The indicator aims to display a modified version of the Stochastic Oscillator, highlighting filtered stochastic values along with related signals.
Traders often use Stochastic indicators to identify potential reversal points or overbought/oversold conditions in the market. The modified version might aim to reduce noise or improve signals compared to the standard Stochastic oscillator. Adjusting the input parameters can alter the sensitivity of the indicator to market movements.
It can also be used to identify trend by considering Doda Stochatic's Moving Average crossing the midline level. If it is above it is uptrend and if below midline then it is downtrend. It does not repaint. It is a lagging indicator because it heavily depends on Moving Averages.
What makes the Doda Stochastic Indicator unique is its attempt to eliminate false or misleading signals commonly found in standard stochastic tools. Instead of relying solely on the 20 and 80 markings for overbought and oversold conditions, it uses the crossing of the green and red lines within these segments to identify signals. However, fully grasping its functionality is pivotal to maximising its utility.
The indicator strategically analyses price movements by scrutinising key price levels, market momentum, and unexpected shifts in trends. By default, it operates with a bar count of 2000 and a PDS value of 13.0, parameters that have undergone extensive testing. It's important to note that tweaking these settings might not always be necessary, as they are well-calibrated.
How to Use the Doda Stochastic Indicator:
Setting up the Indicator:
- Begin incorporating the Doda Stochastic Indicator into your trading strategy once you're confident in identifying significant support and resistance levels.
Strategy with Doda Stochastic:
- Buy Signal Criteria:
- Asset displaying an upward trend.
- Green line crossing above the red line on the indicator.
- Confirm entry with bullish candlestick patterns.
- Set stop loss below the nearest swing low.
- Set take profit at the nearest resistance zone or exit when the green line crosses below the red line.
- Implement risk management with a risk-to-reward ratio of at least 1:2.
- Sell Signal Criteria:
- Asset demonstrating a downtrend.
- Green line crossing below the red line on the indicator.
- Confirm entry with bearish candlestick patterns.
- Set stop loss above the nearest swing high.
- Set take profit at the nearest support zone or exit when the green line crosses above the red line.
- Implement risk management with a risk-to-reward ratio of at least 1:2.
Advantages and Disadvantages:
Pros:
- Analyses crucial price levels, market momentum, and unexpected trend changes.
- Identifies overbought and oversold levels.
Cons:
- Overbought and oversold levels may not always lead to immediate price reversals.
- Signals might occasionally misinterpret a trend reversal as a correction, and vice versa.
The strength of the indicator lies in its intricate approach to price analysis and its effort to minimize false signals. However, traders should exercise caution and consider supplementary confirmation signals for more robust trade decisions.
Stochastic RSI Buy/Sell SignalThis indicator will show you a red circle above candles when Stoch RSI K value is greater than your "overbought" value, and a green circle above candles when Stoch RSI K value is below your "oversold" value. Updatable oversold and overbought values.
[KVA]K Stochastic IndicatorOriginal Stochastic Oscillator Formula:
%K=(C−Lowest Low)/(Highest High−Lowest Low)×100
Lowest Low refers to the lowest low of the past n periods.
Highest High refers to the highest high of the past n periods.
K Stochastic Indicator Formula:
%K=(Source−Lowest Source)/(Highest Source−Lowest Source)×100
Lowest Source refers to the lowest value of the chosen source over the past length periods.
Highest Source refers to the highest value of the chosen source over the past length periods.
Key Difference :
The original formula calculates %K using the absolute highest high and lowest low of the price over the past n periods.
The K Stochastic formula calculates %K using the highest and lowest values of a chosen source (which could be the close, open, high, or low) over the specified length periods.
So, if _src is set to something other than the high for the Highest Source or something other than the low for the Lowest Source, the K Stochastic will yield different results compared to the original formula which strictly uses the highest high and the lowest low of the price.
Impact on Traders :
Flexibility in Price Source :
By allowing the source (_src) to be customizable, traders can apply the Stochastic calculation to different price points (e.g., open, high, low, close, or even an average of these). This could provide a different perspective on market momentum and potentially offer signals that are more aligned with a trader's specific strategy.
Sensitivity to Price Action :
Changing the source from high/low to potentially less extreme values (like close or open) could result in a less volatile oscillator, smoothing out some of the extreme peaks and troughs and possibly offering a more filtered view of market conditions.
Customization of Periods :
The ability to adjust the length period offers traders the opportunity to fine-tune the sensitivity of the indicator to match their trading horizon. Shorter periods may provide earlier signals, while longer periods could filter out market noise.
Possibility of Applying the Indicator on Other Indicators :
Layered Technical Analysis :
The K Stochastic can be applied to other indicators, not just price. For example, it could be applied to a moving average to analyze its momentum or to indicators like RSI or MACD, offering a meta-analysis that studies the oscillator's behavior of other technical tools.
Creation of Composite Indicator s:
By applying the K Stochastic logic to other indicators, traders could create composite indicators that blend the characteristics of multiple indicators, potentially leading to unique signals that could offer an edge in certain market conditions.
Enhanced Signal Interpretation :
When applied to other indicators, the K Stochastic can help in identifying overbought or oversold conditions within those indicators, offering a different dimension to the interpretation of their output.
Overall Implications :
The KStochastic Indicator's modifications could lead to a more tailored application, giving traders the ability to adapt the tool to their specific trading style and analysis preferences.
By being applicable to other indicators, it broadens the scope of stochastic analysis beyond price action, potentially offering innovative ways to interpret data and make trading decisions.
The changes might also influence the trading signals, either by smoothing the oscillator's output to reduce noise or by altering the sensitivity to generate more or fewer signal
Including the additional %F line, which is unique to the K Stochastic Indicator, further expands the potential impacts and applications for traders:
Impact on Traders with the %F Line:
Triple Smoothing :
The %F line introduces a third level of smoothing, which could help in identifying longer-term trends and filtering out short-term fluctuations. This could be particularly useful for traders looking to avoid whipsaws and focus on more sustained movements.
Potential for Enhanced Confirmation :
The %F line might be used as a confirmation signal. For instance, if all three lines (%K, %D, and %F) are in agreement, a trader might consider this as a stronger signal to buy or sell, as opposed to when only the traditional two lines (%K and %D) are used.
Risk Management:
The additional line could be utilized for more sophisticated risk management strategies, where a trader might decide to scale in or out of positions based on the convergence or divergence of these lines.
Possibility of Applying the Indicator on Other Indicators with the %F Line:
Depth of Analysis :
When applied to other indicators, the %F line can provide an even deeper layer of analysis, perhaps identifying macro trends within the indicator it is applied to, which could go unnoticed with just the traditional two-line approach.
Refined Signal Strength Assessment :
The strength of signals from other indicators could be assessed by the position and direction of the %F line, providing an additional filter to evaluate the robustness of buy or sell signals.
Overall Implications with the %F Line :
The inclusion of the %F line in the K Stochastic Indicator enhances its utility as a tool for trend analysis and signal confirmation. It allows traders to potentially identify and act on more reliable trading opportunities.
This feature can enrich the trader's toolkit by providing a nuanced view of momentum and trend strength, which can be particularly valuable in volatile or choppy markets.
For those applying the K Stochastic to other indicators, the %F line could be integral in creating a multi-tiered analysis strategy, potentially leading to more sophisticated interpretations and decisions.
The presence of the %F line adds a dimension of depth to the analysis possible with the K Stochastic Indicator, making it a versatile tool that could be tailored to a variety of trading styles and objectives. However, as with any indicator, the additional complexity requires careful study and back-testing to ensure its signals are understood and actionable within the context of a comprehensive trading plan.
Stochastic StrategyThis strategy is designed to make trading decisions based on the Stochastic Oscillator (Stoch) indicator with settings of (7,2,2). The strategy opens a long (buy) position when the Stoch indicator crosses above the 50 level from below. Conversely, it opens a short (sell) position when the Stoch indicator crosses below the 50 level from above. Additionally, when a long position is opened, any existing short position is closed, and vice versa.
Key Parameters:
Stochastic Oscillator Settings: Length = 7, SmoothK = 2, SmoothD = 2.
Overbought Level: 80.
Oversold Level: 20.
Strategy Description:
The Stochastic Oscillator (Stoch) is calculated based on the closing price, high price, and low price with a period of 7, and both the %K and %D lines are smoothed with periods of 2.
When the %K line crosses above the oversold level (20), it generates a long (buy) signal.
When the %K line crosses below the overbought level (80), it generates a short (sell) signal.
The strategy visually marks long and short signals on the chart using upward and downward triangles, respectively.
The strategy automatically enters long or short positions when the respective conditions are met.
If a long position is opened, any existing short position is closed, and vice versa.
Please note that this is a basic example of a trading strategy and does not take into account all possible risk factors or optimizations. Before using this strategy in live trading, it's essential to thoroughly test and customize it to suit your specific needs, and carefully analyze the results. Trading carries risks, and it's important to use proper risk management techniques when implementing any trading strategy.
MarketSmith Stochasticversion=5
This version of the stochastic produces the identical stochastic as used in MarketSmith
The three primary differences from a classic stochastic are as follows:
1. Close values only
2. 5-day ema instead of 3-day simple moving averages for smoothing the fast and slow lines
3. Slow and fast lines are truncated to integer values
by Mike Scott
2023-09-11
Fib TSIFib TSI = Fibonacci True Strength Index
The Fib TSI indicator uses Fibonacci numbers input for the True Strength Index moving averages. Then it is converted into a stochastic 0-100 scale.
The Fibonacci sequence is the series of numbers where each number is the sum of the two preceding numbers. 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610...
TSI uses moving averages of the underlying momentum of a financial instrument.
Stochastic is calculated by a formula of high and low over a length of time on a scale of 0-100.
How to use Fib TSI:
100 = overbought
0 = oversold
Rising = bullish
Falling = bearish
crossover 50 = bullish
crossunder 50 = bearish
The default input settings are:
2 = Stoch D smoothing
3 = TSI signal
TSI uses 2 moving averages compared with each other.
5 = TSI fastest
TSI uses 2 moving averages compared with each other.
Default value is 3/5.
color = white
8 = TSI fast
TSI uses 2 moving averages compared with each other.
Default value is 5/8.
color = blue
13 = TSI mid
TSI uses 2 moving averages compared with each other.
Default value is 8/13.
color = orange
21 = TSI slow
TSI uses 2 moving averages compared with each other.
Default value is 13/21.
color = purple
34 = TSI slowest
TSI uses 2 moving averages compared with each other.
Default value is 21/34.
color = yellow
55 = Stoch K length
All total / 5 = All TSI
color rising above 50 = bright green
color falling above 50 = mint green
color falling below 50 = bright red
color rising below 50 = pink
Up bullish reversal = green arrow up
bullish trend = green dots
Down bearish reversal = red arrow down
bearish trend = red dots
Horizontal lines:
100
75
50
25
0
2 different visual options example snapshot:
MACDVMACDV = Moving Average Convergence Divergence Volume
The MACDV indicator uses stochastic accumulation / distribution volume inflow and outflow formulas to visualize it in a standard MACD type of appearance.
To be able to merge these formulas I had to normalize the math.
Accumulation / distribution volume is a unique scale.
Stochastic is a 0-100 scale.
MACD is a unique scale.
The normalized output scale range for MACDV is -100 to 100.
100 = overbought
-100 = oversold
Everything in between is either bullish or bearish.
Rising = bullish
Falling = bearish
crossover = bullish
crossunder = bearish
convergence = direction change
divergence = momentum
The default input settings are:
7 = K length, Stochastic accumulation / distribution length
3 = D smoothing, smoothing stochastic accumulation / distribution volume weighted moving average
6 = MACDV fast, MACDV fast length line
color = blue
13 = MACDV slow, MACDV slow length line
color = white
4 = MACDV signal, MACDV histogram length
color rising above 0 = bright green
color falling above 0 = dark green
color falling below 0 = bright red
color rising below 0 = dark red
2 = Stretch, Output multiplier for MACDV visual expansion
Horizontal lines:
100
75
50
25
0
-25
-50
-75
-100
Multiple Ticker Stochastic RSIThe Stochastic RSI is a technical indicator ranging between 0 and 100, based on applying the Stochastic oscillator formula to a set of relative strength index (RSI). Unlike the original Stochastic RSI indicator, this allows you to define up to two additional tickers for which all three will be averaged and outputted visually looking like a standard Stochastic RSI indicator. Potential buy and sell visuals are included, as well as alerts. Please note that this indicator is not meant to be used by itself.
Velocity Indicator [CC]The Velocity Indicator was created by Scott Cong (Stocks and Commodities Sep 2023, pgs 8-15). This is my variation of his formula designed to capture the overall velocity of the underlying stock by applying the typical velocity formula. This indicator is visually similar to a typical stochastic indicator but uses a different underlying calculation. This works well as a momentum indicator, and the values are completely unbounded, so the best ways to determine bullish or bearish trends is either by using a crossover or crossunder between the indicator and the midline or to buy or sell the indicator when it reaches a high or low point and starts to fall or rise respectively. For my default version, I used the zero line to help determine the bullish or bearish trends. I have also included multiple colors to differentiate between very strong signals and normal signals, so very strong signals are darker in color, and normal signals use lighter colors. Buy when the line turns green and sell when it turns red.
Let me know if there are any other indicators or scripts you would like to see me publish! I will have some more new scripts in the next week or so.
Price Exhaustion IndicatorThe Price Exhaustion Indicator (PE) is a powerful tool designed to identify trends weakening and strengthening in the financial markets. It combines the concepts of Average True Range (ATR), Moving Average Convergence Divergence (MACD), and Stochastic Oscillator to provide a comprehensive assessment of trend exhaustion levels. By analyzing these multiple indicators together, traders and investors can gain valuable insights into potential price reversals and long-term market highs and lows.
The aim of combining the ATR, MACD, and Stochastic Oscillator, is to provide a comprehensive analysis of trend exhaustion. The ATR component helps assess the volatility and range of price movements, while the MACD offers insights into the convergence and divergence of moving averages. The Stochastic Oscillator measures the current price in relation to its range, providing further confirmation of trend exhaustion. The exhaustion value is derived by combining the MACD, ATR, and Stochastic Oscillator. The MACD value is divided by the ATR value, and then multiplied by the Stochastic Oscillator value. This calculation results in a single exhaustion value that reflects the combined influence of these three indicators.
Application
The Price Exhaustion Indicator utilizes a unique visual representation by incorporating a gradient color scheme. The exhaustion line dynamically changes color, ranging from white when close to the midline (40) to shades of purple as it approaches points of exhaustion (overbought at 100 and oversold at -20). As the exhaustion line approaches the color purple, this represents extreme market conditions and zones of weakened trends where reversals may occur. This color gradient serves as a visual cue, allowing users to quickly gauge the strength or weakness of the prevailing trend.
To further enhance its usability, the Price Exhaustion Indicator also includes circle plots that signify potential points of trend reversion. These plots appear when the exhaustion lines cross or enter the overbought and oversold zones. Red circle plots indicate potential short entry points, suggesting a weakening trend and the possibility of a downward price reversal. Conversely, green circle plots represent potential long entry points, indicating a strengthening trend and the potential for an upward price reversal.
Traders and investors can leverage the Price Exhaustion Indicator in various ways. It can be utilized as a trend-following tool, or a mean reversion tool. When the exhaustion line approaches the overbought or oversold zones, it suggests a weakening trend and the possibility of a price reversal, helping identify potential market tops and bottoms. This can guide traders in timing their entries or exits in anticipation of a trend shift.
Utility
The Price Exhaustion Indicator is particularly useful for long-term market analysis, as it focuses on identifying long-term market highs and lows. By capturing the gradual weakening or strengthening of a trend, it assists investors in making informed decisions about portfolio allocation, trend continuation, or potential reversals.
In summary, the Price Exhaustion Indicator is a comprehensive and visually intuitive tool that combines ATR, MACD, and Stochastic Oscillator to identify trend exhaustion levels. By utilizing a gradient color scheme and circle plots, it offers traders and investors valuable insights into potential trend reversals and long-term market highs and lows. Its unique features make it a valuable addition to any trader's toolkit, providing a deeper understanding of market dynamics and assisting in decision-making processes. Please note that future performance of any trading strategy is fundamentally unknowable, and past results do not guarantee future performance.
Kalman Filtered ROC & Stochastic with MA SmoothingThe "Smooth ROC & Stochastic with Kalman Filter" indicator is a trend following tool designed to identify trends in the price movement. It combines the Rate of Change (ROC) and Stochastic indicators into a single oscillator, the combination of ROC and Stochastic indicators aims to offer complementary information: ROC measures the speed of price change, while Stochastic identifies overbought and oversold conditions, allowing for a more robust assessment of market trends and potential reversals. The indicator plots green "B" labels to indicate buy signals and blue "S" labels to represent sell signals. Additionally, it displays a white line that reflects the overall trend for buy signals and a blue line for sell signals. The aim of the indicator is to incorporate Kalman and Moving Average (MA) smoothing techniques to reduce noise and enhance the clarity of the signals.
Rationale for using Kalman Filter:
The Kalman Filter is chosen as a smoothing tool in the indicator because it effectively reduces noise and fluctuations. The Kalman Filter is a mathematical algorithm used for estimating and predicting the state of a system based on noisy and incomplete measurements. It combines information from previous states and current measurements to generate an optimal estimate of the true state, while simultaneously minimizing the effects of noise and uncertainty. In the context of the indicator, the Kalman Filter is applied to smooth the input data, which is the source for the Rate of Change (ROC) calculation. By considering the previous smoothed state and the difference between the current measurement and the predicted value, the Kalman Filter dynamically adjusts its estimation to reduce the impact of outliers.
Calculation:
The indicator utilizes a combination of the ROC and the Stochastic indicator. The ROC is smoothed using a Kalman Filter (credit to © Loxx: ), which helps eliminate unwanted fluctuations and improve the signal quality. The Stochastic indicator is calculated with customizable parameters for %K length, %K smoothing, and %D smoothing. The smoothed ROC and Stochastic values are then averaged using the formula ((roc + d) / 2) to create the blended oscillator. MA smoothing is applied to the combined oscillator aiming to further reduce fluctuations and enhance trend visibility. Traders are free to choose their own preferred MA type from 'EMA', 'DEMA', 'TEMA', 'WMA', 'VWMA', 'SMA', 'SMMA', 'HMA', 'LSMA', and 'PEMA' (credit to: © traderharikrishna for this code: ).
Application:
The indicator's buy signals (represented by green "B" labels) indicate potential entry points for buying assets, suggesting a bullish trend. The white line visually represents the trend, helping traders identify and follow the upward momentum. Conversely, the sell signals (blue "S" labels) highlight possible exit points or opportunities for short selling, indicating a bearish trend. The blue line illustrates the bearish movement, aiding in the identification of downward momentum.
The "Smoothed ROC & Stochastic" indicator offers traders a comprehensive view of market trends by combining two powerful oscillators. By incorporating the ROC and Stochastic indicators into a single oscillator, it provides a more holistic perspective on the market's momentum. The use of a Kalman Filter for smoothing helps reduce noise and enhance the accuracy of the signals. Additionally, the indicator allows customization of the smoothing technique through various moving average types. Traders can also utilize the overbought and oversold zones for additional analysis, providing insights into potential market reversals or extreme price conditions. Please note that future performance of any trading strategy is fundamentally unknowable, and past results do not guarantee future performance.
RSI with J-Line ***For ease of use, I recommend changing the J Histogram to a line indicator, then it works like the KDJ Stochastic indicator. Full disclosure, I created this script with the help of GPT. This script was inspired by the KDJ Stochastic indicator by Dreadblitz***
The "RSI with J-Line" script is essentially a modified Relative Strength Index (RSI) indicator with an added histogram component. Here's how to use the different components of the script:
RSI Line (Blue): The RSI is a momentum oscillator that measures the speed and change of price movements. It oscillates between zero and 100, and is typically used to identify overbought and oversold conditions in a market. Traditionally, readings over 70 are considered overbought, and readings under 30 are considered oversold. However, these are not strict rules and can vary depending on the market and the overall trend.
RSI Smooth Line (Orange): This is the simple moving average of the RSI. It helps to smooth out the RSI and to identify the overall trend of the momentum. When the RSI line crosses above the RSI Smooth line, it might indicate that the momentum is moving upwards. When the RSI line crosses below the RSI Smooth line, it might indicate that the momentum is moving downwards.
RSI J-Line (Red Histogram): The J-Line is an additional line that's calculated as 3*rsiSmooth - 2*rsi. It's similar to the %J line in the Stochastic indicator and is designed to provide quicker signals than the RSI or RSI Smooth line. When the histogram is above the 0 line, it might indicate bullish momentum. When it's below the 0 line, it might indicate bearish momentum.
Please note that these interpretations are standard for these types of indicators, but actual market behavior can be complex and is influenced by many factors. Indicators should be used as part of a comprehensive trading strategy, not in isolation. Always take into account other market information and indicators before making trading decisions.
Stochastic Distance Indicator [CC]The Stochastic Distance Indicator was created by Vitali Apirine (Stocks and Commodities Jun 2023 pgs 16-21), and this is a new method that measures the absolute distance between a price and its highest and lowest values over a long period. It uses the stochastic formula to create an oscillator using this distance value and smooths the value. Obviously, there is a lag in signals due to the lookback periods, but it does a good job of staying above the midline when the stock is in a strong uptrend and vice versa. Of course, I'm open to suggestions, but I'm deciding to create buy and sell signals based on comparing the unsmoothed and smoothed values. Buy when the line turns green and sell when it turns red.
Let me know if there are any other indicators you would like to see me publish!
RSI, SRSI, MACD and DMI cross - Open source codeHello,
I'm a passionate trader who has spent years studying technical analysis and exploring different trading strategies. Through my research, I've come to realize that certain indicators are essential tools for conducting accurate market analysis and identifying profitable trading opportunities. In particular, I've found that the RSI, SRSI, MACD cross, and Di cross indicators are crucial for my trading success.
Detailed explanation:
The RSI is a momentum indicator that measures the strength of price movements. It is calculated by comparing the average of gains and losses over a certain period of time. In this indicator, the RSI is calculated based on the close price with a length of 14 periods.
The Stochastic RSI is a combination of the Stochastic Oscillator and the RSI. It is used to identify overbought and oversold conditions of the market. In this indicator, the Stochastic RSI is calculated based on the RSI with a length of 14 periods.
The MACD is a trend-following momentum indicator that shows the relationship between two moving averages of prices. It consists of two lines, the MACD line and the signal line, which are used to generate buy and sell signals. In this indicator, the MACD is calculated based on the close price with fast and slow lengths of 12 and 26 periods, respectively, and a signal length of 9 periods.
The DMI is a trend-following indicator that measures the strength of directional movement in the market. It consists of three lines, the Positive Directional Indicator (+DI), the Negative Directional Indicator (-DI), and the Average Directional Index (ADX), which are used to generate buy and sell signals. In this indicator, the DMI is calculated with a length of 14 periods and an ADX smoothing of 14 periods.
The indicator generates buy signals when certain conditions are met for each of these indicators.
1) For the RSI, a buy signal is generated when the RSI is below or equal to 35 and the Stochastic RSI %K is below or equal to 15, or when the RSI is below or equal to 28 the Stochastic RSI %K is below or equal to 15 or when the RSI is below or equal to 25 and the Stochastic RSI %K is below or equal to 10 or when the RSI is below or equal to 28.
2) For the MACD, a buy signal is generated when the MACD line is below 0, there is a change in the histogram from negative to positive, the MACD line and histogram are negative in the previous period, and the current histogram value is greater than 0.
3) For the DMI, a buy signal is generated when the Positive Directional Indicator (+DI) crosses above the Negative Directional Indicator (-DI), and the -DI is less than the +DI.
The indicator generates sell signals when certain conditions are met for each of these indicators:
1) For the RSI, a sell signal is generated when the RSI is above or equal to 75 and the Stochastic RSI %K is above or equal to 85, or when the RSI is above or equal to 80 and the Stochastic RSI %K is above or equal to 85, or when the RSI is above or equal to 85 and the Stochastic RSI %K is above or equal to 90 or when the RSI is above or equal to 82.
2)For the MACD, a sell signal is generated when the MACD line is above 0, there is a change in the histogram from positive to negative, the MACD line and histogram are positive in the previous period, and the current histogram value is less than the previous histogram value. On the other hand, a buy signal is generated when the MACD line is below 0, there is a change in the histogram from negative to positive, the MACD line and histogram are negative in the previous period, and the current histogram value is greater than the previous histogram value.
3)For the DMI a bearish signal is generated when plusDI crosses above minusDI, indicating that bulls are losing strength and bears are taking control.
The indicator uses a combination of these four indicators to generate potential buy and sell signals. The buy signals are generated when RSI and SRSI values are in oversold conditions, while sell signals are generated when RSI and SRSI values are in overbought conditions. The indicator also uses MACD crossovers and DMI crossovers to generate additional buy and sell signals.
When a signal is strong?
The use of multiple signals within a specific timeframe can increase the accuracy and reliability of the signals generated by this indicator. It is recommended to look for at least two signals within a range of 5-8 candles in order to increase the probability of a successful trade.
Why it's original?
1) There is no indicator in the library that combine all of these indicators and give you a 360 view
2)The combination of the RSI, Stochastic RSI, MACD, and DMI indicators in a single script it's unique and not available in the libray.
3)The specific parameters and conditions used to calculate the signals may be unique and not found in other scripts or libraries.
4)The use of plotshape() to plot the signals as shapes on the chart may be unique compared to other scripts that simply plot lines or bars to indicate signals.
5)The use of alertcondition() to trigger alerts based on the signals may be unique compared to other scripts that do not have custom alert functionality.
Keep attention!
It is important to note that no trading indicator or strategy is foolproof, and there is always a risk of losses in trading. While this indicator may provide useful information for making conclusions, it should not be used as the sole basis for making trading decisions. Traders should always use proper risk management techniques and consider multiple factors when making trading decisions.
Support me:)
If you find this new indicator helpful in your trading analysis, I would greatly appreciate your support! Please consider giving it a like, leaving feedback, or sharing it with your trading network. Your engagement will not only help me improve this tool but will also help other traders discover it and benefit from its features. Thank you for your support!
TASC 2023.06 Stochastic Distance Oscillator█ OVERVIEW
This script implements the stochastic distance oscillator (SDO) , a momentum indicator introduced by Vitali Apirine in an article featured in TASC's June 2023 edition of Traders' Tips . The SDO is a variation of the classic stochastic oscillator and is designed to identify overbought and oversold levels, as well as detect bull and bear trend changes.
█ CONCEPTS
Unlike the classic stochastic oscillator, which compares an asset's price to its past price range, the SDO measures the size of the current distance relative to the maximum-minimum distance range over a set number of periods. The current distance is defined as the distance between the current price and the price n periods ago.
The readings of the SDO can be used to identify the following states of the asset price:
Uptrend state: the oscillator crosses over 50 from a non-uptrend state.
Downtrend state: the oscillator crosses under -50 from a non-downtrend state.
Overbought state: the oscillator is in an uptrend and crosses -50 for the first time.
Oversold state: the oscillator is in a downtrend and crosses 50 for the first time.
Trend continuity: the oscillator crosses 0 in the direction of the current trend.
The script indicates these five conditions using on-chart signals and background coloring.
█ CALCULATIONS
The SDO is calculated as follows:
1. Calculate the distance between the current price and the price n periods ago, as well as the maximum and minimum distances for the selected lookback period. The author recommends using one of two values of n , 14 or 40 bars.
2. Calculate the time series % D that represents the relation between the asset's current distance and its distance range over a loockback period:
% D = (Abs(current distance) − Abs(minimum distance)) / (Abs(maximum distance) − Abs(minimum distance)) * 100
3. Use the calculated % D to obtain the SDO:
If the closing price is above the close n periods ago, SDO = % D
If the closing price is below the close n periods ago, SDO = −% D
If the closing price equals the close n periods ago or the current distance equals the minimum distance, SDO = 0
4. Smooth the SDO using an exponential moving average (EMA). The author recommends using an EMA in the range from 3 to 6 .
Adjustable input parameters include the number of periods n , the lookback period for calculating % D , the smoothing EMA length, and the overbought/oversold threshold level.