> ## Documentation Index
> Fetch the complete documentation index at: https://docs.0xarchive.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Stopped vs profit footprint

> The longs and shorts that closed at each price, split into those stopped out and those taking profit.

<Tabs>
  <Tab title="Cells">
    <Frame caption="BTC on 1-minute bars in the 0xArchive Terminal, 2026-10-18.">
      <img src="https://mintcdn.com/0xarchive-e895b8e7/l5hRmyWMwnibVlyD/images/terminal/examples/stopped-profit-footprint.webp?fit=max&auto=format&n=l5hRmyWMwnibVlyD&q=85&s=a772267dab9457b4fa5c786cca17dfc2" alt="Stopped vs profit footprint on a BTC footprint chart" width="1038" height="664" data-path="images/terminal/examples/stopped-profit-footprint.webp" />
    </Frame>
  </Tab>

  <Tab title="Stacked">
    <Frame caption="BTC on 1-minute bars in the 0xArchive Terminal, 2026-10-18.">
      <img src="https://mintcdn.com/0xarchive-e895b8e7/l5hRmyWMwnibVlyD/images/terminal/examples/stopped-profit-footprint-stacked.webp?fit=max&auto=format&n=l5hRmyWMwnibVlyD&q=85&s=577e530511b52c4a62d4e11a34a15054" alt="Stopped vs profit footprint on a BTC footprint chart, drawn Stacked" width="1038" height="664" data-path="images/terminal/examples/stopped-profit-footprint-stacked.webp" />
    </Frame>
  </Tab>
</Tabs>

<Card title="Open on a chart" icon="chart-candlestick" href="https://terminal.0xarchive.io/?symbol=BTC&interval=1m&scripts=example%3Astopped-profit-footprint" horizontal>
  Load it on BTC 1m in the terminal, then change its settings or open it in the script editor.
</Card>

Who closed at each price, and how: **longs stopped** and **longs taking profit** on the left, the sell side a long closes on, and **shorts taking profit** and **shorts stopped** on the right. Profit taking sits nearest the candle and stops outside it, so a flush shows as the outer lanes lighting up while the inner ones stay quiet, and a calm unwind the other way round.

The chart has it built in: pick **Stopped vs profit** under **Positions** in the chart-type menu. Add it as a script to change it; yours is then a **Script** choice under **Data**.

The two stop lanes are **opposed**: where one side's stops are three times the other's at a price, the footprint marks it, and three in a row run right as a band. The statistics rows under each bar are the four lanes summed.

**Stacked** (the second tab above, under **Shape** in the chart-type menu) draws each price as one bar, as long as its total and split into the lanes' colours, so the mix at a price reads at a glance.

## How it works

Each fill's [`takerWhy`](/terminal/guides/order-flow#why-each-side-traded) says what the taker's position did. `stop_long` and `stop_short` are closes at a loss, or forced by a liquidation or auto-deleveraging; `tp_long` and `tp_short` reduce or close a position in profit. [`plot.footprint`](/terminal/guides/outputs#footprints) declares the four lanes, and `fp.add` in `onTrade` adds each closing fill's size at its price. Opens, flips and settlements are left out.

## Try changing

* Drop the profit lanes to get [Stopped out](/terminal/examples/stopped-out-footprint).
* Use `t.notional` in place of `t.size`, with `measure: 'count'`, to print dollars whatever the chart's unit.

## The script

```ts stopped-profit-footprint.ts theme={"theme":"github-dark"}
// Stops against profit taking, at each price: the longs and the shorts that closed, split by whether
// they were stopped (a loss, a liquidation or auto-deleveraging) or took profit, from each fill's
// `takerWhy`. A long closes by selling and a short by buying, so the long lanes sit on the left and the
// short lanes on the right, profit taking nearest the candle. Stops are opposed: where one side's stops
// are three times the other's at a price, the footprint marks it.
indicator('Stopped vs profit footprint', { overlay: true, shortName: 'Stopped vs profit' });

const tape = trades();
const fp = plot.footprint('Stopped vs profit', {
  lanes: [
    { id: 'longsProfit', label: 'Longs taking profit', side: 'left', color: '#c9a227' },
    { id: 'longsStopped', label: 'Longs stopped', side: 'left', color: color.down },
    { id: 'shortsProfit', label: 'Shorts taking profit', side: 'right', color: '#5b8def' },
    { id: 'shortsStopped', label: 'Shorts stopped', side: 'right', color: color.up },
  ],
  opposed: [{ a: 'longsStopped', b: 'shortsStopped' }],
  stats: ['longsStopped', 'longsProfit', 'shortsProfit', 'shortsStopped'],
});

tape.onTrade((t) => {
  const why = t.takerWhy;
  if (why === 'stop_long') fp.add('longsStopped', t.price, t.size);
  else if (why === 'tp_long') fp.add('longsProfit', t.price, t.size);
  else if (why === 'tp_short') fp.add('shortsProfit', t.price, t.size);
  else if (why === 'stop_short') fp.add('shortsStopped', t.price, t.size);
});
```

## Next step

See the next example, [Opens and closes footprint](/terminal/examples/opens-closes-footprint).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.