This is a trading strategy based on the golden cross of dual moving averages, combined with adaptive risk management and dynamic position sizing. The strategy uses 50-day and 200-day Simple Moving Averages (SMA) to identify trends, generating a buy signal when the 50-day MA crosses above the 200-day MA. Simultaneously, the strategy employs a risk control method based on 2.5% of the total account equity, dynamically calculating the position size for each trade, and uses a percentage-based stop-loss relative to the 200-day MA to protect profits.
This adaptive risk management strategy based on the dual moving average golden cross combines classic technical analysis methods with modern risk management techniques, providing traders with a relatively robust trading system. It not only captures medium to long-term trends but also effectively controls risk, suitable for investors seeking stable returns. However, when using this strategy, traders still need to closely monitor market changes and continuously optimize parameters based on actual trading performance to achieve the best risk-reward ratio.
/*backtest start: 2019-12-23 08:00:00 end: 2024-09-24 08:00:00 period: 1d basePeriod: 1d exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=5 strategy("Golden Cross with 1.5% Stop-Loss & MA Exit", overlay=true) // Define the 50-day and 200-day moving averages ma50 = ta.sma(close, 50) ma200 = ta.sma(close, 200) // Entry condition: 50-day MA crosses above 200-day MA (Golden Cross) goldenCross = ta.crossover(ma50, ma200) // Exit condition: price drops below the 200-day MA exitCondition = close < ma200 // Set the stop-loss to 1.5% below the 200-day moving average stopLoss = ma200 * 0.985 // 1.5% below the 200-day MA // Risk management (1.5% of total equity) riskPercent = 0.025 // 1.5% risk equity = strategy.equity riskAmount = equity * riskPercent // Calculate the distance between the entry price (close) and the stop-loss stopDistance = close - stopLoss // Calculate position size based on the risk amount and stop-loss distance if (goldenCross and stopDistance > 0) positionSize = riskAmount / stopDistance strategy.entry("Long", strategy.long, qty=positionSize) // Exit the trade when the price crosses below the 200-day moving average if (exitCondition) strategy.close("Long") // Plot the moving averages on the chart for visualization plot(ma50, color=color.blue, linewidth=2, title="50-day MA") plot(ma200, color=color.red, linewidth=2, title="200-day MA")template: strategy.tpl:40:21: executing "strategy.tpl" at <.api.GetStrategyListByName>: wrong number of args for GetStrategyListByName: want 7 got 6