Deepseek

Deepseek

//@version=5
indicator("Advanced Trading Tool with Zones", overlay=true)

// Inputs
rsiLength = input(14, title="RSI Length")
maShortLength = input(50, title="Short MA Length")
maLongLength = input(200, title="Long MA Length")
bbLength = input(20, title="Bollinger Bands Length")
bbStdDev = input(2, title="Bollinger Bands Std Dev")
atrLength = input(14, title="ATR Length")
overbought = input(70, title="Overbought Level")
oversold = input(30, title="Oversold Level")
zoneLookback = input(50, title="Supply/Demand Zone Lookback")

// Indicators
rsi = ta.rsi(close, rsiLength)
maShort = ta.sma(close, maShortLength)
maLong = ta.sma(close, maLongLength)
= ta.macd(close, 12, 26, 9)
bbUpper = ta.sma(close, bbLength) + ta.stdev(close, bbLength) * bbStdDev
bbLower = ta.sma(close, bbLength) - ta.stdev(close, bbLength) * bbStdDev
atr = ta.atr(atrLength)
obv = ta.obv(close, volume)

// Trend Conditions
uptrend = close > maShort and maShort > maLong
downtrend = close < maShort and maShort < maLong

// Buy/Sell Conditions
buyCondition = uptrend and rsi < oversold and hist > 0 and close < bbLower and obv > obv
sellCondition = downtrend and rsi > overbought and hist < 0 and close > bbUpper and obv < obv

// Plot Buy/Sell Signals
plotshape(series=buyCondition, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY", size=size.small)
plotshape(series=sellCondition, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL", size=size.small)

// Supply/Demand Zones
var float demandZones = array.new_float()
var float supplyZones = array.new_float()

if buyCondition
array.push(demandZones, low)
if sellCondition
array.push(supplyZones, high)

for i = 0 to array.size(demandZones) - 1
zonePrice = array.get(demandZones, i)
line.new(x1=bar_index - zoneLookback, y1=zonePrice, x2=bar_index, y2=zonePrice, color=color.new(color.blue, 50), width=2, style=line.style_dashed)

for i = 0 to array.size(supplyZones) - 1
zonePrice = array.get(supplyZones, i)
line.new(x1=bar_index - zoneLookback, y1=zonePrice, x2=bar_index, y2=zonePrice, color=color.new(color.red, 50), width=2, style=line.style_dashed)

// Support/Resistance Levels
supportLevel = ta.lowest(low, zoneLookback)
resistanceLevel = ta.highest(high, zoneLookback)

line.new(x1=bar_index - zoneLookback, y1=supportLevel, x2=bar_index, y2=supportLevel, color=color.new(color.green, 50), width=2, style=line.style_solid)
line.new(x1=bar_index - zoneLookback, y1=resistanceLevel, x2=bar_index, y2=resistanceLevel, color=color.new(color.orange, 50), width=2, style=line.style_solid)

// Risk-Reward Zones
if buyCondition
stopLoss = low - atr * 1.5
takeProfit = close + atr * 3
line.new(x1=bar_index, y1=stopLoss, x2=bar_index, y2=takeProfit, color=color.new(color.teal, 50), width=2, style=line.style_dotted)

if sellCondition
stopLoss = high + atr * 1.5
takeProfit = close - atr * 3
line.new(x1=bar_index, y1=stopLoss, x2=bar_index, y2=takeProfit, color=color.new(color.teal, 50), width=2, style=line.style_dotted)

Read More

Share:

Latest News