Проаналізуй цю трейд стартегію, та гарантовано її покращ, бе...
Prompt
Проаналізуй цю трейд стартегію, та гарантовано її покращ, без погіршень: "//@version=6 // MERIDIAN BTC Engine v6 (Pro-Edition: Selective Shorts + Break-Even) // Optimized for BINANCE:BTCUSDT.P 4H // Глибокий аналіз тренду, сили та волатильності для фільтрації шортів. // Додано часовий фільтр (00:00 - 02:00 UTC+3) та функцію переведення в безубиток (Break-Even). strategy("MERIDIAN BTC Engine V6", shorttitle = "MERIDIAN", overlay = true, initial_capital = 10000, default_qty_type = strategy.fixed, default_qty_value = 0.001, commission_type = strategy.commission.percent, commission_value = 0.04, slippage = 2, pyramiding = 0, process_orders_on_close = true, margin_long = 10, margin_short = 10, calc_on_every_tick = false, max_bars_back = 1000, currency = currency.USD) // --- ІНПУТИ --- grp_risk = "Управління капіталом" riskPct = input.float(3.0, "Ризик на угоду, %", minval = 0.5, maxval = 8.0, step = 0.5, group = grp_risk) maxLev = input.float(10.0, "Макс. плече", minval = 1.0, maxval = 20.0, step = 0.5, group = grp_risk) grp_time = "Фільтр часу (Заборона торгівлі)" useTimeFilter = input.bool(true, "Увімкнути фільтр годин", group = grp_time) forbiddenSess = input.session("0000-0200:1234567", "Заборонений час", group = grp_time) timeZoneInput = input.string("UTC+3", "Часовий пояс (Київ)", group = grp_time) closeOnForbidden = input.bool(false, "Примусово закривати угоди під час паузи", group = grp_time) grp_signal = "Сигнали (Long & Short)" emaLen = input.int(200, "EMA Основний фільтр", minval = 50, group = grp_signal) stAtr = input.int(10, "Supertrend ATR довжина", minval = 5, group = grp_signal) stSlow = input.float(3.0, "ST Повільний множник", minval = 1.0, group = grp_signal) stFast = input.float(2.0, "ST Швидкий множник", minval = 1.0, group = grp_signal) grp_short = "Фільтрація 'Ефективних' Шортів" allowShort = input.bool(true, "Дозволити селективні шорти", group = grp_short) adxThreshold = input.int(20, "Мінімальна сила тренду (ADX)", minval = 10, group = grp_short) rsiUpper = input.int(55, "Макс. RSI для шорту", group = grp_short) rsiLower = input.int(30, "Мін. RSI (не перепроданість)", group = grp_short) grp_stops = "Стопи, Трейлінг та Безубиток" atrLen = input.int(14, "ATR довжина", minval = 5, group = grp_stops) atrStopMult = input.float(2.0, "Hard Stop ATR ×", group = grp_stops) trailMultL = input.float(3.5, "Trail Long ATR ×", group = grp_stops) trailMultS = input.float(2.8, "Trail Short ATR × (більш жорсткий)", group = grp_stops) useBE = input.bool(true, "Увімкнути безубиток (Break-Even)", group = grp_stops) beAtrMult = input.float(1.5, "BE тригер (ATR × прибутку)", minval = 0.5, step = 0.1, group = grp_stops) beOffsetPct = input.float(0.08, "BE буфер комісії, %", minval = 0.0, step = 0.01, group = grp_stops) // --- ТЕХНІЧНІ ІНДИКАТОРИ --- float emaFilter = ta.ema(close, emaLen) [stSlowLine, stSlowDir] = ta.supertrend(stSlow, stAtr) [stFastLine, stFastDir] = ta.supertrend(stFast, stAtr) float atrVal = ta.atr(atrLen) float rsiVal = ta.rsi(close, 14) // Розрахунок ADX для визначення сили тренду (щоб не шортити флет) [plusDI, minusDI, adxVal] = ta.dmi(14, 14) // --- ЧАСОВИЙ ФІЛЬТР (00:00 - 02:00 UTC+3) --- bool isForbiddenTime = useTimeFilter and not na(time(timeframe.period, forbiddenSess, timeZoneInput)) bool tradeAllowed = not isForbiddenTime // --- ЛОГІКА СИГНАЛІВ --- // Умова для Long: Ціна > EMA + обидва Supertrend зелені bool bullBase = stSlowDir < 0 and stFastDir < 0 and close > emaFilter // Умова для "Жорсткого" Short (Selective): // 1. Ціна < EMA 200 // 2. Обидва Supertrend червоні // 3. ADX > Threshold (тренд має силу) // 4. RSI між 30 та 55 (є простір для падіння, не шортимо в дно) // 5. Поточний ATR вищий за середній (зростаюча паніка/волатильність) float atrAvg = ta.sma(atrVal, 20) bool bearBase = stSlowDir > 0 and stFastDir > 0 and close < emaFilter bool shortFilter = adxVal > adxThreshold and rsiVal < rsiUpper and rsiVal > rsiLower and atrVal > (atrAvg * 0.9) bool wantShort = allowShort and bearBase and shortFilter // Фільтровані сигнали з урахуванням часу bool enterLong = bullBase and tradeAllowed bool enterShort = wantShort and tradeAllowed // --- СТАН ТА РОЗРАХУНОК ПОЗИЦІЇ --- var float hardStop = na var float trailStop = na var bool isBeActivated = false sizeFromRisk(stopDist) => float riskCash = strategy.equity * (riskPct / 100.0) float rawQty = stopDist > 0 ? riskCash / stopDist : 0.0 float maxQty = (strategy.equity * maxLev) / close math.max(math.min(rawQty, maxQty), 0.0) // Очищення стану, коли немає позиції if strategy.position_size == 0 hardStop := na trailStop := na isBeActivated := false // --- ПРИМУСОВЕ ЗАКРИТТЯ ПРИ НАСТАННІ ЗАБОРОНЕНОГО ЧАСУ (ЯКЩО АКТИВОВАНО В НАЛАШТУВАННЯХ) --- if isForbiddenTime and closeOnForbidden and strategy.position_size != 0 strategy.close_all(comment = "Forbidden Time Exit") // --- ВИКОНАННЯ УГОД --- // ВХІД У LONG if enterLong and strategy.position_size <= 0 if strategy.position_size < 0 strategy.close("Short", comment = "Flip to Long") float stopDist = atrStopMult * atrVal float qtyBtc = sizeFromRisk(stopDist) if qtyBtc > 0 strategy.entry("Long", strategy.long, qty = qtyBtc, comment = "M-Long") hardStop := close - stopDist trailStop := high - trailMultL * atrVal isBeActivated := false alert("MERIDIAN: LONG ENTER", alert.freq_once_per_bar_close) // ВХІД У SHORT (СЕЛЕКТИВНИЙ) if enterShort and strategy.position_size >= 0 if strategy.position_size > 0 strategy.close("Long", comment = "Flip to Short") float stopDist = (atrStopMult * 0.8) * atrVal // Коротший стоп для шорта float qtyBtc = sizeFromRisk(stopDist) if qtyBtc > 0 strategy.entry("Short", strategy.short, qty = qtyBtc, comment = "M-Selective-Short") hardStop := close + stopDist trailStop := low + trailMultS * atrVal isBeActivated := false alert("MERIDIAN: SELECTIVE SHORT ENTER", alert.freq_once_per_bar_close) // --- УПРАВЛІННЯ ВИХОДАМИ (BREAK-EVEN & DYNAMIC TRAILING) --- if strategy.position_size > 0 // Перевірка умови переведення в безубиток для лонга if useBE and not isBeActivated and high >= strategy.position_avg_price + beAtrMult * atrVal float bePriceLong = strategy.position_avg_price * (1.0 + beOffsetPct / 100.0) hardStop := math.max(nz(hardStop, bePriceLong), bePriceLong) isBeActivated := true // Чандельєр трейл для лонга trailStop := math.max(nz(trailStop, hardStop), high - trailMultL * atrVal) strategy.exit("Exit Long", "Long", stop = math.max(hardStop, trailStop), comment_loss = "SL-L", comment_profit = isBeActivated ? "BE/TSL-L" : "TSL-L") // Режимний вихід (якщо тренд зламався раніше стопа) if not (stSlowDir < 0) strategy.close("Long", comment = "Long Trend End") if strategy.position_size < 0 // Перевірка умови переведення в безубиток для шорта if useBE and not isBeActivated and low <= strategy.position_avg_price - beAtrMult * atrVal float bePriceShort = strategy.position_avg_price * (1.0 - beOffsetPct / 100.0) hardStop := math.min(nz(hardStop, bePriceShort), bePriceShort) isBeActivated := true // Більш агресивний трейл для шорта trailStop := math.min(nz(trailStop, hardStop), low + trailMultS * atrVal) strategy.exit("Exit Short", "Short", stop = math.min(hardStop, trailStop), comment_loss = "SL-S", comment_profit = isBeActivated ? "BE/TSL-S" : "TSL-S") // Режимний вихід if not (stSlowDir > 0) strategy.close("Short", comment = "Short Trend End") // Стан закриття для візуалізації bool posJustClosed = strategy.position_size[1] != 0 and strategy.position_size == 0 // --- ВІЗУАЛІЗАЦІЯ --- plot(emaFilter, "EMA Filter", color = color.new(color.gray, 50), linewidth = 2) plot(stSlowLine, "Slow Supertrend", color = stSlowDir < 0 ? color.new(color.green, 20) : color.new(color.red, 20), linewidth = 3) plot(stFastLine, "Fast Supertrend", color = color.new(color.white, 70), linewidth = 1) // Лінія активного рівня стопу (бірюзова, якщо активовано безубиток; помаранчева за замовчуванням) float activeStop = strategy.position_size > 0 ? math.max(hardStop, trailStop) : strategy.position_size < 0 ? math.min(hardStop, trailStop) : na plot(activeStop, "Active SL / BE / Trail", color = isBeActivated ? color.aqua : color.orange, linewidth = 1, style = plot.style_linebr) // Підсвітка зон (заборонений час підсвічується сірим) color bgCol = isForbiddenTime ? color.new(color.gray, 88) : (bullBase and tradeAllowed ? color.new(color.green, 93) : (wantShort and tradeAllowed ? color.new(color.red, 93) : na)) bgcolor(bgCol) // Мітки сигналів plotshape(enterLong and not enterLong[1], "Long Signal", shape.triangleup, location.belowbar, color.green, size = size.small) plotshape(enterShort and not enterShort[1], "Selective Short", shape.triangledown, location.abovebar, color.red, size = size.small) plotshape(posJustClosed, "Exit", shape.xcross, location.absolute, color.gray, size = size.tiny) // --- ІНФОРМАЦІЙНА ТАБЛИЦЯ (HUD) --- var hud = table.new(position.top_right, 2, 7, bgcolor = color.new(color.black, 20), border_width = 1, frame_color = color.gray) if barstate.islast float levNow = strategy.position_size != 0 ? math.abs(strategy.position_size * close / strategy.equity) : 0.0 color trendCol = close > emaFilter ? color.green : color.red table.cell(hud, 0, 0, "MERIDIAN V6", text_color = color.white, text_size = size.small) table.cell(hud, 1, 0, strategy.position_size > 0 ? "LONG" : strategy.position_size < 0 ? "SHORT" : "FLAT", text_color = strategy.position_size > 0 ? color.green : strategy.position_size < 0 ? color.red : color.white) table.cell(hud, 0, 1, "ADX Force", text_color = color.gray, text_size = size.tiny) table.cell(hud, 1, 1, str.tostring(adxVal, "#.#"), text_color = adxVal > 20 ? color.orange : color.white, text_size = size.tiny) table.cell(hud, 0, 2, "Equity", text_color = color.gray, text_size = size.tiny) table.cell(hud, 1, 2, str.tostring(strategy.equity, "###,###"), text_color = color.white, text_size = size.tiny) table.cell(hud, 0, 3, "P/L Net", text_color = color.gray, text_size = size.tiny) table.cell(hud, 1, 3, str.tostring(strategy.netprofit, "###,###"), text_color = strategy.netprofit >= 0 ? color.green : color.red, text_size = size.tiny) table.cell(hud, 0, 4, "Leverage", text_color = color.gray, text_size = size.tiny) table.cell(hud, 1, 4, str.tostring(levNow, "#.##") + "x", text_size = size.tiny) table.cell(hud, 0, 5, "Win Rate", text_color = color.gray, text_size = size.tiny) table.cell(hud, 1, 5, str.tostring(strategy.wintrades / math.max(strategy.closedtrades, 1) * 100, "#.#") + "%", text_size = size.tiny) table.cell(hud, 0, 6, "Time Filter", text_color = color.gray, text_size = size.tiny) table.cell(hud, 1, 6, isForbiddenTime ? "PAUSED (00-02)" : "ACTIVE", text_color = isForbiddenTime ? color.orange : color.green, text_size = size.tiny)"
Response not available