I want a strategy pine script is high Sharpe ratio and uncommon
- User
I want a strategy pine script is high Sharpe ratio and uncommon
- Assistant
I want a strategy pine script is high Sharpe ratio and uncommon
Creating a high Sharpe ratio and uncommon trading strategy in Pine Script involves combining multiple indicators and filters to optimize risk-adjusted returns. Below is an example of such a strategy that leverages the Volume-Weighted Average Price (VWAP), Relative Strength Index (RSI) with dynamic thresholds, and Bollinger Bands for volatility filtering. This combination is less commonly used together, potentially providing an edge.
//@version=5
strategy("Uncommon High Sharpe Strategy", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=5, initial_capital=10000, currency=currency.USD)
// === Parameters ===
vwap_length = input.int(14, title="VWAP Length", minval=1)
rsi_length = input.int(14, title="RSI Length", minval=1)
bb_length = input.int(20, title="Bollinger Bands Length", minval=1)
bb_mult = input.float(2.0, title="Bollinger Bands Multiplier", step=0.1)
stop_loss_pct = input.float(1.5, title="Stop Loss (%)", step=0.1)
take_profit_pct = input.float(3.0, title="Take Profit (%)", step=0.1)
// === VWAP Calculation ===
vwap = ta.vwap(hlc3)
// === RSI Calculation with Dynamic thresholds ===
rsi = ta.rsi(close, rsi_length)
rsi_upper = 70 + ta.change(rsi_length) * 0.5 // Dynamic upper threshold
rsi_lower = 30 - ta.change(rsi_length) * 0.5 // Dynamic lower threshold
// === Bollinger Bands Calculation ===
basis = ta.sma(close, bb_length)
dev = bb_mult * ta.stdev(close, bb_length)
upper_bb = basis + dev
lower_bb = basis - dev
// === Plotting ===
plot(vwap, color=color.orange, title="VWAP")
plot(upper_bb, color=color.blue, title="Upper BB")
plot(lower_bb, color=color.blue, title="Lower BB")
hline(70, "RSI Overbought", color=color.red, linestyle=hline.style_dashed)
hline(30, "RSI Oversold", color=color.green, linestyle=hline.style_dashed)
// === Trend Filter ===
is_uptrend = close > vwap
is_downtrend = close < vwap
// === Entry Conditions ===
// Long Entry: Uptrend, RSI oversold, price near lower Bollinger Band
long_condition = is_uptrend and rsi < rsi_lower and close <= lower_bb
if (long_condition)
strategy.entry("Long", strategy.long)
// Short Entry: Downtrend, RSI overbought, price near upper Bollinger Band
short_condition = is_downtrend and rsi > rsi_upper and close >= upper_bb
if (short_condition)
strategy.entry("Short", strategy.short)
// === Exit Conditions ===
// Define Stop Loss and Take Profit levels
long_stop = strategy.position_avg_price * (1 - stop_loss_pct / 100)
long_take = strategy.position_avg_price * (1 + take_profit_pct / 100)
short_stop = strategy.position_avg_price * (1 + stop_loss_pct / 100)
short_take = strategy.position_avg_price * (1 - take_profit_pct / 100)
if (strategy.position_size > 0)
strategy.exit("Take Profit/Stop Loss Long", "Long", stop=long_stop, limit=long_take)
if (strategy.position_size < 0)
strategy.exit("Take Profit/Stop Loss Short", "Short", stop=short_stop, limit=short_take)
// === Optional: Volatility Filter ===
// Only take trades when Bollinger Bands width is above the median to ensure sufficient volatility
bb_width = upper_bb - lower_bb
median_bb_width = ta.median(bb_width, bb_length)
volatility_filter = bb_width > median_bb_width
// Apply Volatility Filter to Entries
if (long_condition and volatility_filter)
strategy.entry("Long", strategy.long)
if (short_condition and volatility_filter)
strategy.entry("Short", strategy.short)
// === Plot RSI for Visualization ===
plot(rsi, title="RSI", color=color.purple)
VWAP Trend Filter:
RSI with Dynamic Thresholds:
Bollinger Bands Volatility Filter:
Risk Management:
While this strategy is designed to be uncommon and target a high Sharpe ratio by combining trend, momentum, and volatility indicators, no strategy guarantees success. It's essential to perform comprehensive testing and continuously monitor performance to adapt to changing market conditions.
Feel free to modify and enhance the strategy to better suit your trading style and objectives!
Not yet included in a published release.