1. CISD Liquidity Sweep Strategy Description
Detects order-flow reversals by tracking the opening price of consecutive same-direction "delivery" candle streaks, reinforced with Market Structure Shift and Liquidity Sweep detection to filter reversal quality.
1.1 Indicator Concept
CISD (Change in State of Delivery) is a concept from the Smart Money Concepts / ICT school of trading. The theory states that the market "delivers" price in consecutive same-direction candle streaks: a run of consecutive bullish candles is a "bullish delivery" streak (buyers in control), while a run of consecutive bearish candles is a "bearish delivery" streak (sellers in control).
The core idea: the opening price of the FIRST candle in a delivery streak is the boundary that defines the current state of delivery. When price later closes back through that exact open level in the opposite direction (e.g. after a bearish streak, price closes back ABOVE the open of the first bearish candle), the theory treats this as evidence that the dominant order flow has flipped - the "state of delivery has changed" (CISD confirmed), signaling a possible short-term trend reversal.
- Bullish CISD: forms after a sufficiently long bearish streak. The watched level = the open price of the first candle of that bearish streak. When price closes back above this level → bullish CISD is confirmed.
- Bearish CISD: forms after a sufficiently long bullish streak. The watched level = the open price of the first candle of that bullish streak. When price closes back below this level → bearish CISD is confirmed.
- Difference from a typical Order Block/CHoCH: CISD defines its level mechanically (using the exact open of one specific candle) instead of an order-block range, which makes it easy to code and gives it a clear expiry horizon (maxSeq).
Beyond the CISD core, the indicator also bundles two independent confirmation tools: MSS (Market Structure Shift) - a break of the nearest pivot high/low, and Liquidity Sweep - detecting when price "sweeps" through a swing high/low and then closes back inside (a liquidity trap).
1.2 Indicator Features
-
CISD Lines & Labels:
- Pending Line: faint line (40% opacity), extends from the first candle of the delivery streak to the current bar, showing the level currently being watched.
- Confirmed Line: switches to a solid green (bullish) or red (bearish) line once CISD is confirmed; automatically switches to dashed if it matches the current CISD trend direction.
- "Pending CISD" Label: a floating label offset forward by pendingOffset bars, always tracking the level of the active setup.
- "CISD" Label + Arrow (▲/▼): appears at the moment of confirmation - the "CISD" label sits at the mid-point of the line, the arrow sits at the confirmation candle.
- MSS Dots (optional, default OFF): a small circle above/below the candle when close breaks the nearest pivot high/low - a structural signal independent of CISD.
- Liquidity Sweep Lines: when price wicks through a swing high/low and then closes back inside, the indicator draws a horizontal line at the swing level plus a vertical "wick" segment marking how deep the sweep went.
- Trend Candle Coloring (optional, default OFF): recolors all candles to match the most recently confirmed CISD trend, giving an at-a-glance market bias without reading individual lines.
- 14 Alerts: new setup formed, CISD confirmed, liquidity sweep, MSS, CISD trend shift, setup expired, and candle-color shift - separate for both bullish and bearish directions.
1.3 How to Use the Indicator
- Watch the "Pending CISD" label as a reaction level: this is the key price - if price returns and closes through it, a reversal signal in the CISD's direction is confirmed.
- Enter when CISD confirms: when the line turns solid + the "CISD" label and arrow appear, this is a BUY signal (bullish CISD) or SELL signal (bearish CISD).
- Set Stop Loss: place SL just outside the confirmed CISD level (below it for longs, above it for shorts) - if price closes back through that level again, the setup is considered invalidated.
- Filter with MSS: enable "Show MSS Dots" to require an independent market structure confirmation before trusting a CISD signal, reducing noise.
- Filter traps with Sweeps: if a liquidity sweep line appears right before a CISD setup, it's a sign liquidity was genuinely taken before the reversal - adding confidence to the upcoming CISD.
- Tune sensitivity via minDelivery/minSeq/maxSeq: increase "Minimum Delivery Candles" to only catch long, strong delivery streaks; increase "Minimum CISD Duration" to filter confirmations that arrive too fast/noisy; decrease "Maximum CISD Validity" to keep only setups that are still "fresh", avoiding trades on stale levels.
- Enable candle coloring for a quick read of current bias (between two consecutive CISD confirmations) when scanning multiple charts.
1.4 How the Indicator Works
Inputs & Roles
- minDelivery (Integer, default: 3): minimum number of consecutive same-direction candles (delivery streak) required before a CISD setup is created. Example: minDelivery=3 means exactly 3 consecutive bearish candles are needed before a bullish CISD setup is created (watching the open of the first bearish candle). Increase → only catches long/strong delivery streaks, fewer but higher-quality setups. Decrease → more setups but noisier.
- maxSeq (Integer, default: 100): maximum number of bars a setup is allowed to remain pending before it's deleted and counted as "expired". Example: setup created at bar 500, maxSeq=100 → if still unconfirmed by bar 600, the line and label are deleted, and the "CISD Expired" alert fires. Increase → setups persist longer, catching slower reversals but the level may already be stale. Decrease → only keeps setups that are still "hot".
- minSeq (Integer, default: 1): minimum number of bars that must pass between setup creation and when it's allowed to confirm. Example: minSeq=1 → cannot confirm on the very bar the setup was created, must wait at least 1 bar. Increase → filters out instant/noisy confirmations. 0 → allows immediate confirmation.
- labelSizeInput / arrowSizeInput (Dropdown, default: Small / Normal): text size of the "CISD" label and the ▲/▼ confirmation arrow. Display only, no effect on detection logic.
- cBull, cBear (Color, default: green #089981 / red #f23645): color of the CISD line, label, and arrow for each direction.
- cisdWidth (Integer 1-5, default: 2): line width for CISD lines, applied to both pending and confirmed states.
- showPendingLabel (Boolean, default: true) / pendingOffset (Integer, default: 2): whether to show the "Pending CISD" label, and how many bars ahead of the current bar it is offset. Example: pendingOffset=2, current bar is 500 → label sits at position 502.
- showMSS (Boolean, default: false) / mssLen (Integer, default: 3): show/hide MSS dots, and the pivot length (bars on each side) used to confirm the high/low used as the MSS reference level. Increase mssLen → rarer but "stronger" pivots, fewer MSS dots. Decrease → more dots but noisier.
- cMSS (Color, default: gray #787b86): color of the MSS dots.
- showSweeps (Boolean, default: true) / swingLen (Integer, default: 10): show/hide liquidity sweep lines, and the pivot length used to identify swing highs/lows used as the sweep reference level. Note: this swing confirms 1 bar earlier than a standard pivot (right offset = 1) to stay closer to real time.
- cSweepH, cSweepL (Color, default: translucent gray #787b8684): color of the bearish sweep line (above a high) / bullish sweep line (below a low).
- sweepWidth (Integer 1-5, default: 1) / sweepWickWidth (Integer 1-20, default: 10): width of the horizontal sweep-level segment, and width of the vertical "wick" segment marking how deep price pierced through the level.
- colorCandles (Boolean, default: false) / bullCandle, bearCandle (Color): enable/disable candle coloring by CISD trend, and the color used for each direction. While trend has not yet had any confirmed CISD (trend = 0), candles keep their default color (not recolored).
Main Logic Blocks
🎯 Flow 1: Candle Delivery Engine (foundation)
- Every candle is classified as bull = close > open or bear = close < open.
- If it's a bullish candle and the previous candle was NOT bullish → this is the FIRST candle of a new bullish streak: save bullDeliveryOpen = this candle's open, bullDeliveryStart = its bar position, bullSeq = 1, and reset bearSeq = 0. If the previous candle was also bullish → just increment bullSeq (continue counting the streak), keeping the original bullDeliveryOpen. Symmetric logic applies to a bearish streak. A doji candle (open = close) resets both streaks to 0.
- Example: 5 consecutive bullish closes starting at bar 120 with open = 1.2500. Throughout the streak, bullDeliveryOpen stays at 1.2500, bullDeliveryStart = 120, while bullSeq climbs 1 → 2 → 3 → 4 → 5 across each candle.
🎯 Flow 2: Create New CISD Setup
- newBullSetup = bearSeq >= minDelivery: the current bearish streak just reached the minimum required length → delete the old Bull setup (if any) and create a new one with level = bearDeliveryOpen (open of the first candle of that bearish streak), x1 = bearDeliveryStart, draw a faint CISD line from x1 to now, create the "Pending CISD" label (if enabled).
- newBearSetup = bullSeq >= minDelivery: symmetric, creates a Bear setup with level = bullDeliveryOpen.
- Example: minDelivery = 3. A 3-candle bearish streak begins with open = 1.2600 at bar 200. At bar 202 (the 3rd bearish candle), bearSeq = 3 ≥ 3 → newBullSetup = true → a Bull setup is created: level = 1.2600, x1 = 200, CISD line drawn from bar 200 to 202, Pending CISD label shows price 1.2600 at position 202 + pendingOffset.
🎯 Flow 3: Update, Confirm & Expire Setup
- Every bar, if the setup is still within its validity window (bars elapsed since x1 ≤ maxSeq): extend the CISD line to the current bar and refresh the Pending label's position/value.
- Confirmation condition: bullConfirm = Bull setup is active, close > level, AND at least minSeq bars have elapsed since x1 (bearConfirm symmetric). When true: line turns solid (dashed if it matches the current trend direction), draws the "CISD" label + confirmation arrow, deletes the Pending label, updates trend = +1 (or -1), and deactivates the setup (considered complete).
- Expiry condition: if bars elapsed since x1 > maxSeq without confirmation → delete the line and Pending label, deactivate, fire a separate "CISD Expired" alert.
- Example: level = 1.2600, minSeq = 1, maxSeq = 100. At bar 210, close = 1.2615 > 1.2600 and 210 - 200 = 10 ≥ 1 → bullConfirm = true → bullish CISD confirmed, trend becomes +1. If bar 301 arrives (301 - 200 = 101 > 100) and price still hasn't closed above 1.2600 → the setup expires and is removed from the chart.
🎯 Flow 4: MSS Detection (independent, parallel)
- Tracks symmetric pivot highs/lows (mssLen bars each side) → updates lastMssHigh / lastMssLow whenever a new pivot confirms.
- bullMSS: current close > lastMssHigh while the previous candle's close was still ≤ lastMssHigh (the first cross above) → a circle appears below the candle. bearMSS is symmetric, circle appears above the candle.
- Example: mssLen = 3, lastMssHigh = 1.2700 (pivot confirmed after 3 bars each side). If close[1] = 1.2695 (≤ 1.2700) and the current close = 1.2705 (> 1.2700) → bullMSS = true → the circle appears.
🎯 Flow 5: Liquidity Sweep Detection (independent, parallel)
- Tracks swing highs/lows (swingLen bars, confirming 1 bar earlier than a standard pivot) → holds them in swingHigh / swingLow.
- bearSweep: the current candle's high > swingHigh (price wicked above the swing high) BUT close < swingHigh (closed back below it) → counted as a sweep of the swing high → draws a horizontal line at swingHigh (from the swing position to now) plus a vertical wick segment up to the actual high. bullSweep is symmetric for a swing low.
- Once price genuinely closes past a swingHigh/swingLow (not just a wick), that swing level is removed from tracking - it's then considered a true structural break, no longer counted as "swept".
- Example: swingLen = 10, swingHigh = 1.2750 (confirmed at bar 189, tracked from bar 190). At bar 250: high = 1.2760 (> 1.2750) but close = 1.2740 (< 1.2750) → bearSweep = true → draws a horizontal line at 1.2750 from bar 189 to 250, plus a vertical wick segment from 1.2750 up to 1.2760.
🎨 Flow 6: Trend Candle Coloring (optional)
- If colorCandles = true: candle color = bullCandle when trend = +1, bearCandle when trend = -1, keeps default (unpainted) when trend = 0 (no CISD has ever confirmed yet). Applied to both barcolor() and plotcandle() simultaneously to work with both TradingView candle display modes.
🔔 Flow 7: Trigger Alerts (14 alerts)
- New Bullish/Bearish CISD Setup: the moment newBullSetup/newBearSetup = true (when the setup is first created).
- Bullish/Bearish CISD Confirmed: when bullConfirm/bearConfirm = true.
- Bullish/Bearish Liquidity Sweep: when bullSweep/bearSweep = true.
- Bullish/Bearish MSS: when bullMSS/bearMSS = true.
- Bullish/Bearish CISD Trend Shift: when a CISD just confirmed AND the previous bar's trend pointed the other way - i.e. a genuine reversal, not just another confirmation in the same direction as the existing trend.
- Bullish/Bearish CISD Expired: when bullExpired/bearExpired = true.
- Candle Color Shift Bullish/Bearish: when colorCandles is enabled and trend just flipped direction - a separate scope dedicated to the candle-coloring feature.
Outputs & Usage Roles
- CISD lines & labels (pending + confirmed): the key price level to watch and use for entry decisions under CISD theory.
- ▲/▼ confirmation arrows: pinpoint the exact candle where a reversal was confirmed, used as the anchor for placing Stop Loss (just outside the CISD level).
- MSS dots: an independent structural confirmation, used as a confluence filter before trusting a CISD signal.
- Liquidity sweep lines: warn of a liquidity trap, helping avoid entries before liquidity has genuinely been taken ahead of a reversal.
- Trend candle coloring: gives a quick read of current bias (between two consecutive CISD confirmations) without reading individual lines on the chart.
- 14 alerts: automate monitoring of a setup's full lifecycle (creation → confirmation/expiry) plus supporting signals (MSS, sweep), without staring at the chart.


