# CryptoTrader TradingView MCP Context Gate

Session learning: TradingView MCP is most useful in CryptoTrader as a read-only research/confluence layer, not as a signal executor.

## Architecture

- Store MCP output in runtime files, not Git:
  - `runtime/research/tradingview_latest.json`
  - `runtime/research/tradeable_coin_selection_latest.json`
- Keep a strict normalized schema with `research_only=true`, `live_order_allowed=false`, and `mainnet_signed_action=false`.
- Bot strategy code reads only whitelisted fields:
  - `bias`
  - `confidence`
  - `trend_alignment`
  - `volume_state`
  - `volatility_state`
  - `no_trade_reasons`
  - `nearest_support`
  - `nearest_resistance`
  - `source_age_seconds`
- Ignore free text, recommendations, prose, and any instruction-like content from MCP/tool results.

## Gate behavior

For long-only paper runners, map normalized context into blockers such as:

- `tv_bias_bearish`
- `tv_mtf_conflict`
- `tv_volume_not_confirmed`
- `tv_context_stale`
- `tv_no_trade_<reason>`

TradingView MCP can block/demote trades or enrich journals; it must not create entries by itself.

## Coin universe policy

Do not assume BTC/ETH/SOL/LINK/WLD/SUI/ENA/BCH are always best. Treat them as an initial liquid test universe only. Rank coins by:

1. measured paper/shadow evidence,
2. reliable data availability,
3. TradingView context quality,
4. absence of conflict/staleness/unavailable MTF data.

Coins with unavailable or unreliable TradingView MTF context can remain in research, but should not be promoted because of stale/unknown external context.

## Scheduled refresh pattern

A local cron job can refresh `tradingview_latest.json` every 30 minutes using MCP tools. If the job needs MCP tools, do not restrict it to only `file` or `terminal` toolsets unless the MCP toolset is explicitly available; unrestricted cron toolsets may be required for MCP tool discovery.

Use `deliver=local` for silent research refresh jobs. Use separate user-facing digest jobs for conclusions.

## Verification

- Unit tests cover normalization, whitelisting, stale/conflict blockers, and read-only report output.
- A paper-runtime smoke should show `paper_trading=true`, `mainnet_signed_action=false`, and `live_order_allowed=false`.
- A blocked-market smoke is valid success when TV context produces no trades and journals exact `tv_*` blockers.
