PromptBase
PromptBase SelectGet Select
Close icon
General
Home
Marketplace
Create
Hire
Login
Chat
Sell
Explore

Prompt Details

Model
(claude-5-sonnet)
Token size
2,601
Example input
[MARKET, INSTRUMENTS, AND TRADING VENUE]: BTC and ETH perpetual futures on a major crypto exchange. [SIGNAL TIMEFRAME AND EXPECTED HOLDING PERIOD]: Use 4-hour signals and expect positions to be held for several days. [TREND FOLLOWING, MEAN REVERSION, BREAKOUT, MOMENTUM, OR OPEN TO SUGGESTIONS]: Trend following. [CONSERVATIVE, MODERATE, OR AGGRESSIVE]: Trend following. [AVAILABLE DATA, PLATFORM, LONG OR SHORT RESTRICTIONS, SESSION, AND OTHER CONSTRAINTS]: Use OHLCV data. Allow both long and short trades. Include trading fees, perpetual-futures funding, and slippage. Evaluate signals at the close of each 4-hour candle. The blueprint should later be implementable in Python or Pine Script.
Example output
# BTC/ETH Perpetual Futures — 4H Trend-Following Research Blueprint ## 1. Feasibility and Assumptions **Restated scope:** BTC and ETH perpetual futures, traded independently (2-instrument universe), on a major crypto derivatives exchange. Signals evaluated on 4-hour OHLCV bars. Expected holding period: several days (multi-bar swing trend following). Both long and short permitted. Data required: 4H open/high/low/close/volume, plus venue-specific funding rate and settlement timestamps. **Assumptions not supplied by you (must be stated as assumptions, not facts):** | # | Assumption | Why it's needed | Must be verified before backtesting | |---|---|---|---| | A1 | Exchange = a single major USDT-margined perpetual venue (e.g., Binance-style contract structure) | Fee/funding conventions differ by venue | Confirm actual venue and contract type | | A2 | Funding settled every 8 hours at fixed clock times | Needed to model funding cash flows correctly | Confirm actual funding interval and settlement timestamps for the chosen venue | | A3 | Taker fee ≈ 0.04%–0.05% per side | Typical range for major venues, not your actual fee tier | Pull your actual maker/taker schedule, including any volume-based discounts | | A4 | Slippage ≈ 1–3 basis points per fill on BTC/ETH majors under normal liquidity | No historical slippage data supplied | Must be estimated from real order-book/trade data or conservatively stressed in section 6 | | A5 | Research account equity = a nominal $100,000 simulation unit, not real capital | Needed to express fixed-fraction risk sizing | N/A — this is a research placeholder only | | A6 | Historical OHLCV history of at least 3–5 years is obtainable at 4H resolution for both instruments | Needed for warm-up + development + validation + holdout split | Confirm actual data availability and any gaps/outages in the vendor's history | | A7 | Maximum practical leverage on the venue is at least 3x for both instruments | Needed for margin feasibility check | Confirm venue's tiered margin/leverage schedule | **Sample-size and liquidity limitations:** A 4H trend-following system with multi-day holding periods will generate a low absolute trade count — plausibly on the order of dozens of trades per instrument per year. This constrains statistical confidence and is addressed explicitly in Sections 7 and 8. **Edge status:** Everything below is a *hypothesis to be tested*, not a claim of an existing profitable edge. No historical performance is implied or estimated in this memo. ## 2. Research Hypothesis **Market behavior being tested:** After a 4H close confirms a shift in short/medium-term moving-average alignment in the direction of a longer-term trend regime, price has a tendency to continue moving in that direction for multiple subsequent bars, more often than a fully random walk would imply. **Plausible mechanism:** Trend continuation in liquid perpetual futures may arise from staggered information absorption and positioning adjustment — large participants (funds, market makers hedging options books, systematic CTAs) often build or unwind exposure over multiple hours to days rather than instantaneously, and momentum/trend-following flows themselves can be self-reinforcing over medium horizons. Funding-rate imbalances during strong trends can also delay mean-reversion by making it costlier for counter-trend participants to hold opposing positions. **Why it might persist:** Crypto perpetual markets have historically had a large share of retail and semi-systematic participants, incomplete arbitrage across venues, and funding-driven positioning frictions — all of which can slow the speed at which price fully reflects new information. **Why it might disappear:** Increasing institutional participation, higher-frequency arbitrage, and crowding by systematic trend followers can compress or eliminate the effect; regime shifts (e.g., low-volatility chop) can also structurally remove trend persistence for extended periods. **Observations that would contradict the hypothesis:** Out-of-sample expectancy at or below zero after realistic costs; profits concentrated in only one historical episode (e.g., a single bull run) rather than distributed across multiple regimes and both instruments; rapid decay of any edge once slippage/fee assumptions are stressed. ## 3. Operational Specification (Base Strategy — exactly one) **Required data (per instrument, BTC and ETH independently):** 4H OHLCV, funding rate history with settlement timestamps, and (if available) mark price series distinct from traded/last price. **Indicators and exact formulas:** - EMA20 = exponential moving average of close, period 20 - EMA50 = exponential moving average of close, period 50 - EMA200 = exponential moving average of close, period 200 - EMA200 slope20 = (EMA200[t] − EMA200[t−20]) ÷ EMA200[t−20] - ADX14 = Average Directional Index, standard Wilder formulation, period 14 - ATR14 = Average True Range, standard Wilder formulation, period 14 **Lookback periods:** as stated above (max lookback = 200 bars for EMA200, plus 20 additional bars for slope calculation). **Warm-up requirement:** minimum 220 fully-formed 4H bars of history before any signal is evaluated, so EMA200 and its 20-bar slope are fully seeded. No signal is generated during warm-up. **Direction:** both long and short permitted, gated by regime. **Regime filter (exact, single):** Uptrend regime is active when EMA200 slope20 > 0. Downtrend regime is active when EMA200 slope20 < 0. When EMA200 slope20 = 0 exactly, no regime is active and no new entries are permitted. **Entry conditions (exact):** Long entry — all three true at the close of bar t: 1. Uptrend regime active (EMA200 slope20 > 0) 2. EMA20 crosses above EMA50 at bar t: EMA20[t−1] ≤ EMA50[t−1] AND EMA20[t] > EMA50[t] 3. ADX14[t] ≥ 20 Short entry — all three true at the close of bar t: 1. Downtrend regime active (EMA200 slope20 < 0) 2. EMA20 crosses below EMA50 at bar t: EMA20[t−1] ≥ EMA50[t−1] AND EMA20[t] < EMA50[t] 3. ADX14[t] ≥ 20 (ADX14 ≥ 20 is the single measurable substitute for "strong momentum." There is no separate "high volatility" or "near support" condition in this base strategy — those subjective terms are not used.) **Signal evaluation timing:** signals evaluated only at the close of each completed 4H bar. No intra-bar evaluation. **Order type:** market order. **Order creation time:** immediately after the close of bar t (once the entry conditions are confirmed true). **Intended fill time:** open of bar t+1. **Actual fill:** modeled as the open of bar t+1, adjusted by the slippage assumption in Section 6. This is not assumed to be an exact fill at the displayed open price. **Elapsed delay:** the actual wall-clock time from the close of bar t to the open of bar t+1 (i.e., effectively immediate — the next bar's open, not a full additional bar of delay). **Gap handling:** if bar t+1's open gaps beyond the modeled slippage band, the fill is still modeled at that actual open price plus slippage; no assumption of fill at a "typical" price is made. **Missing data handling:** if a 4H bar is missing entirely for an instrument, no signal is evaluated for that bar and the prior state carries forward unchanged until data resumes; any position already open continues to be managed using the last available valid bar for stop/exit checks. **Conflicting signals:** a long and short entry condition cannot both be true simultaneously, since they require opposite regimes; no additional conflict-resolution rule is needed. **Maximum concurrent positions:** 1 open position per instrument, 2 total (BTC + ETH independently). No portfolio-level netting between instruments. **Re-entry / cooldown:** after a position is closed (by any exit type), a minimum cooldown of 2 bars (8 hours) must elapse before a new entry signal on the same instrument can be acted on, even if entry conditions are again satisfied. **Signal stacking:** not allowed. No pyramiding or adding to an existing position under any circumstance. ## 4. Exit and Order-Priority Rules **Base exit design (exactly one):** ATR-based Chandelier-style trailing stop as the primary exit, plus a signal-reversal exit and a time-based exit as safeguards. **ATR reference:** ATR14 is fixed at entry (computed once, at the close of bar t, using the same bar that confirmed entry) and held constant for the life of the trade. It is not recalculated bar-to-bar. This choice is used consistently in both this section and the implementation checklist (Section 10). **Trailing stop formulas (direction-aware, exact):** - Long trailing stop = highest high since entry − 3.0 × ATR14-at-entry - Short trailing stop = lowest low since entry + 3.0 × ATR14-at-entry **Initial protective stop:** equal to the trailing stop formula evaluated at the entry bar itself (i.e., "highest high since entry" / "lowest low since entry" both initialize to the entry bar's high/low respectively on bar t+1, the fill bar). **Ratchet behavior:** the long trailing stop may only move upward, never downward, as new higher highs occur. The short trailing stop may only move downward, never upward, as new lower lows occur. If a new bar's extreme would move the stop in the unfavorable direction, the stop is left unchanged. **Profit-taking rule:** none separate from the trailing stop. This is a pure trend-following exit design — the trailing stop itself is the only profit-realization mechanism in the base strategy. **Breakeven behavior:** not used in the base strategy. **Time-based exit:** if a position remains open for 60 bars (10 days) without being stopped out or signal-reversed, it is closed at the open of the next bar following the 60th bar. **Signal-reversal exit:** if, while a position is open, the opposite-direction entry conditions (Section 3) become fully true at a bar close, the current position is closed (not reversed into a new position on the same bar — a new entry can only be considered after cooldown, per Section 3). **Same-bar stop priority:** if a bar's tradable range would trigger the trailing stop, the stop exit takes priority over any signal-reversal or time-based exit check on that same bar. **Gap handling (exit):** if the market gaps through the trailing stop level, the exit is modeled as filled at the actual open price of that bar (adjusted for slippage), not at the theoretical stop price. **Weekend / funding-event handling:** crypto perpetuals trade continuously, so there is no weekend session gap. Funding settlements do not trigger exits by themselves; funding is a cash-flow cost applied separately per Section 6, using actual settlement timestamps. **Exit priority order (as specified, unmodified):** 1. Active protective/trailing stop checked against the bar's tradable range. 2. Signal-reversal exit evaluated if the stop was not triggered. 3. Time-based exit evaluated if neither the stop nor reversal exit occurred. 4. A new entry is only considered after the prior position is fully closed and the cooldown has elapsed. No exact fill at the displayed stop or open price is assumed anywhere in this section — all exits are subject to the slippage model in Section 6. ## 5. Backtest Risk Assumptions (moderate risk level → one exact set) These are experimental simulation settings for research purposes only, not financial advice or a recommendation for real trading. | Setting | Value | |---|---| | Per-position risk cap | 0.5% of simulation equity | | Max concurrent positions | 2 (one BTC, one ETH) | | Max gross exposure | 200% of equity notional (sum of absolute position notional) | | Max net exposure | no explicit net cap beyond the 2-position structural limit | | Portfolio-level risk cap | 1.0% of equity (sum of open per-position risk) | | Drawdown pause threshold | 15% peak-to-trough equity drawdown triggers a full trading pause pending manual review | | Leverage / margin assumption | effective leverage capped at 3x notional per instrument | **Direction-aware sizing formulas:** - Long risk distance = abs(entry price − stop price) - Short risk distance = abs(stop price − entry price) - Position size = account equity × 0.005 ÷ direction-appropriate risk distance Before any trade is simulated, position size must be verified to be: positive, at or above the venue's minimum order size, within available margin at the 3x leverage cap, and within the 200% gross exposure limit. **Correlation note:** BTC and ETH perpetuals are historically highly correlated. Because both instruments can be in the same regime simultaneously, the 2-position structural cap does not eliminate correlated exposure — a simultaneous BTC-long and ETH-long is effectively one directional bet sized twice. This is a stated limitation of the base design, not an unresolved alternative; no separate correlation-based sizing rule is introduced in the base strategy. ## 6. Bias and Execution Controls - **Lookahead bias:** all indicators use only data available at or before the close of bar t; entries fill at t+1 open, never at bar t's own close or high/low. - **Survivorship/delisting bias:** low relevance for BTC/ETH but confirm the exchange has not changed contract specifications (e.g., contract multiplier changes) across the historical sample. - **Point-in-time universe membership:** not applicable (fixed 2-instrument universe). - **Corporate actions:** not applicable to crypto perpetuals. - **Bid-ask spread:** the difference between best bid and best ask at time of order — distinct from slippage and distinct from the high-low range. If historical spread data is unavailable, a scenario assumption must be used (see below), clearly labeled as an assumption, not historical fact. - **Trading fees:** apply the venue's actual taker fee schedule (Assumption A3) per side, both entry and exit. - **Slippage and market impact:** modeled separately from spread, as the difference between the intended t+1 open price and the actual modeled fill price (Assumption A4). - **Funding payments:** applied using actual venue settlement timestamps (Assumption A2), with correct sign — long positions pay funding when funding is positive and receive it when negative; short positions receive when positive and pay when negative. Funding must not be interpolated evenly across bars unless that approximation is separately labeled and separately tested as a stress scenario. - **Borrow fees:** not applicable to perpetual futures (no separate borrow leg). - **Futures rolls:** not applicable (perpetuals do not expire/roll). - **Session boundaries:** none (24/7 market); confirm the vendor's 4H bar boundary convention (e.g., UTC 00:00 aligned) is consistent across the full history. - **Signal-to-order timing:** as defined in Section 3/4 — signal at close of t, fill at open of t+1. - **Bar-resolution ambiguity:** confirm whether the data vendor's 4H bars are closed-interval and non-overlapping; reject any vendor series with repainting or revised historical bars. - **Missing or revised data:** handled per Section 3; any known data revisions in the vendor's history must be logged and flagged during validation. - **Index/mark/traded-price differences:** signals and fills in this base strategy use the traded (last) price series; mark price is not used for signals but should be checked against traded price for anomalies (e.g., liquidation-driven spikes) during data-quality review. If historical spread or slippage data cannot be obtained, use a clearly labeled scenario assumption (e.g., "Scenario: 2 bps slippage, fixed") rather than presenting any invented number as a historical fact, and re-run the stress tests in Section 7 under a worse-case scenario (e.g., 5–8 bps). ## 7. Validation and Falsification Plan **Chronological structure:** - Warm-up: first 220 bars of history, used only for indicator seeding, not evaluated for trades. - Development period: first 50% of the remaining history, used for initial rule confirmation and any necessary bug-fixing (not parameter optimization). - Validation / walk-forward period: next 25% of remaining history, used to check the fixed base-parameter rules out-of-sample. - Untouched holdout period: final 25% of history, examined only once, after all other steps are complete. **Minimum useful trade count:** at least 30 closed trades per instrument in the validation period before any conclusion is drawn; if fewer occur, extend the validation window rather than lowering the bar. **Primary performance metrics (pick 3–4, fixed in advance):** 1. Net expectancy per trade after all costs 2. Profit factor 3. Maximum drawdown 4. Trade-count-adjusted Sharpe or Sortino ratio on the equity curve **Regime/subperiod analysis:** performance must be examined separately across at least a rising-trend period, a falling-trend period, and a sideways/choppy period, and separately for BTC vs ETH. **Sensitivity testing:** re-run the fixed base parameters with small perturbations (Section 8) to check for cliff-like performance changes. **Stress tests:** re-run with (a) fees and slippage doubled, and (b) an added fixed adverse-fill penalty of an extra 2 bps, to see whether any apparent edge survives. **Delayed-entry / missed-fill test:** re-run assuming fills occur one additional bar later than modeled, to check sensitivity to execution latency. **Forward paper-trading stage:** only after passing the above, run the fixed rule set on live, forward data with no further rule changes, before any real-capital consideration. **Rejection criteria (fixed before any results are viewed):** - Non-positive out-of-sample expectancy after full costs → reject. - More than 60% of total profit concentrated in a single instrument or single contiguous period → reject. - Small parameter perturbations (Section 8 ranges) causing profit factor to swing from clearly positive to clearly negative → reject. - Failure to remain net positive under the stressed-cost scenario → reject. - Max drawdown exceeding 20% of equity in backtest → reject. - More than 50% of total profit coming from fewer than 10% of trades → reject. - Apparent edge disappearing once lookahead/timing correction is applied → reject. These thresholds are not to be changed after results are observed. ## 8. Parameter Registry | Parameter | Purpose | Starting value | Test range | # values | Overfitting risk | Effect of increasing | |---|---|---|---|---|---|---| | EMA fast period | Entry trigger speed | 20 | {15, 20, 25} | 3 | Medium | Slower, fewer, later signals | | EMA slow period | Entry trigger baseline | 50 | {40, 50, 60} | 3 | Medium | Slower, fewer, later signals | | ADX threshold | Momentum confirmation | 20 | {15, 20, 25} | 3 | Medium | Fewer, higher-conviction entries | | ATR trailing multiple | Trailing stop distance | 3.0 | {2.0, 3.0, 4.0} | 3 | Medium-High | Wider stops, fewer whipsaw exits, larger per-trade risk realized | Fixed (not swept, to keep the search space small): EMA200 regime period, EMA200 slope lookback (20 bars), ATR period (14), per-trade risk cap (0.5%), max holding period (60 bars). **Grid size:** 3 × 3 × 3 × 3 = 81. Recomputed independently: 3×3 = 9; 9×3 = 27; 27×3 = 81. Confirmed: 81 combinations, matching the table. Given the expected low trade count for a multi-day-holding 4H strategy (likely well under a few hundred trades across both instruments over several years), an 81-combination full grid search is large relative to the available trade count. **Recommendation: use this grid only for sensitivity/robustness checks (Section 7), not as an unrestricted optimization search.** Do not describe any single best-performing combination from this grid as "optimal." ## 9. Failure Analysis | Failure mode | Evidence that would reveal it | |---|---| | Economic hypothesis is false | Persistent non-positive expectancy across regimes and both instruments after correcting for costs | | Regime dependence | Profitability concentrated in trending subperiods only, near-zero or negative in chop subperiods | | Crowding/decay | Edge visible in earlier history, weak or absent in most recent years | | Execution sensitivity | Edge disappears once slippage/fee stress tests (Section 7) are applied | | Data-quality problems | Anomalous spikes, missing bars, or vendor revisions coincide with trade entries/exits | | Parameter instability | Small parameter perturbations swing results from profitable to unprofitable | | Tail events | A small number of extreme adverse bars drive the majority of drawdown | | Historical-to-live gap | Forward paper-trading performance diverges materially from backtest metrics | | Correlated portfolio losses | BTC and ETH positions move in the same direction simultaneously during losses, producing drawdowns larger than either instrument alone would suggest | ## 10. Implementation Handoff Checklist - **Signal calculations:** EMA20, EMA50, EMA200, EMA200 slope20, ADX14, ATR14 — all computed only on fully closed 4H bars. - **State variables per instrument:** open position (none/long/short), entry price, entry-bar ATR14 (fixed), highest-high-since-entry, lowest-low-since-entry, current trailing stop level, bars-in-trade counter, cooldown counter. - **Entry sequence:** confirm regime → confirm EMA cross → confirm ADX14 ≥ 20 → confirm no open position and cooldown elapsed → submit market order immediately after bar t close → model fill at bar t+1 open plus slippage. - **Exit sequence (priority order):** check trailing stop against bar range → check signal-reversal condition → check time-based exit (60 bars) → close and reset state variables. - **Position-sizing sequence:** compute direction-aware risk distance → position size = equity × 0.005 ÷ risk distance → verify positive, above minimum order size, within margin at 3x leverage cap, within 200% gross exposure cap. - **Direction-aware stop-distance formulas:** long = abs(entry − stop); short = abs(stop − entry). - **Exact trailing-stop formula:** long = highest high since entry − 3.0×ATR14-at-entry; short = lowest low since entry + 3.0×ATR14-at-entry. - **Ratchet behavior:** long stop moves up only; short stop moves down only. - **Order precedence:** stop > signal-reversal > time exit > new entry (only after full close + cooldown). - **Required data:** 4H OHLCV, funding settlement history with timestamps, mark price series (for anomaly checks only). - **Required debugging logs:** per-trade entry/exit timestamps, signal values at confirmation, fixed ATR-at-entry, trailing stop value at each bar, fees/funding/slippage applied, resulting equity. - **Pre-implementation tests:** verify no future bar data leaks into signal computation; verify fixed-at-entry ATR is never recalculated mid-trade; verify cooldown blocks re-entry correctly; verify grid arithmetic (81) matches actual generated combinations. - **Python-specific considerations:** use vectorized indicator libraries carefully around warm-up NaNs; ensure timestamp alignment between OHLCV and funding data (especially timezone/UTC handling); avoid pandas shift() off-by-one errors when comparing bar t vs t−1. - **Pine Script-specific considerations:** use `barstate.isconfirmed` to avoid intra-bar repainting on signal evaluation; be explicit that orders are placed on the next bar's open (`strategy.entry` executes on the next tick after the signal bar close in standard Pine execution); confirm ATR is captured once via a persistent `var` variable at entry rather than recalculated each bar. **Final consistency check performed:** base strategy contains no unresolved alternatives; every parameter in Section 8 has exactly one starting value; long/short position sizes are structurally positive by formula; stop distances use absolute values; trailing stop consistently uses highest-high (long) / lowest-low (short); ATR is fixed-at-entry in both Section 4 and Section 10; signal confirmation, order submission, intended fill, and actual fill are kept as four distinct timing points; stop/trailing checks precede reversal and time exits; funding sign/timing follows actual settlement conventions; the 81-combination grid arithmetic is verified independently; no future data enters any signal, sizing, or exit calculation. --- **Optional future variants** *(not part of the base strategy — for later consideration only)* - Volatility-normalized position sizing using realized volatility instead of a fixed ATR-derived stop distance. - A partial-profit-taking rule at a fixed R-multiple before the trailing stop takes over. - Cross-instrument correlation-adjusted portfolio sizing instead of independent per-instrument risk caps. - A funding-rate extremity filter that pauses new entries when funding is unusually skewed in the trade's direction.
Claude

Trading Strategy Blueprint Generator

Add to Cart
PromptBase Select
Get this prompt + 9 more with Select$14 your first month, then $19/mo$14 first month, then $19/mo
View Select
Instant accessInstant access
Usage rightsCommercial use
Money-back guaranteeMoney‑back
By purchasing this prompt, you agree to our terms of service
CLAUDE-5-SONNET
Tested icon
Guide icon
4 examples icon
Free credits icon
Built by a quantitative trader, this prompt turns a trading idea into one precise research blueprint with codeable entries, exits, risk assumptions, execution rules, backtest design, falsification criteria, and robustness tests. It is designed for traders and developers who want structured, testable hypotheses instead of vague indicator combinations. Educational research tool—not a profit claim, trading signal, or substitute for independent testing.
...more
Added over 1 month ago
Report
Browse Marketplace