This is a trading strategy system based on a four-period simple moving average, integrated with dynamic stop-loss and take-profit management mechanisms. The strategy captures market trend turning points by monitoring price crossovers with short-term moving averages and implements percentage-based stop-loss and take-profit levels for risk management. The core strength lies in utilizing the quick response characteristics of short-period moving averages, combined with strict money management rules to achieve stable trading results.
The strategy operates on the following core logic: First, it calculates a 4-period Simple Moving Average (SMA) as the primary indicator. When price crosses above the SMA, the system recognizes it as a bullish signal and enters a long position; when price crosses below the SMA, it identifies a bearish signal and enters a short position. Each trade is set with dynamic take-profit and stop-loss points based on the entry price, with default values of 2% for take-profit and 1% for stop-loss. This setup ensures a 2:1 reward-to-risk ratio, adhering to professional money management principles.
This is a well-structured quantitative trading strategy with clear logic. It captures market momentum through short-term moving averages, supplemented by strict risk control mechanisms, suitable for traders seeking stable returns. While there is room for optimization, the strategy’s basic framework offers good scalability, and through continuous improvement and adjustment, it has the potential to achieve better trading results.
/*backtest start: 2019-12-23 08:00:00 end: 2024-11-28 00:00:00 period: 2d basePeriod: 2d exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=5 strategy("4SMA Strategy with Targets and Stop Loss", overlay=true) // Input parameters for SMA smaLength = input.int(4, title="SMA Length", minval=1) // Input parameters for stop loss and take profit takeProfitPercent = input.float(2.0, title="Take Profit (%)", step=0.1) // Default: 2% stopLossPercent = input.float(1.0, title="Stop Loss (%)", step=0.1) // Default: 1% // Calculate 4-period SMA sma = ta.sma(close, smaLength) // Plot SMA plot(sma, color=color.blue, title="4SMA Line") // Entry Conditions longCondition = ta.crossover(close, sma) // Price crosses above SMA (bullish signal) shortCondition = ta.crossunder(close, sma) // Price crosses below SMA (bearish signal) // Strategy Logic if (longCondition) strategy.entry("Long", strategy.long) // Enter long position if (shortCondition) strategy.entry("Short", strategy.short) // Enter short position // Calculate Take Profit and Stop Loss longTakeProfit = strategy.position_avg_price * (1 + takeProfitPercent / 100) // TP for long longStopLoss = strategy.position_avg_price * (1 - stopLossPercent / 100) // SL for long shortTakeProfit = strategy.position_avg_price * (1 - takeProfitPercent / 100) // TP for short shortStopLoss = strategy.position_avg_price * (1 + stopLossPercent / 100) // SL for short // Exit for Long if (strategy.position_size > 0) // If in a long position strategy.exit("Long TP/SL", from_entry="Long", limit=longTakeProfit, stop=longStopLoss) // Exit for Short if (strategy.position_size < 0) // If in a short position strategy.exit("Short TP/SL", from_entry="Short", limit=shortTakeProfit, stop=shortStopLoss)