Simple MA Crossover Strategy by sborejonandgr5
By version
Performance Metrics
- Author: version
- Symbol: BITSTAMP:BTCUSD
- Timeframe: 1 hour
- Net P&L: −50.39 USD (−0.50%)
- Win Rate: 35.3%
- Profit Factor: 0.984
- Max Drawdown: 600.99 USD (5.81%)
- Total Trades: 561
Description
//version=5strategy("Simple MA Crossover Strategy", overlay=true, initial_capital=10000, default_qty_type=strategy.percent_of_equity, default_qty_value=10)// === INPUTS ===shortLength = input.int(9, title="Short MA Length")longLength = input.int(21, title="Long MA Length")// === CALCULATIONS ===shortMA = ta.sma(close, shortLength)longMA = ta.sma(close, longLength)// === PLOTS ===plot(shortMA, color=color.blue, title="Short MA")plot(longMA, color=color.red, title="Long MA")// === CONDITIONS ===longCondition = ta.crossover(shortMA, longMA)shortCondition = ta.crossunder(shortMA, longMA)// === EXECUTION ===if (longCondition) strategy.entry("Long", strategy.long)if (shortCondition) strategy.entry("Short", strategy.short)// === OPTIONAL: CLOSE ON OPPOSITE SIGNAL ===strategy.close("Long", when=shortCondition)strategy.close("Short", when=longCondition)