Episode 8 · AI Trading · Building a Complete Trading System

A prompt library for traders: nine cards with safety labels

Nine versioned prompt cards for charts, news, journals, specs, Pine, MQL5, backtests, calendars and stress tests, each labelled by what a mistake can touch.

A prompt card is a ready-made prompt built on the five-part frame (role, data, constraints, output, check). Placeholders are in CAPITALS inside square brackets, like [SYMBOL] or [YYYY-MM-DD HH:MM]. Fill in every one before sending: anything left blank invites the model to invent something to fill it. Square brackets that hold a number in code, like Pine’s close[1], are syntax; leave them alone.

Two parts must never be deleted to save space: the constraints, which give each rule with its reason (the model generalises better from a reason than from a bare ban), and the check, which is where you catch an unsourced price, a sentence without a quote or a lot size rounded up.

Cards that produce a view (1 chart, 2 news, 7 backtest) end with the 3-line tail: what would prove the view wrong, the three biggest risks, and “This is analysis, not an order.” The others write specs or code (4, 5, 6) or score against rules and compute numbers (3, 8, 9), so they don’t need it. The task always goes last, after the data.

The nine cards and their safety labels

Card File When What you feed it Safety label
1 · Chart description prompts/chart-v1.md Before the session Chart screenshot, last close read on the platform, candle CSV if you have it TEXT ONLY; LICENCE if from TradingView
2 · Macro news summary prompts/macro-news-v1.md Before the session Full text of the release, with source and time TEXT ONLY · LICENCE
3 · Journal discipline score prompts/journal-v1.md After the session, weekend Your demo trade journal CSV and your trading plan TEXT ONLY
4 · Idea to spec prompts/spec-v1.md Building tools The idea in words TEXT ONLY
5 · Pine v6 indicator prompts/pine-indicator-v1.md Building tools Indicator requirements and parameters RUNS CODE · LICENCE
6 · MQL5 EA for backtest and demo prompts/ea-mql5-v1.md Building tools The approved spec from card 4 RUNS CODE · CAN PLACE ORDERS
7 · Backtest report review prompts/backtest-review-v1.md After a test The metrics table and test conditions TEXT ONLY; LICENCE if a TradingView report
8 · Economic calendar cross-check prompts/calendar-v1.md Before the week, before the session A third-party calendar plus rows from the official pages, with URLs and times TEXT ONLY
9 · Demo account stress test prompts/stress-test-v1.md Before holding through news or a weekend Open demo positions, balance, daily loss cap; scenarios from your candle file TEXT ONLY; the helper script RUNS CODE (read-only)

The label sits in the first line of each card file and tells you how far a mistake can reach:

  • TEXT ONLY: text, images and CSVs in, text out; nothing runs on your machine. Numbers used for decisions still get checked by you, such as the lot in card 4 or a news time in card 8.
  • RUNS CODE: the output is code that will run: Pine on TradingView (card 5), an EA in MT5 (card 6), the stress-test script (card 9). Read it first, run it on sample data or demo.
  • NEEDS KEY: the card needs an API key or a login to a data service. None of the nine does today, because you paste the data. If you change a card to fetch data through MCP or an API, add this label, store the key properly and vet the tool before installing it.
  • CAN PLACE ORDERS: the generated code calls an order function (card 6). The card forces the EA to send orders only in the Strategy Tester or on a demo account, and only when an order switch is on (off by default). An EA does not ask before each order: with the switch on, it sends on its own. So switch it on only in the Strategy Tester; on a demo chart, leave it off and the EA only prints signals in the Experts tab. Never attach an EA to a live account.
  • LICENCE: terms to read before giving the data to an AI, republishing it or sharing the output. Republishing a press release verbatim depends on the source’s terms (card 2). Published Pine scripts must follow TradingView’s House Rules and publishing rules or get hidden; open-source scripts default to the Mozilla Public License 2.0, so reusing someone’s open code means crediting the author, improving it meaningfully and keeping it open unless the author allows otherwise. A script just for you doesn’t need publishing: save it in the Pine Editor and Add to chart. “Private” published scripts are still visible to anyone with the URL. TradingView licenses its charts and data for display; using them for machine processing, including training or testing AI models, is not allowed, with one exception for your own AI app reading data through TradingView’s MCP server to answer you. Sending screenshots or Metrics tables to an AI chat is not addressed, so treat it as a grey area. Hence the short rule: for card 1 prefer an MT5 demo chart or a replay you own, for card 7 prefer the MT5 Strategy Tester report.

If you edit a card and give it a new capability (fetching data via an API, for example), add the label in the new version. Never put API keys, passwords or account numbers in a card file: it gets committed to Git and pasted verbatim into AI conversations.

Store the library and call cards from an agent

Each card is a plain .md file saved as UTF-8. The first line is the change line: name · date · what changed · why · safety label. Never edit a card in place. Copy it to -v2, edit the copy, write the reason in the first line, and commit. Record which card version produced each result (in the notes column of your journal, for example); prompt versions are a parameter to track, like strategy parameters.

cd C:\trading-agent-lab
mkdir prompts
notepad prompts\chart-v1.md            # Yes to create; paste; Ctrl+S; status bar must say UTF-8
ls prompts
Copy-Item prompts\chart-v1.md prompts\chart-v2.md
notepad prompts\chart-v2.md
git add prompts
git commit -m "prompts: chart-v2 requires a source for every level"
cd ~/trading-agent-lab
mkdir -p prompts
touch prompts/chart-v1.md && open -e prompts/chart-v1.md   # Format → Make Plain Text
cp prompts/chart-v1.md prompts/chart-v2.md

With an AI chat (training switched off): open the file, select all, copy, paste, fill in the blanks, attach the image or CSV, send.

In Claude Code, @ attaches a file and puts its contents straight into the conversation, so you don’t paste CSVs by hand. A file is only included if it fits the read limit (25,000 tokens by default), and text files over 256 KB are not included at all; filter a long journal by date before exporting. Run claude from the project folder and use Plan mode for read-only work such as scoring a journal:

claude --permission-mode plan
Follow the card @prompts/journal-v1.md.
Take [PASTE THE CSV...] from @data/trade-journal-2026-11-11.csv,
and [PASTE YOUR RULES...] from @journal/plan.md.
Read only; don't edit files.

Files attached with @ don’t pass through PreToolUse hooks, because no tool call runs. To keep secrets such as .env out for sure, use a deny rule for Read: Claude Code won’t attach files matching it. Never @ a file that holds keys or passwords. Codex CLI and other agents can read project files too; name the path in the request (“Read prompts/journal-v1.md and follow it; the data is in data/”).

You see Why Fix
Cannot find path 'C:\trading-agent-lab' Folder missing or misspelt Check the name; recreate the project skeleton
ls prompts shows chart-v1.md.txt Saved with .txt Rename-Item prompts\chart-v1.md.txt chart-v1.md
Accented text turns to junk Not saved as UTF-8 Save as again with Encoding UTF-8
@ doesn’t list the file Claude Code runs in another folder Exit, pwd, cd into the project, rerun claude

Card 1 · Chart description

Turns a chart image into an objective description, keeping what is visible apart from what is guessed. It never asks whether to buy or sell. Locating things in an image is approximate, and models can misread or invent details in low-quality, rotated or very small images, so every level carries “estimate from image” and a confidence, and prices for a stop or a lot size come from the numbers you paste. Attach the image before the text: models do best with the image first.

# chart-v1 · [DATE] · first version · label: TEXT ONLY; LICENCE if TradingView data
<role>You describe charts objectively for a beginner. You don't predict and don't recommend.</role>
<data>
Attached image above: [SYMBOL], timeframe [TF]; last candle on the image: [YYYY-MM-DD HH:MM UTC].
On the chart: [INDICATORS, e.g. EMA50 in blue].
Close of the last closed candle, read on the platform: [PRICE].
CSV of the latest closed candles (time, open, high, low, close; time zone [TZ]):
[PASTE CSV OR WRITE "NONE"]
</data>
<constraints>
Decision time: [YYYY-MM-DD HH:MM] (UTC). Use only data up to this time; don't infer anything after it.
Prices read from the image are estimates. Exact levels come from the price I pasted or the CSV.
No buy/sell orders. Don't say which scenario will happen, because nobody knows in advance.
</constraints>
<output>4 numbered items following the task. Levels as a table: level | source | confidence.
Then the 3-line tail: what would prove item 1 wrong (a level or candle checkable on the chart);
the 3 biggest risks, each citing a candle or data, or NOT ENOUGH DATA;
last line verbatim: This is analysis, not an order.</output>
<check>Before answering: add a source or confidence to any level missing one;
delete any sentence that predicts or advises; confirm the 3-line tail is there.</check>
<task>
1. Describe what you can SEE: trend, nearby highs and lows, the busiest price zone.
2. For each level: source ("estimate from image" or "CSV row ...") and confidence (high, medium, low).
3. Two scenarios (up, down), each with a confirmation and an invalidation condition checkable
   on the chart, e.g. "a [TF] candle closes above ...".
4. List what the image can't tell you: upcoming news, higher timeframes, real volume...
</task>

Before reading the answer, check it: every level has a source and confidence, exactly two scenarios with checkable conditions, no buy/sell or “will definitely”, and the full tail. If anything is missing, run it again. Then replay a few more candles and judge whether the conditions were clear enough to check.

Card 2 · Macro news, only from what you paste

A chat model without web search may invent content and numbers if you ask “how did the Fed news go yesterday”. So each document is pasted inside its own tag with its source and publication time; the model quotes first, tags every summary sentence with a document number, and deletes any sentence it can’t support. Forecasts not in the text come back as “not in document”; otherwise the model tends to supply a “market forecast” from memory.

Convert times by the actual date. US statistics releases are in US Eastern time: October 2026 CPI came out at 8:30 a.m. ET on Tuesday 10 November 2026. Mid-November the US East is on standard time (UTC−5), so that’s 13:30 UTC; in US summer time (UTC−4) the same 8:30 ET is 12:30 UTC. Don’t use times from memory.

# macro-news-v1 · [DATE] · first version · label: TEXT ONLY, LICENCE
<role>You are an economics news editor writing calmly, without hype, for beginner traders.</role>
<data>
<document n="1">
Source: [INSTITUTION, URL]. Published: [TIME + ORIGINAL TIME ZONE].
[PASTE VERBATIM]
</document>
<document n="2">
Source: [INSTITUTION, URL]. Published: [TIME + ORIGINAL TIME ZONE].
[PASTE VERBATIM]
</document>
Cutoff: [YYYY-MM-DD HH:MM] (UTC).
</data>
<constraints>
Use only the documents above, not general knowledge or memory.
Forecast figures not in the documents: write "not in document".
Convert event times to UTC and keep the original time next to it.
Affected assets: write "may" plus the mechanism. No trading recommendations.
</constraints>
<output>4 numbered items following the task. Each summary sentence ends with its document number, e.g. [1].
Then the 3-line tail: which event or figure would prove the mechanism in item 3 wrong;
the 3 biggest risks, each with a document number, or NOT ENOUGH DATA;
last line verbatim: This is analysis, not an order.</output>
<check>After writing, find a supporting quote for each sentence in items 1–4; if none, delete the
sentence and leave []. Don't delete the tail: a line without support says NOT ENOUGH DATA,
the last line stays verbatim.</check>
<task>
1. Quote the most important sentence of each document inside <quote>.
2. Summary: what happened, who published it, actual versus forecast (if in the document).
3. Assets that may be affected (gold, USD, indices, crypto): "may" plus mechanism.
4. Upcoming events mentioned in the documents, converted to UTC.
</task>

If your agent has web search, add to the constraints: “Use only official pages (central banks, statistics offices); give a URL and access time for every figure.”

Card 3 · Journal discipline score

Scores whether you followed your plan, not profit and loss: the outcome of one trade is partly random, while behaviour (risk, entry time, the right setup) can be fixed. Export your demo journal as CSV and open it in a text editor to copy it verbatim (Excel may reformat numbers). Remove broker names and account numbers first.

Write your plan as rules the CSV can verify, for example: max 1% risk per trade; entries only in the session windows you chose; every trade has a stop; no revenge trade after a loss. R is profit or loss in units of the initial risk (1R). MFE and MAE are the best and worst excursion while the trade was open, in R. They are only known after the trade closed, so the card forbids “it would have been a winner if…”. If your journal has a self-grade column and a system grade that stays hidden until you grade, rows you haven’t graded have no data: an empty error-tag cell there does not mean “no violation”.

# journal-v1 · [DATE] · first version · label: TEXT ONLY
<role>You are a trading discipline coach. You score PLAN COMPLIANCE, not profit or loss,
because each trade's outcome is partly random while behaviour can be fixed.</role>
<plan>[PASTE YOUR RULES, e.g. max 1% risk per trade; entries only in the London or New York
session; every trade has a stop; no revenge trade after a loss]</plan>
<data>
Source: [FILE NAME], exported [DATE].
[PASTE THE CSV VERBATIM]
</data>
<constraints>
Use only the CSV and the plan above. Empty cells, or an ungraded system grade: write
"not enough data", don't guess.
Don't summarise wins and losses, neither as a percentage nor in words like "most".
Don't write "it would have won if...".
MFE and MAE are known only after the trade closed: use them to look at trade management,
not to judge the entry decision.
</constraints>
<output>Table: CSV row (with its time value) | rule broken | evidence (column + value).
After the table: recurring patterns, then at most 3 fixes.</output>
<check>Delete any remark that can't point to a CSV row.
Rewrite any fix that can't be measured next week until it can.</check>
<task>
1. Mark trades that broke the plan and which rule (from error tags, notes, entry time, session).
2. Find patterns: time of day, setup, emotion that go with violations.
3. Compare my self-grade with the system grade: where I graded myself higher, and possibly why.
4. Propose at most 3 fixes for next week, each measurable (e.g. "0 trades tagged revenge").
</task>

Check the output: no win/loss summary of any kind, no “would have”, every remark points to a row, at most three measurable fixes.

Card 4 · From idea to spec, with a lot-size example

Turns “buy when price pulls back to the EMA50” into a spec: a rule set precise enough to code and test. No code at this step: code written from a vague idea carries every guess the model made. “Nearest low” can mean many things; the spec must pick one, such as “the lowest low of the last 10 closed H1 candles”. Ambiguities are your decisions, not the model’s, so it must list them as questions.

The lot example is there so you can check it at once. Balance 2,000 USD, risk 1% = 20 USD:

Symbol Stop distance Loss per lot Raw lot Rounded down Real risk
XAUUSD (1 lot = 100 oz) 7.5 USD 750 USD 0.0266 0.02 15 USD
EURUSD (1 pip = 10 USD per lot) 30 pips 300 USD 0.0666 0.06 18 USD
BTCUSD CFD (1 lot = 1 BTC) 900 USD 900 USD 0.0222 0.02 18 USD

Rounding up is an error: 0.03 lot of gold would risk 22.5 USD, above 20.

# spec-v1 · [DATE] · first version · label: TEXT ONLY
<role>You write trading strategy specs. At this step you do NOT write code.</role>
<idea>[YOUR IDEA IN WORDS, e.g. "gold H1, buy the pullback to EMA50 in an H4 uptrend,
stop below the nearest low"]</idea>
<constraints>
Risk 1% per trade; lot rounded DOWN to 0.01; below 0.01 lot write "no trade".
Conventions: XAUUSD 1 lot = 100 oz; EURUSD 1 pip = 10 USD per lot; BTCUSD CFD 1 lot = 1 BTC.
All conditions are measured on CLOSED candles. Where my idea is vague: do NOT guess, write a question.
</constraints>
<output>Spec table (item | measurable definition | data needed), a list of questions for me,
and 1 lot example with every step, using my balance [BALANCE] USD and stop distance [DISTANCE].</output>
<check>Turn any unmeasurable word ("near", "strong", "clean") into a question.
Compute the lot example a second time; if the two differ, tell me.</check>
<task>Rewrite the idea as a spec covering: market and timeframe; trend condition;
entry condition (e.g. "nearest low" = lowest low of [N] closed candles); SL, TP; lot formula;
when NOT to trade; handling of gaps and news.</task>

The approved spec feeds card 6. The pipeline: idea in words → card 4 spec → you answer the questions and approve → card 6 EA → Strategy Tester with “Every tick based on real ticks” and a forward period → card 7 looks for weaknesses. A good-looking report is not a reason to run the EA on a live account.

Cards 5 to 7 · Pine v6, MQL5 EA, backtest review

Card 5, Pine v6. When request.security pulls a higher timeframe, use an expression shifted by one bar (close[1]) together with lookahead_on; without the shift you get future data on historical bars, and public scripts that do this are moderated. The two go together. barstate.isconfirmed makes signals wait for the close: later signals, no repainting. To try the code: Pine Editor tab → Create new / Indicator → replace the code → Ctrl+S → Add to chart.

# pine-indicator-v1 · [DATE] · first version · label: RUNS CODE, LICENCE
<role>You write Pine Script v6 that a beginner trader can read.</role>
<requirements>Indicator: fast EMA [PERIOD, e.g. 20] and slow EMA [PERIOD, e.g. 50]; an arrow
when the fast EMA crosses the slow one, only on closed candles. Add a trend filter on
[HIGHER TF, e.g. H4] using EMA [PERIOD, e.g. 200].</requirements>
<constraints>
- First line is //@version=6.
- request.security on the higher timeframe: shift by one bar (e.g. close[1]) together with
  lookahead_on, because missing either one looks ahead on historical bars.
- Signals only when barstate.isconfirmed (closed candle); later signals are acceptable.
- Every parameter is an input with a clear name.
- No strategy, no profit calculation.
</constraints>
<output>1) Complete code. 2) Parameter table. 3) A 5-line explanation for a beginner.
4) Does the indicator repaint, and why.</output>
<check>Before giving code: list every request.security call and every use of an unclosed
candle's price, each marked "safe" or "needs fixing".</check>
<task>Write the indicator to the requirements, meeting every constraint.</task>

Card 6, MQL5 EA. OrderSend returning true only means the basic checks on the structures passed, not that the order executed: you must read the retcode. Check the request with OrderCheck() before sending. The CTrade class gives you SetExpertMagicNumber (an ID for the EA’s orders), ResultRetcode and ResultRetcodeDescription. The other lines block risk: volume rounded down to the symbol’s step, no martingale (doubling after a loss), no grid, a stop on every trade, no WebRequest or DLLs, orders only on demo or in the tester, and an order switch that is off by default.

# ea-mql5-v1 · [DATE] · first version · label: RUNS CODE, CAN PLACE ORDERS
<role>You write MQL5. The code is for BACKTESTING and DEMO accounts only.</role>
<spec>[PASTE THE SPEC APPROVED FROM CARD 4]</spec>
<constraints>
- Use #include <Trade\Trade.mqh> and CTrade; set a magic number with SetExpertMagicNumber.
- Check every request with OrderCheck() before sending. After sending, read ResultRetcode()
  and print ResultRetcodeDescription(); a true return does not mean the order filled.
- Send orders only when AccountInfoInteger(ACCOUNT_TRADE_MODE) is ACCOUNT_TRADE_MODE_DEMO or
  in the Strategy Tester; add an input that enables sending, off by default.
- With the switch off: only Print the signal and the intended order; never call OrderSend or
  CTrade's order functions (Buy, Sell, PositionOpen).
- Volume: read SYMBOL_VOLUME_MIN and SYMBOL_VOLUME_STEP, round DOWN; below the minimum, don't send.
- Entry decisions use closed candles only.
- No martingale, no grid, every trade has a stop. No WebRequest, no DLLs.
</constraints>
<output>Full code; input table; a "How to test" section: Every tick based on real ticks,
a proposed in-sample period (for tuning) and a Forward (out-of-sample) period.</output>
<check>List every place in the code that can send an order and the guard that blocks it.</check>
<task>Write the EA to the spec, meeting every constraint.</task>

Card 7, backtest review. The role is a critic, not a fan: quote the metrics first, judge second. Profit Factor is gross profit over gross loss. Recovery Factor is profit over maximum drawdown. LR Correlation near 1 means the balance curve hugs a straight line. History Quality is the share of correct one-minute data used. In MT5, “1 minute OHLC” can produce an unrealistically smooth balance and “Open prices only” can fill stops and pending orders at the wrong price; if a coarse mode looks too good, rerun with “Every tick based on real ticks”. In TradingView: a strategy with no declared commission pays none, slippage defaults to 0 ticks, an order created at a bar’s close fills at the next tick (on history, the next bar’s open), and a strategy on Heikin Ashi or Renko fills at synthetic prices by default.

# backtest-review-v1 · [DATE] · first version · label: TEXT ONLY; LICENCE if a TradingView report
<role>You audit backtests. Your job is to find weaknesses, not to praise.</role>
<data>
[PASTE THE METRICS TABLE VERBATIM: MT5 Strategy Tester Backtest/Results tab, or TradingView Metrics]
Test conditions: tick mode [MODE]; History Quality [NUMBER OR "NONE"]; period [FROM - TO];
commission [VALUE OR "NOT DECLARED"]; slippage [TICKS OR "NOT DECLARED"]; spread [VALUE].
</data>
<constraints>No predictions of future profit. No numbers absent from the report; write "not present".
Never call any configuration "the best".</constraints>
<output><quote> section first, then each metric, then overfitting signs, then 3 next tests.
Then the 3-line tail: which test result would prove the assessment wrong;
the 3 biggest risks, each naming a quoted metric and number, or NOT ENOUGH DATA;
last line verbatim: This is analysis, not an order.</output>
<check>Every remark names the metric and the quoted number; delete remarks without one.
Don't delete the tail: a line without a quoted number says NOT ENOUGH DATA.</check>
<task>
1. Quote every metric in the report inside <quote>.
2. Assess: enough trades to conclude?; balance and equity drawdown versus profit;
   Profit Factor; Recovery Factor; LR Correlation; History Quality.
3. List overfitting signs and unrealistic assumptions (fees, slippage, spread, coarse tick mode).
4. Propose 3 next tests: an out-of-sample period (MT5 has Forward); parameters ±20%;
   MT5 rerun with Every tick based on real ticks, TradingView rerun with fees and slippage declared.
</task>

Card 8 · Economic calendar cross-check

Third-party calendars can be wrong or stale close to a release. This card cross-checks the calendar you use against the issuing institutions’ own pages. Before copying, check that the calendar actually covers the week you plan to trade: no rows for that week, or every row already in the past, means it’s stale.

Official pages state their own conventions, and the conversions are where mistakes happen:

Event What the official page says UTC
US Employment Situation, November 2026 Friday 4 Dec 2026, 08:30; all times US Eastern 13:30 Friday 4 Dec (December: ET = UTC−5)
FOMC meeting Meeting calendar: 8–9 Dec 2026, no time. December calendar: FOMC 2:00 p.m. on 9 Dec, press conference 2:30 p.m., no time zone (statements are in Eastern time) 19:00 Wednesday 9 Dec, press conference 19:30
ECB monetary policy meeting 16–17 Dec 2026; no announcement time unverified time

The US and Europe switch to summer time on different dates (in 2026: US on 8 March and 1 November, Europe on 29 March and 25 October), and labels may not change with the season: the ECB writes CET all summer. A 14:45 press conference on 29 October 2026 fell in the week Europe was back on standard time (UTC+1), so it was 13:45 UTC. Always convert using the local time on that exact date.

The two rules that matter:

  1. Convert date and time from the original zone first, then assign one of four statuses; the model never picks a winner. MATCH: same date and time. MISMATCH: different date or time, or only one calendar has it although that institution was pasted for that date range. UNVERIFIED: only the third-party calendar has it because you didn’t paste that institution. UNVERIFIED TIME: the official page has a date but no time; never call it a mismatch just because conversion shifts the date, and mark the trading-window column MAYBE.
  2. Stale calendar: if it has no rows from the trading dates on, write STALE OR MISSING CALENDAR and build the table from the official rows only, status NOT CHECKABLE (rows without an official time stay UNVERIFIED TIME). If it has later rows but nothing on the trading day, write “no events that day” and still check the official rows. Only when both are missing: STALE OR MISSING and stop.
# calendar-v1 · [DATE] · first version · label: TEXT ONLY
<role>You cross-check the economic calendar for a learning trader. You check dates, times and
sources; you don't guess where the news will move price.</role>
<web_calendar source="[CALENDAR URL]" opened="[YYYY-MM-DD HH:MM] UTC">
[PASTE THE ROWS FOR THE TRADING WEEK AND THE NEXT ONE; IF THERE ARE NONE, WRITE "NO ROWS"]
</web_calendar>
<official_calendar>
Institutions pasted: [e.g. BLS, FED, ECB]; covering [YYYY-MM-DD] to [YYYY-MM-DD].
[PASTE ROWS FROM THE OFFICIAL PAGES; EACH WITH URL, TIME OPENED AND ORIGINAL TIME ZONE]
</official_calendar>
<plan>Trading dates: [YYYY-MM-DD → YYYY-MM-DD]. Symbol: [XAUUSD OR EURUSD]. Planned entry window:
[HH:MM–HH:MM] UTC (if it crosses midnight, include the end date).
Rule: no entries within [30] minutes before or after a HIGH-impact event.</plan>
<constraints>
Use only the two pasted calendars, not memory. Official dates are in the original time zone:
convert date and time to UTC and keep the original next to it.
Convert using the local time of the publisher on that exact date (New York for BLS and Fed,
Frankfurt for ECB, London for the UK). US and European summer time are judged separately by date
(they switch on different dates; labels may not change with the season, e.g. ECB writes CET all summer).
In both calendars with the same converted date and time: MATCH.
In both with a different date or time, or in only one although that institution is pasted and the
date is covered: MISMATCH, say what differs; don't pick the right side.
Only in the web calendar and that institution isn't pasted (or the date isn't covered): UNVERIFIED;
still judge the entry window by the web calendar's time.
Official calendar has a date but no time: "unverified time" (status UNVERIFIED TIME); don't fill it in,
don't call it MISMATCH because the converted date differs; mark the window column MAYBE for the
event's last day and the early hours of the next day (UTC).
Web calendar has no rows from the trading dates on, or every event is already past: write
STALE OR MISSING CALENDAR first, then build the table from official rows only (web column "none",
status NOT CHECKABLE; official rows without a time stay UNVERIFIED TIME). If it has later rows but
the trading day is empty, write "no web events that day" and still check the official rows.
Both missing: write STALE OR MISSING and stop.
No guesses at actual figures, no views on direction, no advice to trade or stay out.
</constraints>
<output>Table: event | original date/time + zone | UTC date/time | web | official |
MATCH, MISMATCH, UNVERIFIED, UNVERIFIED TIME or NOT CHECKABLE (stale calendar only) |
inside the entry window ± [30] minutes (YES, NO or MAYBE). After the table: the MISMATCH rows,
then HIGH-impact rows still UNVERIFIED or UNVERIFIED TIME, for me to open myself.</output>
<check>Convert every time a second time; report any difference.
One status per row; count MATCH, MISMATCH, UNVERIFIED, UNVERIFIED TIME and NOT CHECKABLE: the total
must equal the number of events. Rows without an official time must never say NO in the window column.</check>
<task>Cross-check each event in the trading dates against the constraints, HIGH-impact first.</task>

Check the output yourself: convert one ET time and one Frankfurt time to UTC by hand, make sure there’s no “this news will lift gold”, open the source for every MISMATCH and every HIGH-impact row still unverified, and confirm no row without an official time says NO in the window column.

Card 9 · Stress test with sourced scenarios

This card computes rather than guesses: if a bad move that already happened in your data happens again, how much do the open demo positions lose against the balance and the daily loss cap? The scenarios can only be as bad as the worst move in the file, so the file must be long. A file without a gap through the stop does not mean holding over the weekend is safe.

Backtests often assume perfect fills (a TradingView strategy with no declared commission pays none, and slippage defaults to 0; a stop jumped over between bars fills at the next bar’s open), so the card states two assumptions explicitly: the stop slips by an amount you choose, and a reopening price beyond the stop closes the trade at the reopening price, not at the stop.

Use at least 12 months of H1 candles (about 6,000 for gold), ideally one to two years, and record the count and date range. Even a year can be too short: on one EURUSD H1 file, the last 12 months (6,227 candles) gave a largest weekend gap of 72.8 pips while the whole file gave 127.5. On a short file of the last 500 gold H1 candles (four weekends), the largest gaps were −2.94 and +4.14 USD, both smaller than a 7.5 USD stop, so the scenario “gap through the stop” never appears; the full 22-month file had a 111.937 USD gap and a 397.29 USD candle.

This read-only script finds the widest candle and the largest gaps after a market break. It reads an MT5 export (separate <DATE> and <TIME> columns, usually server time) or a file with time, open, high, low, close.

import sys
import pandas as pd

sys.stdout.reconfigure(encoding="utf-8")
path = sys.argv[1] if len(sys.argv) > 1 else "data/xauusd_h1_mt5.csv"
with open(path, "rb") as f:                 # UTF-16 BOM → read as UTF-16
    enc = "utf-16" if f.read(2) in (b"\xff\xfe", b"\xfe\xff") else "utf-8-sig"
bars = pd.read_csv(path, sep=None, engine="python", encoding=enc)
bars.columns = [c.strip("<>").lower() for c in bars.columns]
if "date" in bars.columns:
    bars["time"] = pd.to_datetime(bars["date"] + " " + bars["time"], format="%Y.%m.%d %H:%M:%S")
else:
    bars["time"] = pd.to_datetime(bars["time"])
bars["range"] = (bars["high"] - bars["low"]).round(5)
bars["gap"] = (bars["open"] - bars["close"].shift(1)).round(5)
after_break = bars[bars["time"].diff() > pd.Timedelta(hours=24)]
days = (bars["time"].iloc[-1] - bars["time"].iloc[0]).days
print(f"File: {len(bars)} candles, {bars['time'].iloc[0]} -> {bars['time'].iloc[-1]} ({days} days), {len(after_break)} breaks")
if days < 365:
    print("File shorter than 1 year: scenarios may understate reality")
print("3 widest candles (price units; EURUSD x 10,000 = pips):")
print(bars.nlargest(3, "range")[["time", "range"]].to_string(index=False))
print("3 largest gaps after a break (time = reopening candle):")
print(after_break.loc[after_break["gap"].abs().nlargest(3).index, ["time", "gap"]].to_string(index=False))
neg = after_break[after_break["gap"] < 0].nsmallest(1, "gap")
pos = after_break[after_break["gap"] > 0].nlargest(1, "gap")
print("Largest negative gap (hurts longs):", f"{neg['time'].iloc[0]}  {neg['gap'].iloc[0]}" if len(neg) else "none")
print("Largest positive gap (hurts shorts):", f"{pos['time'].iloc[0]}  {pos['gap'].iloc[0]}" if len(pos) else "none")
.venv\Scripts\python src\stress_scenarios.py data\xauusd_h1_export.csv

On a sample XAUUSD H1 file (bid prices, 10,831 candles, 1 Jan 2025 to 30 Oct 2026, times are candle open in UTC):

File: 10831 candles, 2025-01-01 23:00:00 -> 2026-10-30 09:00:00 (666 days), 97 breaks
3 widest candles (price units; EURUSD x 10,000 = pips):
               time   range
2026-01-29 15:00:00  397.29
2026-01-30 18:00:00  212.64
2026-02-02 01:00:00  200.95
3 largest gaps after a break (time = reopening candle):
               time      gap
2026-04-12 22:00:00 -111.937
2026-03-01 23:00:00   94.779
2026-02-01 23:00:00  -77.520
Largest negative gap (hurts longs): 2026-04-12 22:00:00  -111.937
Largest positive gap (hurts shorts): 2026-03-01 23:00:00  94.779
Scenario (long 0.02 lot XAUUSD, stop 7.5 USD, balance 2,000 USD) Adverse move Working Loss % of balance
A · Stop fills exactly 7.5 USD 0.02 × 100 × 7.5 15.00 USD 0.75%
B · Stop slips 2 USD (assumption) 9.5 USD 0.02 × 100 × 9.5 19.00 USD 0.95%
C · Largest negative gap jumps the stop; closes at the reopening price 111.937 USD 0.02 × 100 × 111.937 223.87 USD 11.19%
D · No stop, price moves against you by the widest candle 397.29 USD 0.02 × 100 × 397.29 794.58 USD 39.73%
# stress-test-v1 · [DATE] · first version · label: TEXT ONLY (helper script: RUNS CODE, read-only)
<role>You compute bad-case scenarios for a DEMO account. You compute and show the working;
you never advise buying, selling, closing or holding.</role>
<positions source="[MT5 demo, Trade tab, time captured UTC]">
Balance: [BALANCE] USD. Daily loss cap: [AMOUNT] USD.
One position per line: symbol | side | lot | entry | SL (or "none").
Conventions: XAUUSD 1 lot = 100 oz, a 1 USD move = 100 USD per lot; EURUSD 1 pip = 10 USD per lot;
BTCUSD CFD 1 lot = 1 BTC, a 1 USD move = 1 USD per lot (check the symbol spec on MT5 demo).
</positions>
<scenarios>
First line: Data: [FILE] | [N] candles | [FIRST] → [LAST] | [N BREAKS]. File shorter than 12 months:
write "scenarios may understate reality".
One scenario per line: name | adverse move | source (file + candle time, or URL + time opened).
[PASTE THE SCRIPT OUTPUT]
</scenarios>
<assumptions>
Stop slippage: [N] USD for gold, [N] pips for EURUSD, [N] USD for BTCUSD. If unsure, compute both 0 and this.
A reopening price beyond the stop closes the trade at the reopening price, not at the stop.
Gaps apply against each position: longs use the largest negative gap, shorts the largest positive gap.
For a worst case in both directions, state "assumed gap of the same size in the adverse direction".
</assumptions>
<constraints>
Use only numbers in positions, scenarios and assumptions. Unsourced numbers: "unverified"; missing
candle count or dates: "data length unverified".
If the largest gap is smaller than the stop distance, write "no gap through the stop in this file";
don't conclude that holding over the weekend is less risky than the stop.
No advice to buy, sell, close, hold or resize. Don't say which scenario will happen.
</constraints>
<output>Table: scenario | position | adverse move | working | loss USD | % of balance | breaches the daily cap?
After the table: the assumptions used, then at most 3 questions for me to review my plan.</output>
<check>Compute each row a second time; report any difference.
No rounding mid-calculation; round only the final result to 0.01 USD.</check>
<task>Compute each scenario for each position, meeting the constraints.</task>

After reading the table, you review your plan (holding over the weekend, for instance). Every number here is a simulation on history, not advice; rerun it on your own long demo file before using it.

Try it: review a card before saving a new version

<role>You review prompt cards for a learning trader. You only comment and suggest; don't rewrite
the whole card, because I need to know exactly which lines change.</role>
<old_card name="[OLD FILE, e.g. chart-v1.md]">
[PASTE OLD VERSION]
</old_card>
<new_card name="[NEW FILE, e.g. chart-v2.md]">
[PASTE NEW VERSION]
</new_card>
<errors_seen>[PASTE 1–3 BAD OUTPUTS AND WHAT WAS WRONG, e.g. "support level without a source",
"lot rounded up"]</errors_seen>
<safety_labels>TEXT ONLY: text, images, CSVs in, text out. RUNS CODE: the output is code that will run.
NEEDS KEY: needs an API key or a data-service login. CAN PLACE ORDERS: code calls an order function.
LICENCE: terms to read before giving data to an AI, republishing or sharing.</safety_labels>
<constraints>
Base everything on the two cards, the labels and the errors I pasted. Where unsure, say "not sure".
Don't add buy/sell advice or win-rate calculations.
If you see an API key, password or account number: say where, never copy the value.
</constraints>
<output>
1. A 5-part checklist for the new card: role | data with source and UTC time | constraints |
   output (for cards with a view: the full 3-line tail) | check. Each cell Yes or Missing, with the quoted line.
2. Placeholders still unfilled or vague.
3. Lines from the old card removed or weakened (especially constraints and checks), and the possible consequence.
4. Whether the new card blocks the errors seen; which are still unblocked.
5. A proposed change line for the top of the file: name · date · change · reason · safety label.
6. Whether the safety label still fits; any missing label (e.g. an API call needs NEEDS KEY).
</output>
<check>Delete any remark that can't quote a line of the card as evidence.</check>
<task>Review the new card against the 6 output items, in order.</task>

Key takeaways

  • Fill every placeholder, never delete constraints or checks, and version cards instead of editing them in place.
  • Score journals on plan compliance: no win/loss summary, no “would have”, every remark points to a CSV row.
  • EA card: OrderSend returning true is not a fill; OrderCheck before, retcode after, orders only on demo.
  • A backtest too good on 1 minute OHLC gets rerun on Every tick based on real ticks; TradingView strategies need fees declared by hand.
  • Stress scenarios are only as bad as the worst move in your file, so use a long one.

Comments