Skip to content

fix: start position shading where price reaches the entry - #62

Merged
cyenite merged 1 commit into
mainfrom
fix/position-entry-shading
Nov 6, 2026
Merged

cyenite merged 1 commit into
mainfrom
fix/position-entry-shading

Conversation

@cyenite

@cyenite cyenite commented Nov 6, 2026

Copy link
Copy Markdown
Owner

The Long and Short Position tools shaded the trade so far from the tool's left edge (the entry anchor's bar). TradingView starts it at the bar where price first touched the entry price. This matches TradingView.

What changed

  • positionOutcome (packages/meridian-charts/src/drawings/tools.ts) finds the first bar from the entry anchor whose range includes the entry price and returns it as start. The stop and target are only checked from that bar on, so a stop touched before the entry no longer closes a trade that never opened.
  • The progress block and the dashed line start at that bar.
  • An entry price never reached in the tool's span shades nothing and shows no P&L, rather than an Open P&L.

Behaviour choices

  • The trade opens whichever side price reaches the entry from (touch, not direction).
  • If the bar that reaches the entry also reaches the stop or target, the trade closes on that bar, with the stop checked first.

Testing

  • New test: a long whose entry is only reached several bars later shades from that bar; one whose entry is never reached shades nothing and shows no P&L.
  • The quantity test's P&L check moved to a fixture whose entry is actually traded (the old long entry at 100 sat on a bar with a low of 104, so it no longer opens).
  • npm test (843 tests) and the typecheck pass. Not yet checked by eye in the running app.

The Long and Short Position tools shaded the trade so far from the
entry anchor's bar. As in TradingView, the trade now opens at the first
bar that trades through the entry price, the stop and target are only
checked from there, and an entry price never reached shades nothing and
shows no P&L.
@cyenite
cyenite merged commit 0464326 into main Nov 6, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant