// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © AI_PIPS //@version=6 indicator("AIPIPS Narrative Timeline", overlay=false, max_labels_count=500) swingLen = input.int(5, "Swing length", minval=1) structureLen = input.int(20, "Structure lookback", minval=5) ph = ta.pivothigh(high, swingLen, swingLen) pl = ta.pivotlow(low, swingLen, swingLen) prevPH = ta.valuewhen(not na(ph), ph, 1) prevPL = ta.valuewhen(not na(pl), pl, 1) sweepHigh = not na(prevPH) and high > prevPH sweepLow = not na(prevPL) and low < prevPL bosUp = close > ta.highest(high[1], structureLen) bosDown = close < ta.lowest(low[1], structureLen) bullFvg = low[1] > high[2] bearFvg = high[1] < low[2] var string[] events = array.new_string() var string[] times = array.new_string() maxEvents = 8 addEvent(text) => array.unshift(events, text) array.unshift(times, str.format("{0,time,HH:mm}", time)) if array.size(events) > maxEvents array.pop(events) array.pop(times) if sweepHigh addEvent("Liquidity grab high") if sweepLow addEvent("Liquidity grab low") if bosUp addEvent("Bullish BOS") if bosDown addEvent("Bearish BOS") if bullFvg addEvent("Bullish FVG") if bearFvg addEvent("Bearish FVG") var table timeline = table.new(position.top_right, 2, maxEvents + 1) if barstate.islastconfirmedhistory table.cell(timeline, 0, 0, "Time", text_color=color.yellow, bgcolor=color.black) table.cell(timeline, 1, 0, "Event", text_color=color.yellow, bgcolor=color.black) for i = 0 to array.size(events) - 1 table.cell(timeline, 0, i + 1, array.get(times, i), text_color=color.gray) table.cell(timeline, 1, i + 1, array.get(events, i), text_color=color.white) plot(0, display=display.none)