Pine Script Supply and Demand Indicator Tradingview
A Supply and Demand indicator in Pine Script generally highlights key areas on a chart where price reversals or consolidations occur due to supply (resistance) and demand (support) zones. Here's a basic version of a Supply and Demand indicator using Pine Script.
//@version=5
indicator("Supply and Demand Zones", overlay=true)
// Input settings for lookback periods
lookback_high = input.int(10, title="Lookback Period for Highs")
lookback_low = input.int(10, title="Lookback Period for Lows")
zone_width = input.int(3, title="Zone Width")
// Detecting supply (resistance) zones
var float supply_zone_high = na
var float supply_zone_low = na
if ta.highestbars(high, lookback_high) == 0
supply_zone_high := high
supply_zone_low := high - zone_width * syminfo.mintick
// Detecting demand (support) zones
var float demand_zone_low = na
var float demand_zone_high = na
if ta.lowestbars(low, lookback_low) == 0
demand_zone_low := low
demand_zone_high := low + zone_width * syminfo.mintick
// Plotting the supply zone
hline(supply_zone_high, "Supply Zone High", color=color.red, linewidth=2)
hline(supply_zone_low, "Supply Zone Low", color=color.red, linewidth=1, linestyle=hline.style_dotted)
box.new(left=bar_index[lookback_high], top=supply_zone_high, right=bar_index, bottom=supply_zone_low, bgcolor=color.new(color.red, 90), border_color=color.red)
// Plotting the demand zone
hline(demand_zone_low, "Demand Zone Low", color=color.green, linewidth=2)
hline(demand_zone_high, "Demand Zone High", color=color.green, linewidth=1, linestyle=hline.style_dotted)
box.new(left=bar_index[lookback_low], top=demand_zone_high, right=bar_index, bottom=demand_zone_low, bgcolor=color.new(color.green, 90), border_color=color.green)
Recommended by LinkedIn
Explanation:
You can adjust the lookback period and zone width to fit your trading strategy. Would you like to add additional features or modify this script?