OPEN-SOURCE SCRIPT

Combined Strategy (VSA + RSI and Moving Average)

//version=6
strategy("Combined Strategy (VSA + RSI and Moving Average)", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=10)

// إعدادات مؤشر القوة النسبية (RSI)
rsiPeriod = input.int(14, title="RSI Period")
rsiOverbought = input.int(70, title="RSI Overbought Level")
rsiOversold = input.int(30, title="RSI Oversold Level")
rsi = ta.rsi(close, rsiPeriod)

// إعدادات المتوسط المتحرك
maPeriod = input.int(50, title="MA Period")
ma = ta.sma(close, maPeriod)

// إعدادات الربح المستهدف (Take Profit) وإيقاف الخسارة (Stop Loss)
takeProfitPct = input.float(2.0, title="Take Profit (%)") / 100
stopLossPct = input.float(1.0, title="Stop Loss (%)") / 100

// شروط استراتيجية VSA
sot_down = (math.abs(close - close[1]) < ((ta.sma(high - close, 5)) * 0.1)) and (volume > ta.sma(volume, 10)) and
(ta.mom(close, 3) > 0 or ta.mom(close, 4) > 0 or ta.mom(close, 5) > 0 or ta.mom(close, 6) > 0) ? 1 : 0

sot_up = (math.abs(close - close[1]) < ((ta.sma(high - close, 5)) * 0.1)) and (volume > ta.sma(volume, 10)) and
(ta.mom(close, 3) < 0 or ta.mom(close, 4) < 0 or ta.mom(close, 5) < 0 or ta.mom(close, 6) < 0) ? 1 : 0

// حساب مستوى الربح المستهدف وإيقاف الخسارة
longTakeProfit = close * (1 + takeProfitPct)
longStopLoss = close * (1 - stopLossPct)

shortTakeProfit = close * (1 - takeProfitPct)
shortStopLoss = close * (1 + stopLossPct)

// شروط الدخول والخروج
longCondition = (ta.crossover(rsi, rsiOversold) and close > ma and sot_up == 1)
shortCondition = (ta.crossunder(rsi, rsiOverbought) and close < ma and sot_down == 1)

// تنفيذ الصفقات مع تحديد Take Profit و Stop Loss
if longCondition
strategy.entry("Long", strategy.long, stop=longStopLoss, limit=longTakeProfit)

if shortCondition
strategy.entry("Short", strategy.short, stop=shortStopLoss, limit=shortTakeProfit)

// رسم الإشارات على الرسم البياني
plot(rsi, color=color.blue, title="RSI")
hline(rsiOverbought, "Overbought", color=color.red)
hline(rsiOversold, "Oversold", color=color.green)

plot(ma, color=color.orange, title="Moving Average")

// رسم إشارات SOT (مؤشر VSA)
plotshape(sot_down, style=shape.triangledown, color=color.red, size=size.auto)
plotshape(sot_up, style=shape.triangleup, color=color.green, size=size.auto, location=location.belowbar)
plotchar(sot_down, text="SOT", char="", color=color.red)
plotchar(sot_up, text="SA", char="", color=color.green, location=location.belowbar)
Bands and Channels

Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in publication is governed by House rules. You can favorite it to use it on a chart.

Want to use this script on a chart?

Disclaimer