Liquidity Gravity Strategy | Weighted Swing-Pool Imbalance by blitz_locked

By blitz_locked

Performance Metrics

Description

Liquidity Gravity StrategyOVERVIEWLiquidity Gravity measures how much untaken swing liquidity sits above price versus below it, and trades toward the heavier side. Every swing high and swing low that price has not yet traded through is treated as a liquidity pool. Each pool pulls on price with a weight, the pulls on each side are added up, and the balance between them (the imbalance, from -1 to +1) drives entries, exits and targets.It is a trend-toward-liquidity strategy. It does not fade sweeps or trade reversals.HOW IT WORKS1. Pools: confirmed swing highs and lows are stored until price trades through them. Swings within a small ATR tolerance of an existing pool join it, so equal highs and lows count as one heavier pool.2. Weight: each pool's pull is (swings sharing it) x exp(-distance / (decay x ATR)) / (1 + age / age scale). Nearby, recent, repeatedly tested pools pull hardest.3. Imbalance: (pull above - pull below) / (pull above + pull below), smoothed with an EMA. Near +1 means almost all the pull is overhead. Near -1 means it is below.4. Entry: a long when the imbalance crosses above the entry threshold, a short when it crosses below the negative threshold. A minimum total pull ignores readings built on very little liquidity, and a cooldown spaces trades after an exit.5. Target: the nearest pool on the heavy side that is at least the minimum reward-to-risk away, capped at a maximum R. If no pool qualifies, an optional fixed-R target is used.6. Stop: a fixed ATR distance, or just beyond the nearest pool behind price.7. Exits: stop, target, optional breakeven, an early exit when the imbalance swings hard the other way, and an optional time stop.8. Sizing: a fixed percentage of equity is risked to the stop, with a cap on total position value.FEATURES- Weighted pool model with distance, age and equal-level weighting- Cross or Level entry modes- Pool-based or ATR stop, pool-based or fixed-R target- Breakeven move, flip exit, time stop and post-exit cooldown- Risk-based position sizing with a leverage cap- Optional EMA trend filter and candle-direction filter- Gravity ribbon: a line that leans toward the heavier side, with a soft cloud back to the price average- Nearest pool lines above and below price- Stop, entry and target lines with shaded risk and reward zones, drawn only while a trade is open- Compact panel: bias, imbalance, distance to the nearest pools, position, net profit, win rate, profit factor, trade count- Candle colouring by imbalance (optional)- Alerts on entriesDEFAULT SETTINGSSwing length 5, equal-level tolerance 0.10 ATR, distance decay 4 ATR, age scale 100 bars, smoothing 3, entry mode Cross, entry threshold 0.30, flip-exit threshold 0.30, minimum pull 0.4, cooldown 10 bars, risk 1% of equity, ATR stop 1.2, minimum reward:risk 1.5, maximum 4, fallback target 1.5R, breakeven at 1.5R, time stop 60 bars. Commission 0.05% and slippage 1 tick are placeholders, so set them to your market.WARNINGS- Pools are inferred from price only. The script has no order-book or stop-order data, so a pool is an assumption about where liquidity might rest, not a confirmed fact.- Swings are confirmed only after the swing length has passed, so pools appear late by design.- Backtest results depend on the symbol, timeframe, loaded history, commission, slippage and fill assumptions. They are not a forecast.- The settings interact, and it is easy to fit them to one chart. Test on data you did not tune on.- The gravity ribbon and imbalance are descriptive tools, not predictions.- In ranging markets the imbalance can flip often, which produces small losses or breakeven trades.- Size and risk settings matter as much as the signals. Do not risk more than you can afford to lose.- This is an educational tool, not financial advice.TIPS- Fewer trades: keep Cross mode, raise the entry threshold, raise the cooldown, or turn on the EMA trend filter.- More trades: lower the entry threshold or minimum pull, or try Level mode (expect more noise).- Decay controls how far the model looks. Lower values focus on nearby pools, higher values let distant pools count.- Longer swing lengths create fewer, more significant pools. Shorter ones give faster but noisier readings.- If trades are skipped, check the minimum reward:risk, since the nearest pool may be too close to be worth the risk.- To hide TradingView's own order labels, untick Signal labels and Trades on chart in the strategy's Style tab.- Compare changes one setting at a time and look at trade count, profit factor and max drawdown together.

Browse all 5,900+ TradingView Pine Script strategies

View on TradingView