OPEN-SOURCE SCRIPT

High-Leverage Futures Trading Strategy

//version=5
indicator("High-Leverage Futures Trading Strategy", shorttitle="HL Futures", overlay=true)

// Input Parameters
risk_per_trade = input.float(5, title="Risk per Trade (%)", minval=1, maxval=100)
atr_multiplier = input.float(1.5, title="ATR Stop-Loss Multiplier", minval=0.1, maxval=5)
ema_fast_length = input.int(50, title="Fast EMA Length", minval=1)
ema_slow_length = input.int(200, title="Slow EMA Length", minval=1)
rsi_length = input.int(14, title="RSI Length", minval=1)
macd_fast = input.int(12, title="MACD Fast Length", minval=1)
macd_slow = input.int(26, title="MACD Slow Length", minval=1)
macd_signal = input.int(9, title="MACD Signal Length", minval=1)

// Force 4-Hour Timeframe
is_4h = (timeframe.period == "240")
if not is_4h
label.new(bar_index, high, "Use 4H timeframe", color=color.red, textcolor=color.white, style=label.style_label_down)

// Moving Averages
ema_fast = ta.ema(close, ema_fast_length)
ema_slow = ta.ema(close, ema_slow_length)

// Trend Identification
long_condition = close > ema_fast and ema_fast > ema_slow
short_condition = close < ema_fast and ema_fast < ema_slow

// RSI
rsi = ta.rsi(close, rsi_length)
rsi_long = rsi < 30
rsi_short = rsi > 70

// MACD
[macd_line, signal_line, _] = ta.macd(close, macd_fast, macd_slow, macd_signal)
macd_long = ta.crossover(macd_line, signal_line)
macd_short = ta.crossunder(macd_line, signal_line)

// ATR for Stop-Loss
atr = ta.atr(14)
stop_loss_long = close - atr * atr_multiplier
stop_loss_short = close + atr * atr_multiplier

// Volume Confirmation
volume_spike = volume > ta.sma(volume, 20) * 1.5

// Entry Signals
entry_long = long_condition and macd_long and rsi_long and volume_spike
entry_short = short_condition and macd_short and rsi_short and volume_spike

// Plot EMAs
plot(ema_fast, color=color.blue, title="50 EMA")
plot(ema_slow, color=color.red, title="200 EMA")

// Plot Buy and Sell Signals
plotshape(entry_long, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.labelup, size=size.small)
plotshape(entry_short, title="Sell Short Signal", location=location.abovebar, color=color.red, style=shape.labeldown, size=size.small)

// Alerts
alertcondition(entry_long, title="Long Entry", message="Go LONG: High-leverage entry detected.")
alertcondition(entry_short, title="Short Entry", message="Go SHORT: High-leverage entry detected.")

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