Top-Bottom System (STAR) for BankNifty: Decoded and Verified in Pine
A client's hand-run line-chart pivot system reverse-engineered from spreadsheets into Pine v6 and matched trade for trade.
Two client variants (6-rule stop-and-reverse, 4-rule partial-booking) plus a touch-entry indicator; 27 of 29 and 31 of 38 exact matches against the clients' own Excel backtests, with every mismatch traced to futures rollover splices.

- Rules decoded from client spreadsheets, not assumed
- 27/29 and 31/38 exact matches vs manual backtests
- Booked-at-level fill model reproduces the STAR chain exactly
- Strategy, 4-rule variant and touch-entry indicator delivered
Two clients independently wanted the well-known Top-Bottom System for BankNifty futures coded exactly as they traded it by hand on a daily line chart. The rules had never been written down precisely, so the first job was decoding: a pivot is a close higher or lower than the closes on both sides, confirmed one bar later; a signal is a close crossing the last confirmed level; and, crucially, the trade is booked at the level price rather than the close, which is what makes one exit price equal the next entry price in a continuous chain.
The six-rule variant is always in the market with stop-and-reverse, percentage stops, breakeven after a move in favour, a gap rule and a tighter entry-day stop. The four-rule variant books one of two lots at a fixed gain and lets the second run, exits on the stop without reversing, and books entries at the open on gap days. Each was checked against the client's own spreadsheet: 27 of 29 and 31 of 38 exact trade matches, with the remainder explained by contract-rollover data splices. A third deliverable turned the system into an indicator with intraday touch entries, price labels and dashed TP/SL lines.
The strategy was later deployed as a live dashboard for one of the clients.
How it works
- Client spreadsheet and chat brief are reduced to numbered rules
- Pivots and crosses are computed on daily closes with 1-bar confirmation
- Fills are modelled at the level price to reproduce the chain
- Backtest trades are diffed against the client's sheet row by row
- Strategy, indicator and report are delivered as .txt Pine files
Software and automation are infrastructure, not financial advice. No performance guarantees. Every live system needs staged testing, risk limits, and owner approval.