Divergence Strategy [Trendoscope®]🎲 Overview
The Divergence Strategy is a sophisticated TradingView strategy that enhances the Divergence Screener by adding automated trade signal generation, risk management, and trade visualization. It leverages the screener’s robust divergence detection to identify bullish, bearish, regular, and hidden divergences, then executes trades with precise entry, stop-loss, and take-profit levels. Designed for traders seeking automated trading solutions, this strategy offers customizable trade parameters and visual feedback to optimize performance across various markets and timeframes.
For core divergence detection features, including oscillator options, trend detection methods, zigzag pivot analysis, and visualization, refer to the Divergence Screener documentation. This description focuses on the strategy-specific enhancements for automated trading and risk management.
🎲 Strategy Features
🎯Automated Trade Signal Generation
Trade Direction Control : Restrict trades to long-only or short-only to align with market bias or strategy goals, preventing conflicting orders.
Divergence Type Selection : Choose to trade regular divergences (bullish/bearish), hidden divergences, or both, targeting reversals or trend continuations.
Entry Type Options :
Cautious : Enters conservatively at pivot points and exits quickly to minimize risk exposure.
Confident : Enters aggressively at the latest price and holds longer to capture larger moves.
Mixed : Combines conservative entries with delayed exits for a balanced approach.
Market vs. Stop Orders: Opt for market orders for instant execution or stop orders for precise price entry.
🎯 Enhanced Risk Management
Risk/Reward Ratio : Define a risk-reward ratio (default: 2.0) to set profit targets relative to stop-loss levels, ensuring consistent trade sizing.
Bracket Orders : Trades include entry, stop-loss, and take-profit levels calculated from divergence pivot points, tailored to the entry type and risk-reward settings.
Stop-Loss Placement : Stops are strategically set (e.g., at recent pivot or last price point) based on entry type, balancing risk and trade validity.
Order Cancellation : Optionally cancel pending orders when a divergence is broken (e.g., price moves past the pivot in the wrong direction), reducing invalid trades. This feature is toggleable for flexibility.
🎯 Trade Visualization
Target and Stop Boxes : Displays take-profit (lime) and stop-loss (orange) levels as boxes on the price chart, extending 10 bars forward for clear visibility.
Dynamic Trade Updates : Trade visualizations are added, updated, or removed as trades are executed, canceled, or invalidated, ensuring accurate feedback.
Overlay Integration : Trade levels overlay the price chart, complementing the screener’s oscillator-based divergence lines and labels.
🎯 Strategy Default Configuration
Capital and Sizing : Set initial capital (default: $1,000,000) and position size (default: 20% of equity) for realistic backtesting.
Pyramiding : Allows up to 4 concurrent trades, enabling multiple divergence-based entries in trending markets.
Commission and Margin : Accounts for commission (default: 0.01%) and margin (100% for long/short) to reflect trading costs.
Performance Optimization : Processes up to 5,000 bars dynamically, balancing historical analysis and real-time execution.
🎲 Inputs and Configuration
🎯Trade Settings
Direction : Select Long or Short (default: Long).
Divergence : Trade Regular, Hidden, or Both divergence types (default: Both).
Entry/Exit Type : Choose Cautious, Confident, or Mixed (default: Cautious).
Risk/Reward : Set the risk-reward ratio for profit targets (default: 2.0).
Use Market Order : Enable market orders for immediate entry (default: false, uses limit orders).
Cancel On Break : Cancel pending orders when divergence is broken (default: true).
🎯Inherited Settings
The strategy inherits all inputs from the Divergence Screener, including:
Oscillator Settings : Oscillator type (e.g., RSI, CCI), length, and external oscillator option.
Trend Settings : Trend detection method (Zigzag, MA Difference, External), MA type, and length.
Zigzag Settings : Zigzag length (fixed repaint = true).
🎲 Entry/Exit Types for Divergence Scenarios
The Divergence Strategy offers three Entry/Exit Type options—Cautious, Confident, and Mixed—which determine how trades are entered and exited based on divergence pivot points. This section explains how these settings apply to different divergence scenarios, with placeholders for screenshots to illustrate each case.
The divergence pattern forms after 3 pivots. The stop and entry levels are formed on one of these levels based on Entry/Exit types.
🎯Bullish Divergence (Reversal)
A bullish divergence occurs when price forms a lower low, but the oscillator forms a higher low, signaling a potential upward reversal.
💎 Cautious:
Entry : At the pivot high point for a conservative entry.
Exit : Stop-loss at the last pivot point (previous low that is higher than the current pivot low); take-profit at risk-reward ratio. Canceled if price breaks below the pivot (if Cancel On Break is enabled).
Behavior : Enters after confirmation and exits quickly to limit downside risk.
💎Confident:
Entry : At the last pivot low, (previous low which is higher than the current pivot low) for an aggressive entry.
Exit : Stop-loss at recent pivot low, which is the lowest point; take-profit at risk-reward ratio. Canceled if price breaks below the pivot. (lazy exit)
Behavior : Enters early to capture trend continuation, holding longer for gains.
💎Mixed:
Entry : At the pivot high point (conservative).
Exit : Stop-loss at the recent pivot point that has resulted in lower low (lazy exit). Canceled if price breaks below the pivot.
Behavior : Balances entry caution with extended holding for trend continuation.
🎯Bearish Divergence (Reversal)
A bearish divergence occurs when price forms a higher high, but the oscillator forms a lower high, indicating a potential downward reversal.
💎Cautious:
Entry : At the pivot low point (lower high) for a conservative short entry.
Exit : Stop-loss at the previous pivot high point (previous high); take-profit at risk-reward ratio. Canceled if price breaks above the pivot (if Cancel On Break is enabled).
Behavior : Enters conservatively and exits quickly to minimize risk.
💎Confident:
Entry : At the last price point (previous high) for an aggressive short entry.
Exit : Stop-loss at the pivot point; take-profit at risk-reward ratio. Canceled if price breaks above the pivot.
Behavior : Enters early to maximize trend continuation, holding longer.
💎Mixed:
Entry : At the previous piot high point (conservative).
Exit : Stop-loss at the last price point (delayed exit). Canceled if price breaks above the pivot.
Behavior : Combines conservative entry with extended holding for downtrend gains.
🎯Bullish Hidden Divergence (Continuation)
A bullish hidden divergence occurs when price forms a higher low, but the oscillator forms a lower low, suggesting uptrend continuation. In case of Hidden bullish divergence, b]Entry is always on the previous pivot high (unless it is a market order)
💎Cautious:
Exit : Stop-loss at the recent pivot low point (higher than previous pivot low); take-profit at risk-reward ratio. Canceled if price breaks below the pivot (if Cancel On Break is enabled).
Behavior : Enters after confirmation and exits quickly to limit downside risk.
💎Confident:
Exit : Stop-loss at previous pivot low, which is the lowest point; take-profit at risk-reward ratio. Canceled if price breaks below the pivot. (lazy exit)
Behavior : Enters early to capture trend continuation, holding longer for gains.
🎯Bearish Hidden Divergence (Continuation)
A bearish hidden divergence occurs when price forms a lower high, but the oscillator forms a higher high, suggesting downtrend continuation. In case of Hidden Bearish divergence, b]Entry is always on the previous pivot low (unless it is a market order)
💎Cautious:
Exit : Stop-loss at the latest pivot high point (which is a lower high); take-profit at risk-reward ratio. Canceled if price breaks above the pivot (if Cancel On Break is enabled).
Behavior : Enters conservatively and exits quickly to minimize risk.
💎Confident/Mixed:
Exit : Stop-loss at the previous pivot high point; take-profit at risk-reward ratio. Canceled if price breaks above the pivot.
Behavior : Uses the late exit point to hold longer.
🎲 Usage Instructions
🎯Add to Chart:
Add the Divergence Strategy to your TradingView chart.
The oscillator and divergence signals appear in a separate pane, with trade levels (target/stop boxes) overlaid on the price chart.
🎯Configure Settings:
Adjust trade settings (direction, divergence type, entry type, risk-reward, market orders, cancel on break).
Modify inherited Divergence Screener settings (oscillator, trend method, zigzag length) as needed.
Enable/disable alerts for divergence notifications.
🎯Interpret Signals:
Long Trades: Triggered on bullish or bullish hidden divergences (if allowed), shown with green/lime lines and labels.
Short Trades: Triggered on bearish or bearish hidden divergences (if allowed), shown with red/orange lines and labels.
Monitor lime (target) and orange (stop) boxes for trade levels.
Review strategy performance metrics (e.g., profit/loss, win rate) in the strategy tester.
🎯Backtest and Optimize:
Use TradingView’s strategy tester to evaluate performance on historical data.
Fine-tune risk-reward, entry type, position sizing, and cancellation settings to suit your market and timeframe.
For questions, suggestions, or support, contact Trendoscope via TradingView or official support channels. Stay tuned for updates and enhancements to the Divergence Strategy!
Divergencetrading
Divergence IQ [TradingIQ]Hello Traders!
Introducing "Divergence IQ"
Divergence IQ lets traders identify divergences between price action and almost ANY TradingView technical indicator. This tool is designed to help you spot potential trend reversals and continuation patterns with a range of configurable features.
Features
Divergence Detection
Detects both regular and hidden divergences for bullish and bearish setups by comparing price movements with changes in the indicator.
Offers two detection methods: one based on classic pivot point analysis and another that provides immediate divergence signals.
Option to use closing prices for divergence detection, allowing you to choose the data that best fits your strategy.
Normalization Options:
Includes multiple normalization techniques such as robust scaling, rolling Z-score, rolling min-max, or no normalization at all.
Adjustable normalization window lets you customize the indicator to suit various market conditions.
Option to display the normalized indicator on the chart for clearer visual comparison.
Allows traders to take indicators that aren't oscillators, and convert them into an oscillator - allowing for better divergence detection.
Simulated Trade Management:
Integrates simulated trade entries and exits based on divergence signals to demonstrate potential trading outcomes.
Customizable exit strategies with options for ATR-based or percentage-based stop loss and profit target settings.
Automatically calculates key trade metrics such as profit percentage, win rate, profit factor, and total trade count.
Visual Enhancements and On-Chart Displays:
Color-coded signals differentiate between bullish, bearish, hidden bullish, and hidden bearish divergence setups.
On-chart labels, lines, and gradient flow visualizations clearly mark divergence signals, entry points, and exit levels.
Configurable settings let you choose whether to display divergence signals on the price chart or in a separate pane.
Performance Metrics Table:
A performance table dynamically displays important statistics like profit, win rate, profit factor, and number of trades.
This feature offers an at-a-glance assessment of how the divergence-based strategy is performing.
The image above shows Divergence IQ successfully identifying and trading a bullish divergence between an indicator and price action!
The image above shows Divergence IQ successfully identifying and trading a bearish divergence between an indicator and price action!
The image above shows Divergence IQ successfully identifying and trading a hidden bullish divergence between an indicator and price action!
The image above shows Divergence IQ successfully identifying and trading a hidden bearish divergence between an indicator and price action!
The performance table is designed to provide a clear summary of simulated trade results based on divergence setups. You can easily review key metrics to assess the strategy’s effectiveness over different time periods.
Customization and Adaptability
Divergence IQ offers a wide range of configurable settings to tailor the indicator to your personal trading approach. You can adjust the lookback and lookahead periods for pivot detection, select your preferred method for normalization, and modify trade exit parameters to manage risk according to your strategy. The tool’s clear visual elements and comprehensive performance metrics make it a useful addition to your technical analysis toolbox.
The image above shows Divergence IQ identifying divergences between price action and OBV with no normalization technique applied.
While traders can look for divergences between OBV and price, OBV doesn't naturally behave like an oscillator, with no definable upper and lower threshold, OBV can infinitely increase or decrease.
With Divergence IQ's ability to normalize any indicator, traders can normalize non-oscillator technical indicators such as OBV, CVD, MACD, or even a moving average.
In the image above, the "Robust Scaling" normalization technique is selected. Consequently, the output of OBV has changed and is now behaving similar to an oscillator-like technical indicator. This makes spotting divergences between the indicator and price easier and more appropriate.
The three normalization techniques included will change the indicator's final output to be more compatible with divergence detection.
This feature can be used with almost any technical indicator.
Stop Type
Traders can select between ATR based profit targets and stop losses, or percentage based profit targets and stop losses.
The image above shows options for the feature.
Divergence Detection Method
A natural pitfall of divergence trading is that it generally takes several bars to "confirm" a divergence. This makes trading the divergence complicated, because the entry at time of the divergence might look great; however, the divergence wasn't actually signaled until several bars later.
To circumvent this issue, Divergence IQ offers two divergence detection mechanisms.
Pivot Detection
Pivot detection mode is the same as almost every divergence indicator on TradingView. The Pivots High Low indicator is used to detect market/indicator highs and lows and, consequently, divergences.
This method generally finds the "best looking" divergences, but will always take additional time to confirm the divergence.
Immediate Detection
Immediate detection mode attempts to reduce lag between the divergence and its confirmation to as little as possible while avoiding repainting.
Immediate detection mode still uses the Pivots Detection model to find the first high/low of a divergence. However, the most recent high/low does not utilize the Pivot Detection model, and instead immediately looks for a divergence between price and an indicator.
Immediate Detection Mode will always signal a divergence one bar after it's occurred, and traders can set alerts in this mode to be alerted as soon as the divergence occurs.
TradingView Backtester Integration
Divergence IQ is fully compatible with the TradingView backtester!
Divergence IQ isn’t designed to be a “profitable strategy” for users to trade. Instead, the intention of including the backtester is to let users backtest divergence-based trading strategies between the asset on their chart and almost any technical indicator, and to see if divergences have any predictive utility in that market.
So while the backtester is available in Divergence IQ, it’s for users to personally figure out if they should consider a divergence an actionable insight, and not a solicitation that Divergence IQ is a profitable trading strategy. Divergence IQ should be thought of as a Divergence backtesting toolkit, not a full-feature trading strategy.
Strategy Properties Used For Backtest
Initial Capital: $1000 - a realistic amount of starting capital that will resonate with many traders
Amount Per Trade: 5% of equity - a realistic amount of capital to invest relative to portfolio size
Commission: 0.02% - a conservative amount of commission to pay for trade that is standard in crypto trading, and very high for other markets.
Slippage: 1 tick - appropriate for liquid markets, but must be increased in markets with low activity.
Once more, the backtester is meant for traders to personally figure out if divergences are actionable trading signals on the market they wish to trade with the indicator they wish to use.
And that's all!
If you have any cool features you think can benefit Divergence IQ - please feel free to share them!
Thank you so much TradingView community!
Bullish Divergence Short-term Long Trade FinderThis script is a Bullish divergence trade finder built to find small periods where Bitcoin will likely rise from. It looks for bullish divergence followed by a higher low as long as the hour RSI value is below the 40 mark, if then it will enter an long. It marks out Buy signals on the RSI if the value dips below 'RSI Bull Condition Minimum' (Default 40) on the current time frame in view. It also marks out Sell signals found when the RSI is above the 'RSI Bearish Condition Minimum' (Default 50). The sell signals are bearish divergence that has occurred recently on the RSI. When a long is in play it will sell if it finds bearish divergence or the time frame in view reaches RSI value higher than the 'RSI Sell Value'(Default 75). You can set your stop loss value with the 'Stop loss Percentage' (default 5).
Available inputs:
RSI Period: relative strength measurement length(Typically 14)
RSI Oversold Level: the bottom bar of the RSI (Typically 30)
RSI Overbought Level: the top bar of the RSI (Typically 70)
RSI Bearish Condition Minimum: The minimum value the script will use to look for a pivot high that starts the Bearish condition to Sell (Default 50)
RSI Bearish Condition Sell Min: the minimum value the script will accept a bearish condition (Default 60)
RSI Bull Condition Minimum: the minimum value it will consider a pivot low value in the RSI to find a divergence buy (Default 40)
Look Back this many candles: the amount of candles thee script will look back to find a low value in the RSI (Default 25)
RSI Sell Value: The RSI value of the exit condition for a long when value is reached (Default 75)
Stop loss Percentage: Percentage value for amount to lose (Default 5)
The formula to enter a long is stated below:
If price finds a lower low and there is a higher low found following a lower low and price has just made another dip and price closes lower than the last divergence and Relative strength index hour value is less than 40 enter a long.
The formula to exit a long is stated below:
If the value drops below the stop loss percentage OR (the RSI value is greater than the value of the parameter 'RSI Sell Value' or bearish divergence is found greater than the parameter 'RSI Bearish Condition Minimum' )
This script was built from much strategy testing on BTC but works with alts (occasionally) also. It is most successful to my knowledge using the 15 min and 7 min time frames with default values. Hope it helps! Follow for further possible updates to this script or other entry or exit strategies.
snapshot:
I only have a Pro trading view account so I cannot share a larger data set about this script because the buy signals happen pretty rarely. The most amount that I could find within a view for me was 40 trades within a viewable time. The suggested/default parameters that I have do not occur very often so it limits the data set. Adjustments can be made to the parameters so that trades can be entered more often. The scripts success is dependent on the values of the parameters set by the user. This script was written to be used for BTC/USD or BTC/USDT trading. I am unable to share a larger dataset without putting out results that are intended to fail or having a premium account so reaching the 100 trade minimum is not possible with my account.