该策略是一个基于双均线系统的自适应交易策略,通过快速移动平均线(EMA25)与慢速移动平均线(EMA100)的交叉来识别买入信号,并结合动态止损和获利目标优化交易效果。该策略采用突破交易思路,在保证收益的同时注重风险控制,适合中长期趋势交易。
策略核心逻辑包括三个关键部分: 1. 信号系统:利用EMA25上穿EMA100形成做多信号,这种交叉通常预示着上升趋势的开始。 2. 风险控制:以EMA100下方最近的红色蜡烛最低点作为止损点,这个设置能有效防止假突破带来的损失。 3. 利润管理:采用1:3的风险收益比设置获利目标,当达到2%收益时自动将止损点调整到成本线,实现无风险持仓。
该策略通过均线交叉捕捉趋势起点,配合动态止损和利润管理机制,实现了较好的风险收益特征。策略设计充分考虑了实战需求,具有较强的实用性。通过建议的优化方向,策略的稳定性和适应性还可以进一步提升。策略适合风险承受能力较强、追求中长期稳定收益的交易者使用。
/*backtest start: 2019-12-23 08:00:00 end: 2024-12-18 08:00:00 period: 1d basePeriod: 1d exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=5 strategy("EMA Crossover with TP and SL (Buy only) and Break-even", overlay=true) // EMA sozlamalari emaFastLength = input.int(25, title="Fast EMA Length") emaSlowLength = input.int(100, title="Slow EMA Length") // Hisoblash emaFast = ta.ema(close, emaFastLength) emaSlow = ta.ema(close, emaSlowLength) // Kesishishni aniqlash bullishCross = ta.crossover(emaFast, emaSlow) // EMA 25 EMA 100 ni yuqoriga kesib o'tganda // EMA 100 tagidagi oxirgi qizil shamning tagini olish lastRedCandleLow = ta.valuewhen(close < open and close < emaSlow, low, 0) // EMA 100 pastidagi qizil shamning tagi // TP va SL darajalarini hisoblash longSL = lastRedCandleLow longTP = close + 3 * (close - longSL) // TP SL ga nisbatan 1:2 masofada // Savdoni ochish va 2% foyda bo'lganda SLni break-even ga o‘zgartirish if (bullishCross) strategy.entry("Buy", strategy.long) // Buy pozitsiyasini ochish strategy.exit("Exit Buy", "Buy", stop=longSL, limit=longTP) // SL va TP qo'yish // 2% foyda bo'lganda SLni break-even ga o'zgartirish if (strategy.position_size > 0) profitPercentage = (close - strategy.position_avg_price) / strategy.position_avg_price * 100 if (profitPercentage >= 2) strategy.exit("Exit Buy BE", "Buy", stop=strategy.position_avg_price) // SLni break-even ga o'zgartirish // Signalni ko'rsatish plotshape(bullishCross, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY") // // TP va SL chizish // if (bullishCross) // line.new(x1=bar_index, y1=longSL, x2=bar_index+1, y2=longSL, color=color.red, width=1, extend=extend.none) // line.new(x1=bar_index, y1=longTP, x2=bar_index+1, y2=longTP, color=color.green, width=1, extend=extend.none) // label.new(bar_index, longSL, text="SL: " + str.tostring(longSL), style=label.style_label_down, color=color.red, textcolor=color.white, size=size.small) // label.new(bar_index, longTP, text="TP: " + str.tostring(longTP), style=label.style_label_up, color=color.green, textcolor=color.white, size=size.small) // EMA chizish plot(emaFast, color=color.blue, title="Fast EMA (25)") plot(emaSlow, color=color.orange, title="Slow EMA (100)") // Alert qo'shish alertcondition(bullishCross, title="Buy Signal Alert", message="EMA 25 crossed above EMA 100! Buy Signal!")