This strategy judges market trend direction by calculating moving average and price difference to determine long entry, avoiding frequent opening during shocks.
This strategy combines MA and price fluctuation to capture upside opportunities during trends.
When price breaks above MA, it indicates an upward trend. If recent 3-period HL difference is larger than 20-period average, it suggests increased fluctuation and potential for a big rise for entry.
After opening, set a fixed percentage stop loss price. Exit when price drops below to control downside risk.
Risk Solutions:
This strategy effectively filters out shocks and volatility before entering in trending markets with simple but useful indicators, avoiding unnecessary trades. Also, risk is well controlled to limit losses. Further optimizations can lead to even better results.
/*backtest start: 2023-02-21 00:00:00 end: 2024-02-27 00:00:00 period: 1d basePeriod: 1h exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=5 strategy("Estrategia de Diferencia HL y MA para Criptomonedas", shorttitle="HL MA Crypto Strategy-Ortiz", overlay=true) // Definir longitud de MA y HL ma_length = input(20, title="Longitud MA") hl_length = input(3, title="Longitud HL") exit_below_price = input(0.98, title="Salir por debajo de precio") // Calcular MA ma = ta.sma(close, ma_length) // Calcular HL hh = ta.highest(high, hl_length) ll = ta.lowest(low, hl_length) hl = hh - ll // Condiciones de tendencia alcista bullish_trend = close > ma // Condiciones de entrada y salida long_condition = close > ma and close > ma[1] and hl > ta.sma(hl, ma_length) short_condition = false // No operar en tendencia bajista exit_condition = low < close * exit_below_price // Entrada y salida de la estrategia if (long_condition) strategy.entry("Buy", strategy.long) if (short_condition) strategy.entry("Sell", strategy.short) if (exit_condition) strategy.close("Buy") // Plot de señales en el gráfico plotshape(long_condition, style=shape.triangleup, location=location.belowbar, color=color.green, size=size.small, title="Buy Signal") plotshape(short_condition, style=shape.triangledown, location=location.abovebar, color=color.red, size=size.small, title="Sell Signal")