OPEN-SOURCE SCRIPT

VWAP + RSI + MACD Strategy + Risk Management

132
// TradingView Pine Script for VWAP + RSI + MACD Strategy with Risk Management
//version=5
indicator("VWAP + RSI + MACD Strategy + Risk Management", overlay=true)

// VWAP Calculation
vwap_value = ta.vwap
plot(vwap_value, title="VWAP", color=color.blue, linewidth=2)

// RSI Calculation
rsi_length = 14
rsi_value = ta.rsi(close, rsi_length)
plot(rsi_value, title="RSI", color=color.purple, linewidth=2)

// MACD Calculation
[macdLine, signalLine, _] = ta.macd(close, 12, 26, 9)
macdBullish = ta.crossover(macdLine, signalLine)
macdBearish = ta.crossunder(macdLine, signalLine)

// Entry Conditions
bullish_signal = ta.crossover(close, vwap_value) and rsi_value > 50 and macdBullish
bearish_signal = ta.crossunder(close, vwap_value) and rsi_value < 50 and macdBearish

// Stop-Loss Conditions (Risk Management)
stop_loss_long = close < vwap_value // Exit long if price drops below VWAP
stop_loss_short = close > vwap_value // Exit short if price rises above VWAP

// Alerts for Buy/Sell Signals
alertcondition(bullish_signal, title="Bullish Entry", message="Price above VWAP, RSI > 50, MACD Bullish")
alertcondition(bearish_signal, title="Bearish Entry", message="Price below VWAP, RSI < 50, MACD Bearish")
alertcondition(stop_loss_long, title="Exit Long", message="Price dropped below VWAP - Consider exiting long position")
alertcondition(stop_loss_short, title="Exit Short", message="Price rose above VWAP - Consider exiting short position")

// Background Highlighting
bgcolor(bullish_signal ? color.green : bearish_signal ? color.red : na, transp=85)

إخلاء المسؤولية

لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.