Enhanced Combined Indicator: Supply and Demand + Bollinger Bands
This Enhanced Combined Indicator integratesSupply and Demand, Bollinger Bands, and Exponential Moving Averages (EMAs) to help traders identify key entry and exit points. It includes advanced risk management features, such as customizable stop-loss and take-profit levels, and allows for real-time alerts via email, SMS, or Telegram. The script also offers visual indicators for trends, breakouts, and trading signals, empowering traders to make informed decisions

Example chart using the Enhanced Combined Indicator
Key Features
- Combined Indicators: Merges Supply and Demand, Bollinger Bands, and EMAs for comprehensive analysis.
- Risk Management: Customizable stop-loss types (Swing/ATR) and risk-reward ratio for take-profit.
- Pattern Detection: Identifies bullish patterns based on candle health and price movement.
- Trend Confirmation: Uses EMAs to confirm trends for entry/exit signals.
- Breakout Signals: Detects potential breakouts via Bollinger Bands.
- Alerts: Real-time notifications via email, SMS, or Telegram.
- Dynamic Stop-Loss/Take-Profit: Adjustable based on market conditions.
- Visual Indicators: Plots EMAs, support/resistance, and key trading signals.
Additional Features and Strategies
This Pine Script combines multiple technical indicators and strategies into a single script, offering a powerful tool for identifying entry and exit points for trading. Here's a breakdown of its features:
- Alert Options: Users can select alert types like Email, SMS, or Telegram for notifications on entry points.
- Risk Management: Allows users to set a risk percentage per trade and choose between "Swing" or "ATR" based stop-loss types. The user can also select a risk-reward ratio for take-profit calculations.
- Supply and Demand: The script identifies a bullish pattern using candle health and price movement criteria, marking potential entry points when a strong pattern is detected.
- Exponential Moving Averages (EMA): The script tracks three EMAs (9, 21, and 50 periods) for trend identification. A bullish entry is valid if the price is above the EMAs, and vice versa for a bearish entry.
- Bollinger Bands: The upper and lower Bollinger Bands are used to signal potential breakouts. A crossover of the price above the upper band indicates a potential buy signal, and a crossunder below the lower band indicates a potential sell signal.
- ATR-Based Stop-Loss: Uses Average True Range (ATR) to calculate dynamic stop-loss levels based on market volatility.
- Visuals: The script displays key elements like EMAs, support/resistance lines, Bollinger Bands, and labels indicating entry points (Buy/Sell).
- Alerts & Notifications: Alerts are triggered based on crossing the Bollinger Bands and detecting bullish patterns, providing real-time notifications.
Key Conditions
- Bullish Entry: The script detects a bullish pattern with EMA alignment (price above EMAs) and candle health above a certain threshold.
- Bearish Entry: A bearish pattern occurs when the price is below the EMAs and conditions for the bearish candle are met.
- Stop-Loss and Take-Profit: Stop-loss is set based on either the lowest (for buys) or highest (for sells) prices over a lookback period or using ATR. Take-profit is based on a user-defined risk-to-reward ratio.
Plotting
- EMAs: Three EMAs (9, 21, 50) are plotted in different colors for easy tracking of trends.
- Support and Resistance: Horizontal lines plot key support and resistance levels over a specified lookback period.
- Bollinger Bands: Upper and lower Bollinger Bands are plotted, with potential breakout signals marked with triangle shapes above and below bars.
This strategy aims to capture profitable breakouts using Bollinger Bands, while also employing risk management through stop-loss and take-profit levels.
Indicator Code
//@version=5
indicator("Enhanced Combined Indicator: Supply and Demand + Bollinger Bands", overlay=true, max_lines_count=500, max_boxes_count=500)
// Indicator Parameters
alertOptions = input.string(title="Alert Options", defval="Email", options=["Email", "SMS", "Telegram"])
riskPerTrade = input.float(title="Risk per Trade (%)", defval=1.5, minval=0.1, maxval=10)
stopLossType = input.string(title="Type of Stop-loss", defval="Swing", options=["Swing", "ATR"])
takeProfitType = input.string(title="Type of Take-profit", defval="R:R", options=["R:R", "Multiple Target"])
riskRewardRatio = input.float(title="Risk-Reward Ratio", defval=2.0, minval=1.0)
// Supply and Demand Parameters
bodyHealthTip = "Ensure at least one candle with 60% health during the first rise/drop phase."
baseRetracementTip = "Limit base retracement below 80%."
bodyHealthInput = input.int(60, title="Candle Health %", minval=1, maxval=100, tooltip=bodyHealthTip)
baseRetracement = input.float(0.80, title="Base Max Retracement", minval=0.1, maxval=1, tooltip=baseRetracementTip)
// EMA Parameters
ema1_length = input.int(9, title="EMA 1 Length")
ema2_length = input.int(21, title="EMA 2 Length")
ema3_length = input.int(50, title="EMA 3 Length")
lookback = input.int(20, title="Lookback Period")
// Bollinger Bands Parameters
bb_length = input.int(20, minval=1, title="BB Length")
bb_mult = input.float(2.0, minval=0.001, title="BB Mult")
// Calculations
ema1 = ta.ema(close, ema1_length)
ema2 = ta.ema(close, ema2_length)
ema3 = ta.ema(close, ema3_length)
support = ta.lowest(low, lookback)
resistance = ta.highest(high, lookback)
basis = ta.sma(close, bb_length)
dev = bb_mult * ta.stdev(close, bb_length)
upper = basis + dev
lower = basis - dev
// ATR Calculation for Stop-loss
atr_length = input.int(14, title="ATR Length")
atr_value = ta.atr(atr_length)
// Supply and Demand Logic
bullCandle = close > open
bearCandle = close < open
a = high - low
b = close > open ? close - open : open - close
bodyHealth = ((a - b) / a) * 100
// Tracking Bullish Pattern
var int bullPass = na
if bullCandle and close > high[1] and bodyHealth >= bodyHealthInput
bullPass := 1
else if bullPass == 1 and bearCandle and close < open
bullPass := 2
else if bullPass == 2 and bullCandle and close > open
bullPass := 3
// Bollinger Bands Logic
bb_up_cross = ta.crossover(close, upper)
bb_down_cross = ta.crossunder(close, lower)
// Entry Conditions
bullishEntry = bullPass == 3 and close > ema1 and ema1 > ema2 and ema2 > ema3
bearishEntry = bullPass == 3 and close < ema1 and ema1 < ema2 and ema2 < ema3
// Stop-Loss Calculation
var float stopLoss = na
if bullishEntry
stopLoss := stopLossType == "Swing" ? ta.lowest(low, lookback) : close - atr_value
else if bearishEntry
stopLoss := stopLossType == "Swing" ? ta.highest(high, lookback) : close + atr_value
// Take-Profit Calculation
var float takeProfit = na
if bullishEntry and stopLoss
takeProfit := stopLoss + (close - stopLoss) * riskRewardRatio
else if bearishEntry and stopLoss
takeProfit := stopLoss - (stopLoss - close) * riskRewardRatio
// Strategy Execution
if bullishEntry
label.new(bar_index, close, "Buy", color=color.green, textcolor=color.white, size=size.small)
line.new(bar_index[1], stopLoss, bar_index, close, color=color.red, width=2, extend=extend.none) // Plot Stop-loss Line
line.new(bar_index[1], takeProfit, bar_index, close, color=color.green, width=2, extend=extend.none) // Plot Take-profit Line
alert("Bullish Entry: Buy at " + str.tostring(close) + ", Stop-loss at " + str.tostring(stopLoss) + ", Take-profit at " + str.tostring(takeProfit), alert.freq_once_per_bar)
if bearishEntry
label.new(bar_index, close, "Sell", color=color.red, textcolor=color.white, size=size.small)
line.new(bar_index[1], stopLoss, bar_index, close, color=color.red, width=2, extend=extend.none) // Plot Stop-loss Line
line.new(bar_index[1], takeProfit, bar_index, close, color=color.green, width=2, extend=extend.none) // Plot Take-profit Line
alert("Bearish Entry: Sell at " + str.tostring(close) + ", Stop-loss at " + str.tostring(stopLoss) + ", Take-profit at " + str.tostring(takeProfit), alert.freq_once_per_bar)
// Plotting
plot(ema1, title="EMA 1", color=color.blue)
plot(ema2, title="EMA 2", color=color.red)
plot(ema3, title="EMA 3", color=color.orange)
plot(support, title="Support", color=color.green, linewidth=2)
plot(resistance, title="Resistance", color=color.red, linewidth=2)
plot(upper, color=color.gray)
plot(lower, color=color.gray)
// Plot Breakouts
plotshape(bb_up_cross, style=shape.triangleup, location=location.belowbar, color=color.green, size=size.small)
plotshape(bb_down_cross, style=shape.triangledown, location=location.abovebar, color=color.red, size=size.small)
// Alerts
alertcondition(bb_up_cross, title="BB Upper Band Cross", message="BB Upper Band Cross")
alertcondition(bb_down_cross, title="BB Lower Band Cross", message="BB Lower Band Cross")
alertcondition(bullPass == 3, title="Bullish Pattern Detected", message="Bullish Pattern Detected")
How to Use
Follow these steps to use the indicator:
- Click the "Copy Code" button above to copy the script to your clipboard.
- Open TradingView and navigate to the Pine Script editor.
- Paste the code into the editor and click "Add to Chart".
- Customize the inputs to match your trading strategy.