This is a trend-following trading strategy based on moving average lines. It uses a 14-day simple moving average (SMA) to determine market trend direction and enter trades when price approaches the moving average line.
The core logic of this strategy is:
This is a trend-following strategy. It identifies overall market trend using the moving average line and enters oversold stages along the major trend. Stop loss and take profit are used to exit trades.
The main advantages of this strategy are:
There are also some risks associated with this strategy:
Some methods to mitigate risks include allowing wider entry range, adjusting stop loss position etc.
Some ways to optimize this strategy:
In summary, this is a simple and practical trend-following strategy. It identifies trend direction using moving average, enters oversold stages, and sets reasonable stop loss and take profit to control risk. With proper enhancements and combinations, it can be adapted to more market conditions and further improve stability and profitability.
/*backtest start: 2024-01-26 00:00:00 end: 2024-02-25 00:00:00 period: 2h basePeriod: 15m exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=5 strategy("Estrategia MA - mejor", overlay=true) // Parámetros de la estrategia initialCapital = 1000 // Inversión inicial riskPerTrade = 0.02 // Riesgo por operación (2% del capital por operación) lengthMA = 14 // Período de la media móvil pipValue = 20 / 10 // Valor de un pip (30 euros / 10 pips) // Apalancamiento leverage = 10 // Cálculo de la media móvil en el marco temporal de 30 minutos ma = request.security(syminfo.tickerid, "30", ta.sma(close, lengthMA)) // Condiciones de Entrada en Sobreventa entryCondition = close < ma * 0.99 // Ejemplo: 1% por debajo de la MA // Lógica de entrada y salida if entryCondition riskAmount = initialCapital * riskPerTrade // Cantidad de euros a arriesgar por operación size = 1 // Tamaño de la posición con apalancamiento strategy.entry("Long", strategy.long, qty=size) stopLossPrice = close - (10 * pipValue / size) takeProfitPrice = close + (60 * pipValue / size) strategy.exit("Exit Long", "Long", stop=stopLossPrice, limit=takeProfitPrice) // Gráficos plot(ma, color=color.blue, title="Media Móvil") plotshape(series=entryCondition, title="Entrada en Sobreventa", location=location.belowbar, color=color.green, style=shape.labelup, text="↑ Compra")