BASEtrading knowledge base
RU

The core of the S0 / s01 system

Segments сегмент · segment chain

A segment is one “floor” on the price staircase. When price climbs the whole floor, we take the profit and look for the next one.

A corridor 8·STEP high from the anchor S0 with fixed KEY, STOP, PARTIAL and TARGET levels. Close-based segments form a chain, a zigzag on the STEP grid.

⟳ being refined

Price jiggles all the time. To keep our heads straight, we split its path into equal “floors” and only watch which floor it has passed.

Picture an elevator in a tall building. Tracking every centimetre is boring and useless. It's easier to split the building into floors of the same height.

The height of one step is called STEP. One floor, a segment, is 8 of these steps.

How price goes through one floor

Segment diagram: floor S0, stop, KEY entry, PARTIAL half, TARGET 🏁 Ceiling · 8 steps ½ Take half · 6 🚪 Entry · 3 steps 🛑 Wrong, get out Floor · start
Price (the black line) starts from the “floor” and climbs 3 steps: we get in. At step 6 we take half, at step 8 we take the rest. Floor done.
  1. Mark the floor. The point where the floor starts is called S0 (“S-zero”).
  2. Wait for proof. Price has gone up 3 steps (KEY), so the elevator really is going up. We hop on.
  3. Play it safe. If price drops almost back to the floor (the STOP level), we get out. A small loss beats a big one.
  4. Take half. At step 6 (PARTIAL) we pocket half the win: even if something goes wrong later, part of it is already ours.
  5. Floor done. At step 8 (TARGET) we take everything and start looking for the next floor.

What if the elevator goes down? If price falls 3 steps from the highest point it reached, it has changed its mind. A new segment starts, this time going down. Everything works the same, just mirrored: we make money on the fall.

Why we only look at the “close”

On a chart, price is drawn as candles: each candle is a slice of time, say 5 minutes. During those 5 minutes price can dart up and down. We only look at where it ended up (that's called the close). This way the system ignores random twitches.

A chain of floors

Segments come one after another: finish a floor, start the next; turn around, go down. You get a chain of segments that looks like a staircase. It shows right away where the market really went and how far, without the noise.

The “Two chains” tab: coloured up and down segment bars over a price chart
A real screen from our Lab: the coloured bars are segments going up (green) and down (red). Two chains at once: one with a small step and one with a big step.

Honestly: segments are great at showing what the market is doing. But on their own they don't guarantee profit: tests on past data showed that after exchange fees there's no gain so far. That's why they get “helpers”: DH and the golden trend.

Definition

A segment is a price corridor 8·STEP tall, running one way from the anchor point S0: up for LONG, down for SHORT. Levels inside the corridor sit at fixed distances from S0 and are not recalculated from the actual fill price. All decisions are made on candle close only: wicks and candle colour are not used.

8·STEPsegment height
3·STEPKEY — activation / entry
1.5·STEPeffective stop (2 − 0.5 buffer)
≈ 1 mediancandle range — a typical STEP

Levels

LevelLONGSHORTRole
KEYS0 + 3·STEPS0 − 3·STEPa close at or beyond KEY activates the segment (equality counts)
STOPS0 + 2·STEPS0 − 2·STEPstop level
Buffered STOPS0 + 1.5·STEPS0 − 1.5·STEPa close at or beyond it closes the position (0.5·STEP buffer)
PARTIALS0 + 6·STEPS0 − 6·STEPclose 50% of size, once per segment
TARGETS0 + 8·STEPS0 − 8·STEPclose the remainder; end of segment

Trade risk from KEY to the buffered stop ≈ 1.5·STEP. Results are measured in R = points / STEP.

BTCUSDT 5m: LONG segment #60 with labelled S0, STOP, buffer, KEY, PARTIAL, TARGET and opposite KEY levels
BTCUSDT 5m, STEP 400, segment #60 LONG (cryptotrader, DH filter page). S0 78,851.6 → KEY 80,051.6 → PARTIAL 81,251.6 → TARGET 82,051.6. Entry 80,059.3, exit on the buffered stop at 79,429.2: −630.1 pts = −1.58 R.

State machine (Core v2)

  1. Waiting. No direction; both KEYs are live: S0 ± 3·STEP. The first close beyond either one sets the direction.
  2. Active segment. On every close, the run's close extreme is updated (MAX for LONG, MIN for SHORT). Checks in order: GAP_STOP → STOP → GAP (gap through TARGET) → PARTIAL → REVERSAL → TARGET.
  3. Reversal (opposite KEY). A LONG reverses if close ≤ MAX − 3·STEP (SHORT: close ≥ MIN + 3·STEP). The opposite segment opens on the same close with S0 = the extreme.
  4. Aiming after TARGET / STOP. The deviation dev = trunc((close − A)/STEP) accumulates into U (up) and D (down), with a budget U + D ≤ 2. Keys: Klong = A + (3 − D)·STEP, Kshort = A − (3 − U)·STEP. New segment: S0 = K ∓ 3·STEP. Anchor A = TARGET after a target hit, or the close extreme after a stop.
  5. Glue (GLUE). If price gaps through both KEY and TARGET, the segment stays in the chain without a trade, and the next one is glued on with S0 = its TARGET (an 8·STEP step).

Initial S0

find_s0_starting: the window is the first 70 candles, the reference close is the 71st. It takes the window's absolute High and Low (refined by the open/close of ±1 neighbours). S0 is whichever is farther from the reference close. Low → LONG, High → SHORT.

Two implementations: where they differ

RuleCore v2 — cryptotrader s0/base/core.py“New stop” — mamba s01/aimcore
Check orderGAP_STOP → STOP → GAP → PARTIAL → REVERSAL → TARGETPARTIAL → REVERSAL → TARGET → STOP
STOP after PARTIALdoes not firecloses the remainder
TARGET exit pricecandle closeTARGET level
After STOPsingle anchor — close extreme, U + D ≤ 2two S0s from the segment's candle bodies (low and high)
After TARGETanchor A = TARGETtwo S0s from the TARGET candle body (#219–#225) ⟳
P&Lpoints% and R
Tradesonetechnical and real (the real one only if ≥ 2·STEP remains to PARTIAL)

On historical data: same exit in 73% of segments (#143, 25 Oct), 60% after #372; 79% identical trades. Since 31 Oct, cryptotrader /s0/ also shows “New stop” by default; Core v2 is available via ?e=core.

Timeline

DateWhat changed
21 Sep 2026Author's Core v2, P&L in points
1 Oct“Lab 01.10”: technical + real trade, aiming with S0 = K ∓ 3·STEP
13 OctOwner's edits #107–#118: reversal on the same close, GLUE, 0 gap stops (was 86)
27 Oct“New stop” (#201–#214): two S0s after STOP. RTS: stops 71 → 108, reversals 83 → 36
29 Octaimcore becomes the engine for all s01 chains (#263)
30 Oct#372: dropped the “opposite key strictly beyond the entry key” condition, MIX 1,257 → 1,325 segments

Two chains

One chart carries a small chain (the working chain's STEP, “STEP S”) and a large one (“STEP M” — the calibrator's best large-range candidate or Andrey's STEP). Both are built by the same engine from the same S0, overlaid with the golden trend M5/H1 and DH. MIX example: small STEP 250 gives 381 segments, large STEP 675 gives 64.

The “Two chains” tab on RTS with the M5 and H1 golden trend
mamba Lab, “Two chains”, RTS: small and large chains, golden trend M5/H1, DH S at the bottom.

What the tests showed

  • The chain reproduces exactly, but there is no stable edge (cryptotrader, “Segments” stage, 13–18 Oct 2026). A volatility-phase filter over 18,681 trades produced no profit.
  • BTC 15m since 2021: edge per trade 0.007–0.017% of price vs 0.04–0.11% commission — every variant is negative after fees.
  • 4H segment as a 5m/15m filter: the only positive is BCH 15m, +6.57 USDT over 83 trades.
  • Direction after a DH “star” on the M5 chain: 299 stars, side called right in 49–57% of cases — coin-flip level.

The projects' conclusion: segments are a precise “ruler” of movement, and the edge is sought in which segment to take: DH filters, the golden trend, trend age.

Sources in the projects (9)
  • cryptotrader/s0/base/core.py — Core v2: level constants, calc_levels (l. 75), chain_segments (l. 127)
  • cryptotrader/src/algorithms.html — walkthrough of the segment and STEP algorithm, SVG diagram, level calculator
  • cryptotrader/docs/SEGMENTS.md — results of the “Segments” stage, 13–18 Oct 2026
  • cryptotrader/s0/README.md — owner's fixes #107–#118, service, journal
  • mamba/lab/platform/s01/aimcore/core.py — SegmentEngine.advance_chain — the s01 “New stop” engine
  • mamba/lab/platform/s01/aimcore/GEOMETRY_RULES.md — current geometry rules
  • mamba/lab/platform/s01/twochains.py — “Two chains”: small and large
  • mamba/PLAN.md — log: #143 engine comparison, #201–#214 “New stop”, #372
  • mamba/lab/research/Segment_Profiling/ — segment outcome types (TARGET_EXT, REV, STOP…)