Multi-Divergence Buy/Sell Indicator For ThinkOrSwim

ALV

Member
VIP
The author states:
The "Multi-Divergence Buy/Sell Indicator" is a technical analysis tool that combines multiple divergence signals from different indicators to identify potential buy and sell opportunities in the market. Here's a breakdown of how the indicator works and how to use it:

Input Parameters:
RSI Length: Specifies the length of the RSI (Relative Strength Index) calculation.
MACD Short Length: Specifies the short-term length for the MACD (Moving Average Convergence Divergence) calculation.
MACD Long Length: Specifies the long-term length for the MACD calculation.
MACD Signal Smoothing: Specifies the smoothing length for the MACD signal line calculation.
Stochastic Length: Specifies the length of the Stochastic oscillator calculation.
Stochastic Overbought Level: Defines the overbought level for the Stochastic oscillator.
Stochastic Oversold Level: Defines the oversold level for the Stochastic oscillator.

Calculation of Indicators:
RSI: Calculates the RSI based on the specified RSI Length.
MACD: Calculates the MACD line, signal line, and histogram based on the specified MACD parameters.
Stochastic: Calculates the Stochastic oscillator based on the specified Stochastic parameters.

Divergence Detection:
RSI Divergence: Identifies a bullish divergence when the RSI crosses above its 14-period simple moving average (SMA).
MACD Divergence: Identifies a bullish divergence when the MACD line crosses above the signal line.
Stochastic Divergence: Identifies a bullish divergence when the Stochastic crosses above its 14-period SMA.

Buy and Sell Conditions:
Buy Condition: Triggers a buy signal when all three divergences (RSI, MACD, and Stochastic) occur simultaneously.
Sell Condition: Triggers a sell signal when both RSI and MACD divergences occur, but Stochastic divergence does not occur.

Plotting Buy/Sell Signals:
The indicator plots green "Buy" labels below the price bars when the buy condition is met.
It plots red "Sell" labels above the price bars when the sell condition is met.

Usage:

The indicator can be used on any timeframe and for any trading instrument.
Look for areas where all three divergences (RSI, MACD, and Stochastic) align to generate stronger buy and sell signals.
Consider additional technical analysis and risk management strategies to validate the signals and manage your trades effectively.
O8d1LZu.png



Hi coders!
Can anyone convert this Multi-Divergence Buy/Sell TradingView Indicator into a TOS indicator? Here is the link to the author's indicator: https://www.tradingview.com/script/7wVZvOkC-Multi-Divergence-Buy-Sell-Indicator/ . It is an open-source code and I take no credit for this author's indicator and any usage of author's code is strictly for personal use.

@samer800
Hi Samer. Big fan of your work here. Do you think it is possible you can evaluate this script and convert if possible?
Thanks!!
 
Last edited by a moderator:
Hi coders!
Can anyone convert this Multi-Divergence Buy/Sell TradingView Indicator into a TOS indicator? Here is the link to the author's indicator: https://www.tradingview.com/script/7wVZvOkC-Multi-Divergence-Buy-Sell-Indicator/ . It is an open-source code and I take no credit for this author's indicator and any usage of author's code is strictly for personal use.


The "Multi-Divergence Buy/Sell Indicator" is a technical analysis tool that combines multiple divergence signals from different indicators to identify potential buy and sell opportunities in the market. Here's a breakdown of how the indicator works and how to use it:

Input Parameters:
RSI Length: Specifies the length of the RSI (Relative Strength Index) calculation.
MACD Short Length: Specifies the short-term length for the MACD (Moving Average Convergence Divergence) calculation.
MACD Long Length: Specifies the long-term length for the MACD calculation.
MACD Signal Smoothing: Specifies the smoothing length for the MACD signal line calculation.
Stochastic Length: Specifies the length of the Stochastic oscillator calculation.
Stochastic Overbought Level: Defines the overbought level for the Stochastic oscillator.
Stochastic Oversold Level: Defines the oversold level for the Stochastic oscillator.

Calculation of Indicators:
RSI: Calculates the RSI based on the specified RSI Length.
MACD: Calculates the MACD line, signal line, and histogram based on the specified MACD parameters.
Stochastic: Calculates the Stochastic oscillator based on the specified Stochastic parameters.

Divergence Detection:
RSI Divergence: Identifies a bullish divergence when the RSI crosses above its 14-period simple moving average (SMA).
MACD Divergence: Identifies a bullish divergence when the MACD line crosses above the signal line.
Stochastic Divergence: Identifies a bullish divergence when the Stochastic crosses above its 14-period SMA.

Buy and Sell Conditions:
Buy Condition: Triggers a buy signal when all three divergences (RSI, MACD, and Stochastic) occur simultaneously.
Sell Condition: Triggers a sell signal when both RSI and MACD divergences occur, but Stochastic divergence does not occur.

Plotting Buy/Sell Signals:
The indicator plots green "Buy" labels below the price bars when the buy condition is met.
It plots red "Sell" labels above the price bars when the sell condition is met.

Usage:

The indicator can be used on any timeframe and for any trading instrument.
Look for areas where all three divergences (RSI, MACD, and Stochastic) align to generate stronger buy and sell signals.
Consider additional technical analysis and risk management strategies to validate the signals and manage your trades effectively.

Remember, no indicator guarantees profitable trades, so it's essential to use this indicator in conjunction with other tools and perform thorough analysis before making trading decisions. Author - brutaltraderyt



Code:
//@version=5
indicator("Multi-Divergence Buy/Sell Indicator", overlay=true)

// Input parameters
rsiLength = input(14, "RSI Length")
macdShortLength = input(12, "MACD Short Length")
macdLongLength = input(26, "MACD Long Length")
macdSignalSmoothing = input(9, "MACD Signal Smoothing")
stochLength = input(14, "Stochastic Length")
stochOverbought = input(80, "Stochastic Overbought Level")
stochOversold = input(20, "Stochastic Oversold Level")

// Calculate RSI
rsi = ta.rsi(close, rsiLength)

// Calculate MACD
[macdLine, signalLine, _] = ta.macd(close, macdShortLength, macdLongLength, macdSignalSmoothing)

// Calculate Stochastic
stoch = ta.stoch(close, high, low, stochLength)

// Determine divergences
rsiDivergence = ta.crossover(rsi, ta.sma(rsi, 14))
macdDivergence = ta.crossover(macdLine, signalLine)
stochDivergence = ta.crossover(stoch, ta.sma(stoch, 14))

// Determine buy/sell conditions
buyCondition = rsiDivergence and macdDivergence and stochDivergence
sellCondition = rsiDivergence and macdDivergence and not stochDivergence

// Plotting buy/sell signals
plotshape(buyCondition, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="Buy")
plotshape(sellCondition, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="Sell")
check the below:

CSS:
# https://www.tradingview.com/v/7wVZvOkC/
#//@brutaltraderyt
#strategy("Multi-Divergence Buy/Sell Indicator", overlay=true)
# Converted by Sam4Cok@Samer800    - 03/2024
#// Input parameters
input source = close;
input rsiLength = 14;#, "RSI Length")
input macdShortLength = 12;#, "MACD Short Length")
input macdLongLength = 26;#, "MACD Long Length")
input macdSignalSmoothing = 9;#, "MACD Signal Smoothing")
input stochLength = 14;#, "Stochastic Length")
input smoothingLength = 14;
input stochOverbought = 80;#, "Stochastic Overbought Level")
input stochOversold = 20;#, "Stochastic Oversold Level")

def na = Double.NaN;

# stoch(source, high, low, length) =>
script stoch {
input len = 14;
input src = close;
input h = high;
input l = low;
    def hh = highest(h, len);
    def ll = lowest(l, len);
    def stoch = 100 * (src - ll) / (hh - ll);
    plot return = stoch;
}
#// Calculate RSI
def rsi = RSI(Price = source, Length = rsiLength);
def avgRsi = Average(rsi, smoothingLength);
#// Calculate MACD
def fastMA = ExpAverage(source, macdShortLength);
def slowMA = ExpAverage(source, macdLongLength);
def macd = fastMA - slowMA;
def signal = ExpAverage(macd, macdSignalSmoothing);

def macdLine = macd;
def signalLine = signal;

#// Calculate Stochastic
def stoch = stoch(stochLength);
def avgStoch = Average(stoch, smoothingLength);
#// Determine divergences
def rsiDivergence = Crosses(rsi, avgRsi, CrossingDirection.ABOVE);
def macdDivergence = Crosses(macdLine, signalLine, CrossingDirection.ABOVE);
def stochDivergence = Crosses(stoch, avgStoch, CrossingDirection.ABOVE);

#// Determine buy/sell conditions

def buyCondition = rsiDivergence and macdDivergence and stochDivergence;
def sellCondition = rsiDivergence and macdDivergence and !stochDivergence;

AddChartBubble(buyCondition, low, "BUY", Color.GREEN, no);
AddChartBubble(sellCondition, high, "SELL", Color.RED);

#-- END of Code
 
check the below:

CSS:
# https://www.tradingview.com/v/7wVZvOkC/
#//@brutaltraderyt
#strategy("Multi-Divergence Buy/Sell Indicator", overlay=true)
# Converted by Sam4Cok@Samer800    - 03/2024
#// Input parameters
input source = close;
input rsiLength = 14;#, "RSI Length")
input macdShortLength = 12;#, "MACD Short Length")
input macdLongLength = 26;#, "MACD Long Length")
input macdSignalSmoothing = 9;#, "MACD Signal Smoothing")
input stochLength = 14;#, "Stochastic Length")
input smoothingLength = 14;
input stochOverbought = 80;#, "Stochastic Overbought Level")
input stochOversold = 20;#, "Stochastic Oversold Level")

def na = Double.NaN;

# stoch(source, high, low, length) =>
script stoch {
input len = 14;
input src = close;
input h = high;
input l = low;
    def hh = highest(h, len);
    def ll = lowest(l, len);
    def stoch = 100 * (src - ll) / (hh - ll);
    plot return = stoch;
}
#// Calculate RSI
def rsi = RSI(Price = source, Length = rsiLength);
def avgRsi = Average(rsi, smoothingLength);
#// Calculate MACD
def fastMA = ExpAverage(source, macdShortLength);
def slowMA = ExpAverage(source, macdLongLength);
def macd = fastMA - slowMA;
def signal = ExpAverage(macd, macdSignalSmoothing);

def macdLine = macd;
def signalLine = signal;

#// Calculate Stochastic
def stoch = stoch(stochLength);
def avgStoch = Average(stoch, smoothingLength);
#// Determine divergences
def rsiDivergence = Crosses(rsi, avgRsi, CrossingDirection.ABOVE);
def macdDivergence = Crosses(macdLine, signalLine, CrossingDirection.ABOVE);
def stochDivergence = Crosses(stoch, avgStoch, CrossingDirection.ABOVE);

#// Determine buy/sell conditions

def buyCondition = rsiDivergence and macdDivergence and stochDivergence;
def sellCondition = rsiDivergence and macdDivergence and !stochDivergence;

AddChartBubble(buyCondition, low, "BUY", Color.GREEN, no);
AddChartBubble(sellCondition, high, "SELL", Color.RED);

#-- END of Code

@samer800 - Thank you so much for the wonderful work you do for all the community.
Regards.
 
Ive tried running this as both a strategy and a study on my chart and in both cases, absolutely nothing shows up? Any thoughts on what the issue may be?
 
Ive tried running this as both a strategy and a study on my chart and in both cases, absolutely nothing shows up? Any thoughts on what the issue may be?
@DB01
It happened to me too. The TV author indicated that you may need to adjust the settings. I tried different settings for the MACD to obtain signals. Actually using 8, 21, 15. See white and red bubbles.
For me it is like additional information to Price Action, ADX level and cumulative delta volume.

Hope this help.

PpMmkAU.png
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
358 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top