//@version=6 strategy(title="HiLo-str-v1.53", overlay=true, pyramiding=2, default_qty_type=strategy.cash, default_qty_value=100000, commission_type=strategy.commission.percent, commission_value=0.11, process_orders_on_close=true) // ========================================== // HiLo-str-v1.53 // ========================================== // --- INPUTS --- // Core MACD and entry settings macdSrcOpt = input.string("Close", title="MACD Source", options=["Close", "OHLC4"]) fastLen = input.int(11, title="Fast EMA Length", minval=1) slowLen = input.int(26, title="Slow EMA Length", minval=1) signalLen = 9 minDaysBetweenBuys = input.int(5, title="Minimum Days between Buys", minval=1, tooltip="Minimum number of days that must pass between any two Buy entries (across all legs)") minProfitPct = input.int(12, title="Minimum Profit % (Sell)", minval=0, maxval=100) // POSITION FILTER usePositionFilter = input.bool(true, title="Only allow Buy when Position < ( % )", group="POSITION FILTER") positionLessThanPct = input.int(90, title="Position Less than %", minval=0, maxval=100, group="POSITION FILTER") // DOWN-TREND PROTECTION (Stop Loss) useLossExit = input.bool(true, title="Use Stop Loss and Cooling Period", group="DOWN-TREND PROTECTION") lossPct = input.int(12, title="Stop Loss ( % ) (Sell when loss >= this %)", minval=0, maxval=100, group="DOWN-TREND PROTECTION") lossPauseDays = input.int(30, title="Cooling Period after Stop Loss (Days)", minval=1, group="DOWN-TREND PROTECTION") // MARKET REGIME FILTER (NEW in v1.48) useHsiRegimeFilter = input.bool(false, title="Use Hang Seng Market Regime Filter", group="MARKET REGIME FILTER", tooltip="Blocks buys unless the Hang Seng Index is above its slow EMA, its fast EMA is above its slow EMA, and the fast EMA slope is rising.") hsiSymbol = input.symbol("TVC:HSI", title="Hang Seng Symbol", group="MARKET REGIME FILTER") hsiFastEmaLen = input.int(10, title="HSI Fast EMA Length", minval=10, group="MARKET REGIME FILTER") hsiSlowEmaLen = input.int(50, title="HSI Slow EMA Length", minval=10, group="MARKET REGIME FILTER") hsiSlopeLookback = input.int(10, title="HSI Fast EMA Slope Lookback", minval=1, group="MARKET REGIME FILTER") // (MOVE-ON removed) // TRAILING PROFIT EXIT (give-back protection) useTrailingExit = input.bool(false, title="Use Trailing Profit Exit", group="TRAILING PROFIT EXIT", tooltip="When a MACD Highest forms, if the open leg already meets its minimum profit, arm a trailing stop. The leg then closes when profit gives back the set % from its running peak — locking gains without waiting for the next flip.") trailingGivebackPct = input.float(2.0, title="Close if Profit drops % from Peak", minval=0.1, maxval=100.0, step=0.1, group="TRAILING PROFIT EXIT") // TRAILING ENTRY FOR BUY (mirror of the trailing sell: confirm the dip before buying) useTrailingEntryBuy = input.bool(false, title="Use Trailing Entry for Buy", group="TRAILING ENTRY (BUY)", tooltip="Do not buy at the MACD Lowest. Arm on a MACD Lowest, track the (lowest) price, then buy once price has risen a set % from that trough. Aims to catch a lower confirmed entry price instead of a falling knife.") trailingBuyRisePct = input.float(2.0, title="Buy once price rises % from trough", minval=0.1, maxval=100.0, step=0.1, group="TRAILING ENTRY (BUY)") // DATE SETTINGS currentYear = year(timenow) currentMonth = month(timenow) currentDay = dayofmonth(timenow) startYear = currentMonth <= 6 ? currentYear - 1 : currentYear startMonth = currentMonth <= 6 ? currentMonth + 6 : currentMonth - 6 dynamicStartDate = timestamp(startYear, startMonth, currentDay, 0, 0, 0) useManualDate = input.bool(false, title="Use Manual Start Date", group="DATE SETTINGS") manualStartDateRaw = input.time(timestamp("01 Jan 2025 00:00 +0000"), title="Manual Start Date", group="DATE SETTINGS") manualStartDate = timestamp(year(manualStartDateRaw), month(manualStartDateRaw), dayofmonth(manualStartDateRaw), 8, 0, 0) // --- LABELS & ALERTS --- strategyLabel = "HiLo-str-v1.53 (" + str.tostring(fastLen) + ", " + str.tostring(slowLen) + ", " + macdSrcOpt + ", " + str.tostring(minProfitPct) + ")" // Feature suffix for alerts string featureSuffix = "" if usePositionFilter featureSuffix += " (Pos<" + str.tostring(positionLessThanPct) + "%)" if useLossExit featureSuffix += " (SL " + str.tostring(lossPct) + "%/" + str.tostring(lossPauseDays) + "d)" if useTrailingExit featureSuffix += " (Trail " + str.tostring(trailingGivebackPct) + "%)" if useTrailingEntryBuy featureSuffix += " (TrailBuy " + str.tostring(trailingBuyRisePct) + "%)" string pfText = usePositionFilter ? str.tostring(positionLessThanPct) : "-" string lossPctText = useLossExit ? str.tostring(lossPct) : "-" string lossPauseText = useLossExit ? str.tostring(lossPauseDays) : "-" string alertLabel = "HiLo-str-v1.53 (" + macdSrcOpt + ", " + str.tostring(fastLen) + ", " + str.tostring(slowLen) + ", " + str.tostring(minDaysBetweenBuys) + ", " + str.tostring(minProfitPct) + ", " + pfText + ", " + lossPctText + ", " + lossPauseText + (useHsiRegimeFilter ? ", " + str.tostring(hsiSymbol) + ", " + str.tostring(hsiFastEmaLen) + ", " + str.tostring(hsiSlowEmaLen) + ", " + str.tostring(hsiSlopeLookback) : "") + (useTrailingExit ? ", " + str.tostring(trailingGivebackPct) : "") + (useTrailingEntryBuy ? ", " + str.tostring(trailingBuyRisePct) : "") + ")" startDate = useManualDate ? manualStartDate : dynamicStartDate timeCondition = time >= startDate // --- MACD --- macdSrc = macdSrcOpt == "Close" ? close : ohlc4 macdLine = ta.ema(macdSrc, fastLen) - ta.ema(macdSrc, slowLen) signalLine = ta.ema(macdLine, signalLen) hist = macdLine - signalLine // 52-week Position fiftyTwoWeekHigh = request.security(syminfo.tickerid, "D", ta.highest(high, 252)) fiftyTwoWeekLow = request.security(syminfo.tickerid, "D", ta.lowest(low, 252)) fiftyTwoWeekClose = request.security(syminfo.tickerid, "D", close) fiftyTwoWeekRange = fiftyTwoWeekHigh - fiftyTwoWeekLow positionPct = fiftyTwoWeekRange > 0 ? ((fiftyTwoWeekClose - fiftyTwoWeekLow) / fiftyTwoWeekRange) * 100.0 : na // --- TREND / REGIME FILTERS --- // Hang Seng Market Regime Filter (v1.48) hsiClose = useHsiRegimeFilter ? request.security(hsiSymbol, "D", close) : na hsiFastEma = useHsiRegimeFilter ? request.security(hsiSymbol, "D", ta.ema(close, hsiFastEmaLen)) : na hsiSlowEma = useHsiRegimeFilter ? request.security(hsiSymbol, "D", ta.ema(close, hsiSlowEmaLen)) : na hsiFastSlopeUp = useHsiRegimeFilter ? request.security(hsiSymbol, "D", ta.ema(close, hsiFastEmaLen) > ta.ema(close, hsiFastEmaLen)[hsiSlopeLookback]) : bool(na) hsiRegimeBull = hsiClose > hsiSlowEma and hsiFastEma > hsiSlowEma and hsiFastSlopeUp hsiRegimeOk = not useHsiRegimeFilter or na(hsiClose) or na(hsiFastEma) or na(hsiSlowEma) or (hsiFastSlopeUp != true and hsiFastSlopeUp != false) or hsiRegimeBull hsiRegimeBlocked = useHsiRegimeFilter and not hsiRegimeOk // Combined entry permission downtrendBlocked = not hsiRegimeOk // MACD events prevIsHighest = macdLine[1] >= ta.highest(macdLine, 10)[1] prevIsLowest = macdLine[1] <= ta.lowest(macdLine, 10)[1] highEvent = prevIsHighest and (macdLine < macdLine[1]) and (macdLine[1] > signalLine[1]) and (hist[1] > 0) lowEvent = prevIsLowest and (macdLine > macdLine[1]) and (macdLine[1] < signalLine[1]) and (hist[1] < 0) var bool anyLongOpenPrev = false var bool trailingBuyTrigger = false var bool trailBuyArmed = false var float trailBuyLow = na // TRAILING ENTRY (BUY): arm on MACD Lowest, track the running lowest price, // then buy once price has risen trailingBuyRisePct% off the trough. trailingBuyTrigger := false if timeCondition if lowEvent trailBuyArmed := true trailBuyLow := close if trailBuyArmed and useTrailingEntryBuy if close < trailBuyLow trailBuyLow := close trailingBuyTrigger := close >= trailBuyLow * (1 + trailingBuyRisePct / 100.0) eventOkBuy = useTrailingEntryBuy ? trailingBuyTrigger : lowEvent eventOkSell = highEvent // Track last buy time (Minimum Days between Buys) var int lastBuyTime = na var int nextAllowedBuyTime = na enoughDaysSinceLastBuy = na(lastBuyTime) or (time - lastBuyTime >= minDaysBetweenBuys * 86400000) lossPauseOk = not useLossExit or na(nextAllowedBuyTime) or (time >= nextAllowedBuyTime) positionOk = not usePositionFilter or na(positionPct) or positionPct < positionLessThanPct buySignal = timeCondition and eventOkBuy and enoughDaysSinceLastBuy and lossPauseOk and positionOk and not downtrendBlocked uptrendBuy = macdLine > 0 and signalLine > 0 // --- PER-LEG STATE --- var bool leg1Open = false var bool leg2Open = false var bool leg1UptrendBuy = false var bool leg2UptrendBuy = false var float leg1Price = na var float leg2Price = na var int leg1BarIndex = na var int leg2BarIndex = na var int leg1Time = na var int leg2Time = na var label leg1Label = na var label leg2Label = na var float leg1MaxProfit = na var float leg2MaxProfit = na var bool leg1TrailingArmed = false var bool leg2TrailingArmed = false var float leg1TrailingTriggerPrice = na var float leg2TrailingTriggerPrice = na // --- ENTRIES --- if buySignal string uptrendTag = uptrendBuy ? " (Uptrend Buy)" : "" string positionSuffix = na(positionPct) ? "" : " (Position: " + str.format("{0,number,0}", positionPct) + "%)" string blockedReason = "" if hsiRegimeBlocked blockedReason += "HSI Regime " if not leg1Open strategy.entry("Long_1", strategy.long, alert_message="BUY Triggered @ $" + str.format("{0,number,0.00}", close) + " (Leg 1)" + positionSuffix + featureSuffix) leg1Open := true if useTrailingEntryBuy trailBuyArmed := false // consume trailing-entry arm once a leg actually opens leg1UptrendBuy := uptrendBuy leg1Price := close leg1MaxProfit := 0.0 leg1TrailingArmed := false leg1BarIndex := bar_index leg1Time := time lastBuyTime := time leg1Label := label.new(bar_index, na, "Buy_1\n" + str.format("{0,number,0.00}", leg1Price), xloc=xloc.bar_index, yloc=yloc.abovebar, style=label.style_label_up, color=color.new(color.orange, 0), textcolor=color.white, size=size.normal) else if not leg2Open strategy.entry("Long_2", strategy.long, alert_message="BUY Triggered @ $" + str.format("{0,number,0.00}", close) + " (Leg 2)" + positionSuffix + featureSuffix) leg2Open := true if useTrailingEntryBuy trailBuyArmed := false // consume trailing-entry arm once a leg actually opens leg2UptrendBuy := uptrendBuy leg2Price := close leg2MaxProfit := 0.0 leg2TrailingArmed := false leg2BarIndex := bar_index leg2Time := time lastBuyTime := time leg2Label := label.new(bar_index, na, "Buy_2\n" + str.format("{0,number,0.00}", leg2Price), xloc=xloc.bar_index, yloc=yloc.abovebar, style=label.style_label_up, color=color.new(color.orange, 0), textcolor=color.white, size=size.normal) // --- DECOUPLED STOP LOSS (v1.1, unchanged) --- if timeCondition and useLossExit float leg1ProfitPct = na float leg2ProfitPct = na if leg1Open leg1ProfitPct := ((close - leg1Price) / leg1Price) * 100.0 if leg2Open leg2ProfitPct := ((close - leg2Price) / leg2Price) * 100.0 // Leg 1 stop check if leg1Open and leg1ProfitPct <= -lossPct string positionSuffixSell = na(positionPct) ? "" : " (Position: " + str.format("{0,number,0}", positionPct) + "%)" label.new(bar_index, na, "SL_1\n" + str.format("{0,number,0.00}", close), xloc=xloc.bar_index, yloc=yloc.abovebar, style=label.style_label_down, color=color.new(color.red, 0), textcolor=color.white, size=size.normal) line.new(leg1BarIndex, leg1Price, bar_index, close, xloc=xloc.bar_index, extend=extend.none, color=color.new(color.red, 0), style=line.style_solid, width=2) leg1AgeDaysExit = (time - leg1Time) / 86400000.0 leg1DaysHeld = math.max(1, int(math.round(leg1AgeDaysExit)) + 1) string sell1Alert = "SELL Triggered (Stop Loss) @ $" + str.format("{0,number,0.00}", close) + " (Buy_1 $" + str.format("{0,number,0.00}", leg1Price) + ") (" + str.format("{0,number,0.0}", leg1ProfitPct) + "%) (" + str.tostring(leg1DaysHeld) + " days)" + positionSuffixSell + featureSuffix strategy.close("Long_1", comment="SL_1", alert_message=sell1Alert) if not na(leg1Label) label.set_color(leg1Label, color.new(color.red, 0)) leg1Open := false leg1UptrendBuy := false leg1TrailingArmed := false leg1TrailingTriggerPrice := na nextAllowedBuyTime := time + lossPauseDays * 86400000 // Leg 2 stop check if leg2Open and leg2ProfitPct <= -lossPct string positionSuffixSell2 = na(positionPct) ? "" : " (Position: " + str.format("{0,number,0}", positionPct) + "%)" label.new(bar_index, na, "SL_2\n" + str.format("{0,number,0.00}", close), xloc=xloc.bar_index, yloc=yloc.abovebar, style=label.style_label_down, color=color.new(color.red, 0), textcolor=color.white, size=size.normal) line.new(leg2BarIndex, leg2Price, bar_index, close, xloc=xloc.bar_index, extend=extend.none, color=color.new(color.red, 0), style=line.style_solid, width=2) leg2AgeDaysExit = (time - leg2Time) / 86400000.0 leg2DaysHeld = math.max(1, int(math.round(leg2AgeDaysExit)) + 1) string sell2Alert = "SELL Triggered (Stop Loss) @ $" + str.format("{0,number,0.00}", close) + " (Buy_2 $" + str.format("{0,number,0.00}", leg2Price) + ") (" + str.format("{0,number,0.0}", leg2ProfitPct) + "%) (" + str.tostring(leg2DaysHeld) + " days)" + positionSuffixSell2 + featureSuffix strategy.close("Long_2", comment="SL_2", alert_message=sell2Alert) if not na(leg2Label) label.set_color(leg2Label, color.new(color.red, 0)) leg2Open := false leg2UptrendBuy := false leg2TrailingArmed := false leg2TrailingTriggerPrice := na nextAllowedBuyTime := time + lossPauseDays * 86400000 // --- PROFIT EXITS --- // Exit on highEvent. If Trailing is used, the bare highEvent sell is suppressed // so trailing can own the exit. if (useTrailingExit ? false : highEvent) and timeCondition string positionSuffixSell = na(positionPct) ? "" : " (Position: " + str.format("{0,number,0}", positionPct) + "%)" string exitReason = "Sell" if leg1Open leg1ProfitPct = ((close - leg1Price) / leg1Price) * 100.0 leg1AgeDays = (time - leg1Time) / 86400000.0 float leg1MinProfitPct = leg1UptrendBuy ? minProfitPct * 0.5 : minProfitPct canSellByProfit1 = leg1ProfitPct >= leg1MinProfitPct if canSellByProfit1 label.new(bar_index, na, exitReason + "_1\n" + str.format("{0,number,0.00}", close), xloc=xloc.bar_index, yloc=yloc.abovebar, style=label.style_label_down, color=color.new(color.gray, 0), textcolor=color.white, size=size.normal) line.new(leg1BarIndex, leg1Price, bar_index, close, xloc=xloc.bar_index, extend=extend.none, color=color.new(color.blue, 0), style=line.style_solid, width=2) leg1DaysHeld = math.max(1, int(math.round(leg1AgeDays)) + 1) string sell1Alert = "SELL Triggered (Profit) @ $" + str.format("{0,number,0.00}", close) + " (Buy_1 $" + str.format("{0,number,0.00}", leg1Price) + ") (" + str.format("{0,number,0.0}", leg1ProfitPct) + "%, Min " + str.format("{0,number,0.0}", leg1MinProfitPct) + "%) (" + str.tostring(leg1DaysHeld) + " days)" + positionSuffixSell + featureSuffix strategy.close("Long_1", comment=exitReason + "_1", alert_message=sell1Alert) if not na(leg1Label) label.set_color(leg1Label, color.new(color.blue, 0)) leg1Open := false leg1UptrendBuy := false leg1TrailingArmed := false leg1TrailingTriggerPrice := na if leg2Open leg2ProfitPct = ((close - leg2Price) / leg2Price) * 100.0 leg2AgeDays = (time - leg2Time) / 86400000.0 float leg2MinProfitPct = leg2UptrendBuy ? minProfitPct * 0.5 : minProfitPct canSellByProfit2 = leg2ProfitPct >= leg2MinProfitPct if canSellByProfit2 label.new(bar_index, na, exitReason + "_2\n" + str.format("{0,number,0.00}", close), xloc=xloc.bar_index, yloc=yloc.abovebar, style=label.style_label_down, color=color.new(color.gray, 0), textcolor=color.white, size=size.normal) line.new(leg2BarIndex, leg2Price, bar_index, close, xloc=xloc.bar_index, extend=extend.none, color=color.new(color.blue, 0), style=line.style_solid, width=2) leg2DaysHeld = math.max(1, int(math.round(leg2AgeDays)) + 1) string sell2Alert = "SELL Triggered (Profit) @ $" + str.format("{0,number,0.00}", close) + " (Buy_2 $" + str.format("{0,number,0.00}", leg2Price) + ") (" + str.format("{0,number,0.0}", leg2ProfitPct) + "%, Min " + str.format("{0,number,0.0}", leg2MinProfitPct) + "%) (" + str.tostring(leg2DaysHeld) + " days)" + positionSuffixSell + featureSuffix strategy.close("Long_2", comment=exitReason + "_2", alert_message=sell2Alert) if not na(leg2Label) label.set_color(leg2Label, color.new(color.blue, 0)) leg2Open := false leg2UptrendBuy := false leg2TrailingArmed := false leg2TrailingTriggerPrice := na // --- TRAILING PROFIT EXIT (give-back protection) --- // Arms when a MACD Highest forms AND the open leg already meets its minimum profit. // Once armed, tracks the peak profit; closes leg when profit gives back the set % from peak. if timeCondition and useTrailingExit string positionSuffixSellT = na(positionPct) ? "" : " (Position: " + str.format("{0,number,0}", positionPct) + "%)" float tProfit1 = na float tProfit2 = na if leg1Open tProfit1 := ((close - leg1Price) / leg1Price) * 100.0 float tMin1 = leg1UptrendBuy ? minProfitPct * 0.5 : minProfitPct // Arm: a MACD Highest just formed and the leg already meets min profit if highEvent and tProfit1 >= tMin1 leg1TrailingArmed := true leg1MaxProfit := tProfit1 leg1TrailingTriggerPrice := close if leg1TrailingArmed if tProfit1 > leg1MaxProfit leg1MaxProfit := tProfit1 if tProfit1 <= leg1MaxProfit - trailingGivebackPct label.new(bar_index, na, "Trail_1\n" + str.format("{0,number,0.00}", close), xloc=xloc.bar_index, yloc=yloc.abovebar, style=label.style_label_down, color=color.new(color.purple, 0), textcolor=color.white, size=size.normal) line.new(leg1BarIndex, leg1Price, bar_index, close, xloc=xloc.bar_index, extend=extend.none, color=color.new(color.purple, 0), style=line.style_solid, width=2) string trail1Alert = "SELL Triggered (Trailing) @ $" + str.format("{0,number,0.00}", close) + " (Buy_1 $" + str.format("{0,number,0.00}", leg1Price) + ") (" + str.format("{0,number,0.0}", tProfit1) + "%, Peak " + str.format("{0,number,0.0}", leg1MaxProfit) + "%)" + (na(leg1TrailingTriggerPrice) ? "" : " (Highest $" + str.format("{0,number,0.00}", leg1TrailingTriggerPrice) + ")") + positionSuffixSellT + featureSuffix strategy.close("Long_1", comment="Trail_1", alert_message=trail1Alert) if not na(leg1Label) label.set_color(leg1Label, color.new(color.purple, 0)) leg1Open := false leg1UptrendBuy := false leg1TrailingArmed := false leg1MaxProfit := na leg1TrailingTriggerPrice := na if leg2Open tProfit2 := ((close - leg2Price) / leg2Price) * 100.0 float tMin2 = leg2UptrendBuy ? minProfitPct * 0.5 : minProfitPct if highEvent and tProfit2 >= tMin2 leg2TrailingArmed := true leg2MaxProfit := tProfit2 leg2TrailingTriggerPrice := close if leg2TrailingArmed if tProfit2 > leg2MaxProfit leg2MaxProfit := tProfit2 if tProfit2 <= leg2MaxProfit - trailingGivebackPct label.new(bar_index, na, "Trail_2\n" + str.format("{0,number,0.00}", close), xloc=xloc.bar_index, yloc=yloc.abovebar, style=label.style_label_down, color=color.new(color.purple, 0), textcolor=color.white, size=size.normal) line.new(leg2BarIndex, leg2Price, bar_index, close, xloc=xloc.bar_index, extend=extend.none, color=color.new(color.purple, 0), style=line.style_solid, width=2) string trail2Alert = "SELL Triggered (Trailing) @ $" + str.format("{0,number,0.00}", close) + " (Buy_2 $" + str.format("{0,number,0.00}", leg2Price) + ") (" + str.format("{0,number,0.0}", tProfit2) + "%, Peak " + str.format("{0,number,0.0}", leg2MaxProfit) + "%)" + (na(leg2TrailingTriggerPrice) ? "" : " (Highest $" + str.format("{0,number,0.00}", leg2TrailingTriggerPrice) + ")") + positionSuffixSellT + featureSuffix strategy.close("Long_2", comment="Trail_2", alert_message=trail2Alert) if not na(leg2Label) label.set_color(leg2Label, color.new(color.purple, 0)) leg2Open := false leg2UptrendBuy := false leg2TrailingArmed := false leg2MaxProfit := na leg2TrailingTriggerPrice := na // --- LIVE P/L LABELS --- float leg1ProfitNow = na float leg2ProfitNow = na if leg1Open leg1ProfitNow := ((close - leg1Price) / leg1Price) * 100.0 if leg2Open leg2ProfitNow := ((close - leg2Price) / leg2Price) * 100.0 if leg1Open and not na(leg1Label) label.set_text(leg1Label, "Buy_1\n" + str.format("{0,number,0.00}", leg1Price) + "\n" + str.format("{0,number,0.0}", leg1ProfitNow) + "%") label.set_textcolor(leg1Label, leg1ProfitNow >= 0 ? color.lime : (leg1ProfitNow <= -lossPct ? color.red : color.white)) if leg2Open and not na(leg2Label) label.set_text(leg2Label, "Buy_2\n" + str.format("{0,number,0.00}", leg2Price) + "\n" + str.format("{0,number,0.0}", leg2ProfitNow) + "%") label.set_textcolor(leg2Label, leg2ProfitNow >= 0 ? color.lime : (leg2ProfitNow <= -lossPct ? color.red : color.white)) // Reset flip arms was removed along with Bear/Cow Flip feature anyLongOpenNow = leg1Open or leg2Open anyLongOpenPrev := anyLongOpenNow // --- PLOTS --- hsiRegimeBear = useHsiRegimeFilter and not hsiRegimeOk bgcolor(hsiRegimeBear ? color.new(color.rgb(255, 182, 193), 60) : na, title="HSI Regime Background") // --- INFO TABLE --- var table infoTable = table.new(position.top_right, 2, 7, bgcolor=color.white, border_width=1) if barstate.islast or barstate.isconfirmed table.cell(infoTable, 0, 0, strategyLabel, text_color=color.white, bgcolor=color.gray) table.cell(infoTable, 1, 0, "v1.53", text_color=color.white, bgcolor=color.gray) table.cell(infoTable, 0, 1, "Start Date", text_color=color.blue, bgcolor=color.yellow) table.cell(infoTable, 1, 1, str.format("{0,date,dd-MMM-yyyy}", startDate), text_color=color.blue, bgcolor=color.yellow) // Filter Statuses table.cell(infoTable, 0, 2, "HSI Regime", text_color=useHsiRegimeFilter ? color.green : color.red, bgcolor=color.white) table.cell(infoTable, 1, 2, useHsiRegimeFilter ? (hsiRegimeOk ? "OK" : "BLOCKED") : "OFF", text_color=hsiRegimeOk ? color.green : color.red, bgcolor=color.white) table.cell(infoTable, 0, 3, "Min Profit %", text_color=color.black, bgcolor=color.white) table.cell(infoTable, 1, 3, str.tostring(minProfitPct) + "%", text_color=color.black, bgcolor=color.white) table.cell(infoTable, 0, 4, "Buy_1 Profit", text_color=color.black, bgcolor=color.white) table.cell(infoTable, 1, 4, leg1Open ? str.format("{0,number,0.0}", leg1ProfitNow) + "%" : "-", text_color=color.black, bgcolor=color.white) table.cell(infoTable, 0, 5, "Buy_2 Profit", text_color=color.black, bgcolor=color.white) table.cell(infoTable, 1, 5, leg2Open ? str.format("{0,number,0.0}", leg2ProfitNow) + "%" : "-", text_color=color.black, bgcolor=color.white) table.cell(infoTable, 0, 6, "Loss Pause Until", text_color=color.black, bgcolor=color.white) table.cell(infoTable, 1, 6, (useLossExit and not na(nextAllowedBuyTime)) ? str.format("{0,date,dd-MMM-yyyy}", nextAllowedBuyTime) : "-", text_color=color.black, bgcolor=color.white)