这是一种基于多时间尺度技术指标组合的量化交易策略,通过综合分析移动平均线、随机相对强弱指标(SRI)和价格动量,实现精准的市场进入和风险控制。该策略旨在捕捉市场趋势,同时有效管理交易风险,适用于追求稳定收益的量化交易者。
策略核心由五个关键技术指标组成: 1. 移动平均线指标: - 5日、10日、50日和100日简单移动平均线(SMA) - 通过多时间尺度移动平均线的相对位置判断市场趋势方向 - 价格与移动平均线的相对关系确定进入信号
这是一种基于多时间尺度分析的量化交易策略,通过综合技术指标和先进的风险管理机制,旨在捕捉市场趋势并控制交易风险。策略的核心优势在于信号的多维度验证和灵活的风险控制。未来将通过机器学习和更复杂的技术指标组合进一步提升策略的稳定性和收益率。
/*backtest
start: 2024-04-17 00:00:00
end: 2025-04-15 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"TRX_USD"}]
*/
//@version=6
strategy("Strategia LONG & SHORT con TP, SL e BE", overlay=true, default_qty_type=strategy.fixed, default_qty_value=1)
// === INPUT === //
tp_points = input.int(60000, "Take Profit (punti)")
sl_points = input.int(25000, "Stop Loss (punti)")
breakeven_trigger = tp_points * 0.5
// === MEDIE MOBILI === //
ma5 = ta.sma(close, 5)
ma10 = ta.sma(close, 10)
ma50 = ta.sma(close, 50)
ma100 = ta.sma(close, 100)
// === SRI da timeframe 1 minuto === //
sri_tf = "1"
sri_length = 10
sri_src = close
sri = request.security(syminfo.tickerid, sri_tf, ta.stoch(sri_src, sri_src, sri_src, sri_length))
// === CONDIZIONI LONG === //
long_candle = open > close[1]
price_above_ma100 = close > ma100
ma50_above_ma100 = ma50 > ma100
ma5_above_ma10 = ma5 > ma10
sri_below_75 = sri < 70
long_condition = long_candle and price_above_ma100 and ma50_above_ma100 and ma5_above_ma10 and sri_below_75
// === CONDIZIONI SHORT === //
short_candle = open < close[1]
price_below_ma100 = close < ma100
ma50_below_ma100 = ma50 < ma100
ma5_below_ma10 = ma5 < ma10
sri_above_25 = sri > 30
short_condition = short_candle and price_below_ma100 and ma50_below_ma100 and ma5_below_ma10 and sri_above_25
// === ENTRY LONG === //
if (long_condition)
strategy.entry("Long", strategy.long)
// === ENTRY SHORT === //
if (short_condition)
strategy.entry("Short", strategy.short)
// === GESTIONE USCITE === //
var float long_entry_price = na
var float short_entry_price = na
// LONG: TP/SL + break-even
if (strategy.position_size > 0)
if (na(long_entry_price))
long_entry_price := strategy.position_avg_price
tp_price_long = long_entry_price + tp_points * syminfo.mintick
sl_price_long = long_entry_price - sl_points * syminfo.mintick
be_trigger_long = long_entry_price + breakeven_trigger * syminfo.mintick
sl_be = close >= be_trigger_long ? long_entry_price : sl_price_long
strategy.exit("Exit Long", from_entry="Long", limit=tp_price_long, stop=sl_be)
// SHORT: TP/SL + break-even
if (strategy.position_size < 0)
if (na(short_entry_price))
short_entry_price := strategy.position_avg_price
tp_price_short = short_entry_price - tp_points * syminfo.mintick
sl_price_short = short_entry_price + sl_points * syminfo.mintick
be_trigger_short = short_entry_price - breakeven_trigger * syminfo.mintick
sl_be_short = close <= be_trigger_short ? short_entry_price : sl_price_short
strategy.exit("Exit Short", from_entry="Short", limit=tp_price_short, stop=sl_be_short)
// Reset quando flat
if (strategy.position_size == 0)
long_entry_price := na
short_entry_price := na