State-Based Natural Gas Algo Indicator from a Statement of Work
A Python-and-broker SOW mapped onto a Pine v6 visual and alert layer that emits JSON events for the execution engine.
Weapon-candle state machine for BUY and SELL, five assumptions listed for confirmation, defaults measured gross on 5-minute data and reported as negative, saved on a dedicated layout, and a background-tab TradingView recipe worked out along the way.

- SOW clause-to-code mapping in the README
- JSON alert events for the Python engine
- Negative measured defaults reported up front
- Owner's layout protected by a dedicated layout
A client's statement of work described a state-based natural gas algorithm meant to live in Python with a broker connection. The chart layer was built first as a Pine v6 indicator: it tracks the weapon-candle states for both directions, draws levels and stops, and emits JSON alert() events so the Python engine can act on them. Manual orders, broker sync, partial fills and repricing stay in the engine where they belong.
The README maps every SOW clause to the implementation and lists five assumptions that need the client's confirmation. Defaults were measured honestly on 5-minute futures data: hundreds of trades and a negative point total with the weapon-candle stop, slightly less negative without it, and that was stated before anyone traded it.
The script was saved privately and attached on a new layout so my working layout stayed untouched. Doing that in a background browser tab required a recipe (menu-driven script creation, file-input injection, synthetic paste events) that is now reusable for other hidden-tab TradingView work.
How it works
- Candle state machine evaluates weapon conditions per bar
- Levels, stops and state labels are drawn
- State transitions emit JSON alert events
- Execution engine consumes events and manages orders
Software and automation are infrastructure, not financial advice. No performance guarantees. Every live system needs staged testing, risk limits, and owner approval.