//@version=5
strategy("SMA Crossover (50/200) - Eterna",
overlay=true,
initial_capital=10000,
default_qty_type=strategy.percent_of_equity,
default_qty_value=10,
commission_type=strategy.commission.percent,
commission_value=0.075)
// ==================== Parameters ====================
fastLength = input.int(50, "Fast SMA Length", minval=1)
slowLength = input.int(200, "Slow SMA Length", minval=1)
leverage = input.int(5, "Leverage", minval=1, maxval=100)
positionSize = input.float(0.01, "Position Size", minval=0.001, step=0.001)
// Eterna Webhook Settings
enableWebhook = input.bool(true, "Enable Webhook Alerts", group="Webhook")
webhookMessage = input.string('{"action":"{{strategy.order.action}}", "symbol":"{{ticker}}", "size":' + str.tostring(positionSize) + ', "leverage":' + str.tostring(leverage) + '}',
"Webhook JSON",
group="Webhook")
// ==================== Indicators ====================
fastSMA = ta.sma(close, fastLength)
slowSMA = ta.sma(close, slowLength)
// ==================== Entry Conditions ====================
longCondition = ta.crossover(fastSMA, slowSMA)
shortCondition = ta.crossunder(fastSMA, slowSMA)
// ==================== Strategy Execution ====================
if longCondition
strategy.entry("Long", strategy.long, alert_message=str.replace(webhookMessage, "{{strategy.order.action}}", "buy"))
if shortCondition
strategy.entry("Short", strategy.short, alert_message=str.replace(webhookMessage, "{{strategy.order.action}}", "sell"))
// ==================== Plotting ====================
plot(fastSMA, "Fast SMA", color=color.blue, linewidth=2)
plot(slowSMA, "Slow SMA", color=color.red, linewidth=2)
// Plot entry signals
plotshape(longCondition, "Long Signal", shape.triangleup, location.belowbar, color.green, size=size.small)
plotshape(shortCondition, "Short Signal", shape.triangledown, location.abovebar, color.red, size=size.small)
// Background color for trend
bgcolor(fastSMA > slowSMA ? color.new(color.green, 95) : color.new(color.red, 95))