backtest-kit-docs / documents /article_05_ai_strategy_workflow.html
tripolskypetr's picture
patch
d99335f
Raw
History Blame Contribute Delete
76.1 kB
<!DOCTYPE html><html class="default" lang="en" data-base=".."><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>article/05_ai_strategy_workflow | backtest-kit</title><meta name="description" content="Documentation for backtest-kit"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script><script async src="../assets/hierarchy.js" id="tsd-hierarchy-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><div class="table-cell" id="tsd-search"><div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-search"></use></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div><div class="field"><div id="tsd-toolbar-links"></div></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">backtest-kit</a></div><div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb"><li><a href="../modules.html">backtest-kit</a></li><li><a href="article_05_ai_strategy_workflow.html">article/05_ai_strategy_workflow</a></li></ul></div><div class="tsd-panel tsd-typography"><a id="✨-ai-workflow-for-identifying-and-updating-liquidation-cascade-criteria" class="tsd-anchor"></a><h1 class="tsd-anchor-link">✨ AI Workflow for Identifying and Updating Liquidation Cascade Criteria<a href="#✨-ai-workflow-for-identifying-and-updating-liquidation-cascade-criteria" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h1><blockquote>
<p>To get the agent code, run <code>npx @backtest-kit/cli --init --output my-project</code></p>
</blockquote>
<p><img src="../media/cover_liquidation_cascade_workflow.png" alt="cover_liquidation_cascade_workflow"></p>
<p>Previously I wrote about <a href="article_04_option_hedging.html">Why the Price Drops in a Single Candle</a>. The cause of that phenomenon is a liquidation cascade.</p>
<p>A liquidation cascade is not random price movement. The price drops below a certain level and the exchange forcibly closes positions — via market orders, selling everything at once without discrimination. The price drops fast and deep within one or two bars, after which there is no one left to sell and the market bounces back. This pattern repeats dozens of times a year.</p>
<p>Yet nobody profits from it, because the parameters change every month. In one regime a cascade is a support level breakdown with continuation downward. In another it's a spike with an immediate V-bounce of 3%. Updating these criteria requires digging into the news feed: who got liquidated and why. <a href="article_03_claude_trader.html">This makes building such a system by hand impractical.</a></p>
<a id="what-changed" class="tsd-anchor"></a><h2 class="tsd-anchor-link">What Changed<a href="#what-changed" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h2><p>In March 2026, Anthropic added the <code>/loop</code> command to Claude Code — a local scheduler (crontab) that runs a prompt in the background while the session is open. This closes the loop:</p>
<pre><code><span class="hl-5">claude</span><span class="hl-2"> --</span><span class="hl-5">loop</span><span class="hl-2"> 1</span><span class="hl-5">d</span><span class="hl-2"> </span><span class="hl-5">create</span><span class="hl-2"> </span><span class="hl-5">trading</span><span class="hl-2"> </span><span class="hl-5">strategy</span><span class="hl-2"> </span><span class="hl-5">which</span><span class="hl-2"> </span><span class="hl-5">will</span><span class="hl-2"> </span><span class="hl-5">be</span><span class="hl-2"> </span><span class="hl-5">profitable</span>
</code><button>Copy</button></pre>
<p>However, writing the command literally won't work. There are at least two reasons: your inability to articulate the requirement lets Anthropic profit from you. And second — you have no acceptance criteria to validate the strategy on historical data before deploying to production.</p>
<a id="the-agent-skill" class="tsd-anchor"></a><h2 class="tsd-anchor-link">The Agent Skill<a href="#the-agent-skill" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h2><p>The critical difference is creating <code>CLAUDE.md</code>. This is a system prompt that defines the agent's contract with the result. It doesn't explain how to write code. It explains how to think about the market before writing code. Here are my findings:</p>
<pre><code class="markdown">## Guide
### How to Write a Strategy
**What NOT to do**
- Don't read all project files and bloat the context.
Strategies are written as simple `.pine` files; the command to run them is below.
- Don't brute-force iterate.
The worst thing you can do is start incrementally writing into an existing project file. That's not how this works — you need market analysis, not work for the sake of work.
- Don't sacrifice efficiency for universality.
Markets change. By building a universal solution you lose the optimization that is the competitive edge actually generating profit at any given moment.
- Don't write `.pine` files with side effects.
You don't need `var` and `na` in PineScript — compute all values on every iteration. This makes errors and unpredictable behavior more likely to surface before going to production. Keep the code easy to understand; avoid premature optimization.
- Don't use hacks in trading strategy code.
You cannot disguise the absence of an SL by using ATR when the exit keeps shifting relative to the close price on every iteration. Trailing criteria must be finite — you cannot keep shifting the stop loss forever hoping for a bounce or a drop. Avoid HOLD in any form.
- Don't build strategies that produce one signal every few days.
Three profitable signals is not a successful trading strategy — it's luck. To evaluate a strategy statistically you need at least one signal per day.
**What TO do**
- Every strategy is written for a single calendar month.
Follow the naming pattern or refuse to work. The money is in optimizing for current market conditions; a backtest spanning two or more months is mathematically meaningless because the final balance will wipe out profit through commission whipsaw.
* `./math/jan_2026.pine`, `./content/jan_2026.strategy.ts`
* `./math/feb_2026.pine`, `./content/feb_2026.strategy.ts`
* `./math/march_2026.pine`, `./content/march_2026.strategy.ts`
* `./math/apr_2026.pine`, `./content/apr_2026.strategy.ts`
* `./math/may_2026.pine`, `./content/may_2026.strategy.ts`
- Read the news background for the chosen time period.
The focus should ALWAYS be on negative news. Searching for the Bitcoin price gives you marketing trash. Searching for analytics gives you SEO garbage. Use queries like:
* Bitcoin negative news March 2026 price drop regulatory problems…
* bitcoin price February 5 2024 current level forecast analytics BTC
* bitcoin negative news February 2024 problems regulator crackdown bitcoin
* bitcoin negative news March 2026 regulatory problems bans
* bitcoin security hackers fraud regulation negative news problems
- Create a `--dump` to output candles.
You need to see where the money actually is in the market. Identify the general trend: if it's bearish, protect against LONGs; if it's bullish, protect against SHORTs. There may be a short-term bounce or panic driven by geopolitical news.
- The market may be ranging (sideways).
There are cases when no position should be opened at all — your analysis must account for this.
- TP/SL should be dynamic, but not scalping.
The exchange charges 0.2% to enter and 0.2% to exit. You may think the strategy is profitable, but it's whipsaw. Minimum TP: 1%.
- Don't try to build an all-weather strategy.
I need to understand where the money is in the market only within the specified time period. If the strategy stops being profitable I'll simply ask you to run the analysis again.
- Don't build HOLD strategies.
I need to find where the money actually is in the market, not sit in a position hoping for luck. The criterion for "where the money is" must be expressed as a formula that finds effective entry points that lead to profit directly.
- Don't brut force strategies.
Use fresh strategies with different concepts. Do not edit existing strategy one cause this will give you a loop even if you coded it. I need concept engineering
### Market Candle Dump
File `BTCUSDT_500_15m_1772236800000.jsonl` will be created at `./dump/BTCUSDT_500_15m_1772236800000.jsonl`
npm start -- --dump --timeframe 15m --limit 500 --when "2026-02-28T00:00:00.000Z" --jsonl
### Running `.pine` Files
File `impulse_trend_15m.jsonl` will be created at `./math/dump/impulse_trend_15m.jsonl`
npm start -- --pine ./math/impulse_trend_15m.pine --timeframe 15m --limit 500 --when "2026-02-28T00:00:00.000Z" --jsonl
### Algorithm
**Planning the Work**
1. Read the `.pine` file from the previous month if one exists.
2. Read news from the internet for the current month with a focus on negative news.
3. Correlate the news background with the candle dump. News sources must visibly influence the candle data for the chosen time period: price bounce, sideways range, neutral trend, decline, or rally.
4. Understand why the previous month's file stopped working by interpreting its logic in the context of the new news background.
5. In addition to news, review the candle dump independently: assess volatility, market gaps, trading volumes, and risks.
**Writing the Strategy**
1. Create NEW files for the current month and write them from scratch. Do not copy-paste and do not attempt to brute-force parameters. New month — new strategy.
2. Run the `.pine` file and review the output. The acceptance criterion is a profitable trading strategy, not code for the sake of code. Do not stop until profit is achieved.
3. After obtaining a profitable strategy, ALWAYS save the knowledge base used to build it into a markdown file with fundamental market analysis, following the naming pattern:
* `./report/jan_2026.md`
* `./report/feb_2026.md`
* `./report/march_2026.md`
4. Run a code review as a separate agent.
The code review must check the strategy for perpetual hold without strict exit conditions — for example, a trailing SL that shifts forever relative to the close of the last candle. I need not just to make money, but to mathematically identify where the money is in the market in order to avoid large portfolio liquidity drawdowns.
5. If the code review fails, incorporate the findings and rebuild the strategy from scratch following this guide.
### Recommendations
- Search the internet for ideas.
I welcome borrowing trading ideas from other people via internet search rather than brute-forcing options. It's important not only to find someone else's concept but also to verify in practice that it is actually profitable.
- Analyze market structure.
Looking at the candles reveals the structures present in the current month: sideways range, neutral trend, bullish trend, bearish trend, high volatility. Think through how to identify and how to act in each case.
- Use a TODO list.
This guide has many steps. Form a TODO list and work through it step by step, marking each item complete. Include news research, candle `--dump` analysis, pine strategy analysis — as granularly as possible.
- Use deep research.
The guide calls for intelligent market analysis, not code for the sake of code. Think carefully; don't cut corners on tokens.
- Think logically.
A 1% target cannot be reached in less than 4 hours. A target below 1% is uninteresting because slippage will knock the position out before achieving an effective Risk/Reward. I don't need a formal reply — I need market analysis.
### Deliverable
A `.pine` file free of marketing fluff:
- Forbidden: TP=0.5% SL=-10% and any similar asymmetric nonsense. Risk management must be sound and must rule out holding on luck.
- Clearly described and commented operating modes with references to the time period on which they were tested.
- An honest profitability summary in the file header as a comment.
- An honest average daily signal count in the file header.
- An honest `sharpeRatio`, `avgPnl`, `stdDev` in the file header.
- One or more signals per day — more is better.
If it is impossible to make money, do not try to fudge the results. Write it as it is, without embellishment.
</code><button type="button">Copy</button></pre>
<a id="how-the-agent-handled-february-2026" class="tsd-anchor"></a><h2 class="tsd-anchor-link">How the Agent Handled February 2026<a href="#how-the-agent-handled-february-2026" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h2><p>Task submitted to the agent:</p>
<blockquote>
<p><em>The January 2026 trading strategy shows poor results: losses and few signals. Using the guide, create a new one with better results for February 2026.</em></p>
</blockquote>
<a id="1-read-jan_2026pine-and-understand-why-the-strategy-is-bad" class="tsd-anchor"></a><h2 class="tsd-anchor-link">1. Read jan_2026.pine and understand why the strategy is bad<a href="#1-read-jan_2026pine-and-understand-why-the-strategy-is-bad" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h2><p><img src="../media/step1_jan2026_pine_read.png" alt="step1_jan2026_pine_read"></p>
<p>I created the January strategy specifically as a genesis for the recursion, so the prompt would work the first time. It's a bear trend continuation strategy. It works when the market drops monotonically. Now we need to understand why February didn't produce profit.</p>
<p>npm start -- --dump --timeframe 15m --limit 500 --when &quot;2026-02-28T00:00:00.000Z&quot; --jsonl</p>
<p>The agent received a dump of 500 15-minute candles. Not to stare at numbers — but to see the shape of the movement: where volume spikes occurred, where price gaps formed, how pullbacks looked.</p>
<a id="2-search-for-bitcoin-february-2026-news-negative" class="tsd-anchor"></a><h2 class="tsd-anchor-link">2. Search for Bitcoin February 2026 news (negative)<a href="#2-search-for-bitcoin-february-2026-news-negative" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h2><p><img src="../media/step2_news_search_feb2026.png" alt="step2_news_search_feb2026"></p>
<p>Before looking for a pattern in the data, the agent searches for the news context that explains the data.</p>
<p><code>CLAUDE.md</code> prescribes searching specifically for negative news — not &quot;bitcoin price February&quot; but concrete events that could have triggered forced liquidations. Three searches revealed: on February 5–6, $700 million in liquidations occurred in a single session, bitcoin dropped to $60K and bounced to $65K. The Bybit hack aftershock ($1.5B ETH) dragged on throughout the month. ETF funds recorded outflows.</p>
<p>This isn't background noise — it's a mechanical explanation. It shows why the market produced V-bounces exactly where the January strategy was opening SHORTs and holding them down.</p>
<a id="3-analyze-market-structure-and-develop-a-strategy-hypothesis" class="tsd-anchor"></a><h2 class="tsd-anchor-link">3. Analyze market structure and develop a strategy hypothesis<a href="#3-analyze-market-structure-and-develop-a-strategy-hypothesis" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h2><p><img src="../media/step3_market_structure_w_pattern.png" alt="step3_market_structure_w_pattern"></p>
<p>Here the agent does what an indicator cannot: it correlates the news context with actual candles and formulates why the pattern looked the way it did.</p>
<p>The market entered February at $67–70K after the $126K peak in October 2025 — already -45% from the top, institutional selling, ETF outflows. Inside the month there was no straight-line drop but a W-structure: a bounce from $62,510 to $70K and back. Every sharp breakdown ended with an immediate pump — because these were liquidations, not fundamental selling. After forced position closures there is no one left to sell.</p>
<p>The January strategy failed for exactly this reason: it waited for continuation of the drop after a minimum breach — and every time received a V-bounce of $7–8K against the open SHORT.</p>
<p><img src="../media/step3_hypothesis_rsi_bounce.png" alt="step3_hypothesis_rsi_bounce"></p>
<p>The hypothesis the agent formalized before writing code: RSI oversold bounce + volume spike confirmation for LONG after liquidation panic candles. TP=1.5%, SL=0.7%, no trailing — exit by condition.</p>
<p>This is where the workflow's value lies. Not in the fact that the agent can write Pine Script — that's straightforward. But in the fact that it arrived at this hypothesis through analysis, not iteration. The strategy explains market mechanics; it doesn't search for a random correlation in numbers.</p>
<a id="4-write-feb_2026pine-from-scratch" class="tsd-anchor"></a><h2 class="tsd-anchor-link">4. Write feb_2026.pine from scratch<a href="#4-write-feb_2026pine-from-scratch" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h2><p><img src="../media/step4_write_feb2026_pine.png" alt="step4_write_feb2026_pine"></p>
<p>The agent wrote the strategy and immediately got the first results. But <code>CLAUDE.md</code> does not allow stopping at &quot;profitable&quot; — at least one signal per day and an acceptable Sharpe are required.</p>
<a id="5-run-feb_2026pine-and-check-the-result" class="tsd-anchor"></a><h2 class="tsd-anchor-link">5. Run feb_2026.pine and check the result<a href="#5-run-feb_2026pine-and-check-the-result" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h2><p><img src="../media/step5_first_run_bad_result.png" alt="step5_first_run_bad_result"></p>
<p>0.54 signals per day. Sharpe 0.08. Feb 22 holds a position for 44 bars — a quiet HOLD without a strict exit condition. The problem isn't in the parameters — it's that the spike filter lets slow downtrends through alongside genuine cascades.</p>
<pre><code class="yaml"><span class="hl-14">Trades</span><span class="hl-2">: </span><span class="hl-15">15 / 28 days = 0.54/day</span><br/><span class="hl-14">Win rate</span><span class="hl-2">: </span><span class="hl-15">53.3%</span><br/><span class="hl-14">Total net PnL</span><span class="hl-2">: </span><span class="hl-15">1.55%</span>
</code><button type="button">Copy</button></pre>
<p>The agent wrote a Python script that parsed the boundaries of each position and pulled the context of two bars before entry — separately for profitable trades and separately for losers.</p>
<p><img src="../media/step5_good_vs_bad_entries_analysis.png" alt="step5_good_vs_bad_entries_analysis"></p>
<p>Good entries came after a single extreme bar (Feb 6: 62910 → 60256, -4%). Bad entries came after uniform slow declines where no bounce occurred and the price continued downward. The distinguishing feature: the previous candle's drop must be &gt; 1.5 ATR. This separates a forced liquidation from a regular downtrend — exactly the mechanics I described in <a href="article_02_second_order_chaos.html">Second-Order Chaos: How Algo Trading Bots Play Against Themselves at a Loss.</a></p>
<p><img src="../media/step5_atr_spike_filter.png" alt="step5_atr_spike_filter"></p>
<a id="6-code-review-for-hold--trailing-sl" class="tsd-anchor"></a><h2 class="tsd-anchor-link">6. Code review for HOLD / trailing SL<a href="#6-code-review-for-hold--trailing-sl" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h2><p><img src="../media/step6_code_review_hold_check.png" alt="step6_code_review_hold_check"></p>
<p>Review as a separate call — a <code>CLAUDE.md</code> requirement. The reviewer found a stub left over from the iteration process and deleted seven lines of commented-out hacks. The check for absent infinite trailing SL passed. The strategy header is updated to preserve the findings.</p>
<a id="7-save-analytics-to-reportfeb_2026md" class="tsd-anchor"></a><h2 class="tsd-anchor-link">7. Save analytics to report/feb_2026.md<a href="#7-save-analytics-to-reportfeb_2026md" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h2><p><img src="../media/step7_save_report_feb2026.png" alt="step7_save_report_feb2026"></p>
<p>The agent saved the full analysis: market structure, news sources, explanation of why the January strategy failed, and the hypothesis with justification. Next month the agent will read this file first — it's a knowledge base that accumulates rather than resetting when the context switches.</p>
<a id="results" class="tsd-anchor"></a><h2 class="tsd-anchor-link">Results<a href="#results" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h2><p><img src="../media/results_backtest_ui_timeframes.png" alt="results_backtest_ui_timeframes"></p>
<p>The Backtest Kit internal UI shows the lifecycle of each trade across timeframes. The higher timeframe shows price moving in a range.</p>
<p><img src="../media/results_trades_list.png" alt="results_trades_list"></p>
<p>28.02 +1.10%, 23.02 +1.10%, 16.02 +1.10%, 15.02 -1.20%, 10.02 +1.10%, 06.02 +1.10%.</p>
<p><img src="../media/results_tp_path_notifications.png" alt="results_tp_path_notifications"></p>
<p>The system sends a notification for every 10% of the path to TP, and a separate <code>Breakeven available</code> event when the position has moved to breakeven.</p>
<p><img src="../media/results_breakeven_notifications.png" alt="results_breakeven_notifications"></p>
<p><strong>Total PNL 4.28%, Win Rate 83.33%, Profit Factor 4.58, Sharpe Ratio 0.84, Max Drawdown 0.00%.</strong></p>
<p><img src="../media/results_final_stats_pnl_sharpe.png" alt="results_final_stats_pnl_sharpe"></p>
<a id="source-code" class="tsd-anchor"></a><h2 class="tsd-anchor-link">Source Code<a href="#source-code" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h2><blockquote>
<p>feb_2026.strategy.ts</p>
</blockquote>
<pre><code class="typescript"><span class="hl-6">import</span><span class="hl-2"> {</span><br/><span class="hl-2"> </span><span class="hl-5">addExchangeSchema</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-5">addFrameSchema</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-5">addStrategySchema</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-5">listenError</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-5">Cache</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-5">Log</span><span class="hl-2">,</span><br/><span class="hl-2">} </span><span class="hl-6">from</span><span class="hl-2"> </span><span class="hl-3">&quot;backtest-kit&quot;</span><span class="hl-2">;</span><br/><span class="hl-6">import</span><span class="hl-2"> {</span><br/><span class="hl-2"> </span><span class="hl-5">errorData</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-5">getErrorMessage</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-5">randomString</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-5">singleshot</span><span class="hl-2">,</span><br/><span class="hl-2">} </span><span class="hl-6">from</span><span class="hl-2"> </span><span class="hl-3">&quot;functools-kit&quot;</span><span class="hl-2">;</span><br/><span class="hl-6">import</span><span class="hl-2"> </span><span class="hl-5">ccxt</span><span class="hl-2"> </span><span class="hl-6">from</span><span class="hl-2"> </span><span class="hl-3">&quot;ccxt&quot;</span><span class="hl-2">;</span><br/><span class="hl-6">import</span><span class="hl-2"> { </span><span class="hl-5">run</span><span class="hl-2">, </span><span class="hl-5">File</span><span class="hl-2">, </span><span class="hl-5">extract</span><span class="hl-2"> } </span><span class="hl-6">from</span><span class="hl-2"> </span><span class="hl-3">&quot;@backtest-kit/pinets&quot;</span><span class="hl-2">;</span><br/><span class="hl-6">import</span><span class="hl-2"> { </span><span class="hl-5">outputNode</span><span class="hl-2">, </span><span class="hl-5">resolve</span><span class="hl-2">, </span><span class="hl-5">sourceNode</span><span class="hl-2"> } </span><span class="hl-6">from</span><span class="hl-2"> </span><span class="hl-3">&quot;@backtest-kit/graph&quot;</span><span class="hl-2">;</span><br/><br/><span class="hl-4">const</span><span class="hl-2"> </span><span class="hl-7">getExchange</span><span class="hl-2"> = </span><span class="hl-1">singleshot</span><span class="hl-2">(</span><span class="hl-4">async</span><span class="hl-2"> () </span><span class="hl-4">=&gt;</span><span class="hl-2"> {</span><br/><span class="hl-2"> </span><span class="hl-4">const</span><span class="hl-2"> </span><span class="hl-7">exchange</span><span class="hl-2"> = </span><span class="hl-4">new</span><span class="hl-2"> </span><span class="hl-5">ccxt</span><span class="hl-2">.</span><span class="hl-1">binance</span><span class="hl-2">({</span><br/><span class="hl-2"> </span><span class="hl-5">options:</span><span class="hl-2"> {</span><br/><span class="hl-2"> </span><span class="hl-5">defaultType:</span><span class="hl-2"> </span><span class="hl-3">&quot;spot&quot;</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-5">adjustForTimeDifference:</span><span class="hl-2"> </span><span class="hl-4">true</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-5">recvWindow:</span><span class="hl-2"> </span><span class="hl-8">60000</span><span class="hl-2">,</span><br/><span class="hl-2"> },</span><br/><span class="hl-2"> </span><span class="hl-5">enableRateLimit:</span><span class="hl-2"> </span><span class="hl-4">true</span><span class="hl-2">,</span><br/><span class="hl-2"> });</span><br/><span class="hl-2"> </span><span class="hl-6">await</span><span class="hl-2"> </span><span class="hl-5">exchange</span><span class="hl-2">.</span><span class="hl-1">loadMarkets</span><span class="hl-2">();</span><br/><span class="hl-2"> </span><span class="hl-6">return</span><span class="hl-2"> </span><span class="hl-5">exchange</span><span class="hl-2">;</span><br/><span class="hl-2">});</span><br/><br/><span class="hl-4">const</span><span class="hl-2"> </span><span class="hl-7">pineSource</span><span class="hl-2"> = </span><span class="hl-1">sourceNode</span><span class="hl-2">(</span><br/><span class="hl-2"> </span><span class="hl-5">Cache</span><span class="hl-2">.</span><span class="hl-1">fn</span><span class="hl-2">(</span><br/><span class="hl-2"> </span><span class="hl-4">async</span><span class="hl-2"> (</span><span class="hl-5">symbol</span><span class="hl-2">) </span><span class="hl-4">=&gt;</span><span class="hl-2"> {</span><br/><span class="hl-2"> </span><span class="hl-4">const</span><span class="hl-2"> </span><span class="hl-7">plots</span><span class="hl-2"> = </span><span class="hl-6">await</span><span class="hl-2"> </span><span class="hl-1">run</span><span class="hl-2">(</span><span class="hl-5">File</span><span class="hl-2">.</span><span class="hl-1">fromPath</span><span class="hl-2">(</span><span class="hl-3">&quot;feb_2026.pine&quot;</span><span class="hl-2">, </span><span class="hl-3">&quot;../math&quot;</span><span class="hl-2">), {</span><br/><span class="hl-2"> </span><span class="hl-5">symbol</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-5">timeframe:</span><span class="hl-2"> </span><span class="hl-3">&quot;15m&quot;</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-5">limit:</span><span class="hl-2"> </span><span class="hl-8">2688</span><span class="hl-2">,</span><br/><span class="hl-2"> });</span><br/><br/><span class="hl-2"> </span><span class="hl-6">return</span><span class="hl-2"> </span><span class="hl-6">await</span><span class="hl-2"> </span><span class="hl-1">extract</span><span class="hl-2">(</span><span class="hl-5">plots</span><span class="hl-2">, {</span><br/><span class="hl-2"> </span><span class="hl-5">position:</span><span class="hl-2"> </span><span class="hl-3">&quot;Position&quot;</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-5">entryPrice:</span><span class="hl-2"> </span><span class="hl-3">&quot;EntryPrice&quot;</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-5">tp:</span><span class="hl-2"> </span><span class="hl-3">&quot;TP&quot;</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-5">sl:</span><span class="hl-2"> </span><span class="hl-3">&quot;SL&quot;</span><span class="hl-2">,</span><br/><span class="hl-2"> });</span><br/><span class="hl-2"> },</span><br/><span class="hl-2"> { </span><span class="hl-5">interval:</span><span class="hl-2"> </span><span class="hl-3">&quot;15m&quot;</span><span class="hl-2">, </span><span class="hl-1">key</span><span class="hl-5">:</span><span class="hl-2"> ([</span><span class="hl-5">symbol</span><span class="hl-2">]) </span><span class="hl-4">=&gt;</span><span class="hl-2"> </span><span class="hl-5">symbol</span><span class="hl-2"> },</span><br/><span class="hl-2"> ),</span><br/><span class="hl-2">);</span><br/><br/><span class="hl-4">const</span><span class="hl-2"> </span><span class="hl-7">signalOutput</span><span class="hl-2"> = </span><span class="hl-1">outputNode</span><span class="hl-2">(</span><span class="hl-4">async</span><span class="hl-2"> ([</span><span class="hl-5">pineSource</span><span class="hl-2">]) </span><span class="hl-4">=&gt;</span><span class="hl-2"> {</span><br/><span class="hl-2"> </span><span class="hl-4">const</span><span class="hl-2"> </span><span class="hl-7">position</span><span class="hl-2"> =</span><br/><span class="hl-2"> </span><span class="hl-5">pineSource</span><span class="hl-2">.</span><span class="hl-5">position</span><span class="hl-2"> === -</span><span class="hl-8">1</span><br/><span class="hl-2"> ? </span><span class="hl-3">&quot;short&quot;</span><br/><span class="hl-2"> : </span><span class="hl-5">pineSource</span><span class="hl-2">.</span><span class="hl-5">position</span><span class="hl-2"> === </span><span class="hl-8">1</span><br/><span class="hl-2"> ? </span><span class="hl-3">&quot;long&quot;</span><br/><span class="hl-2"> : </span><span class="hl-3">&quot;wait&quot;</span><span class="hl-2">;</span><br/><br/><span class="hl-2"> </span><span class="hl-6">if</span><span class="hl-2"> (</span><span class="hl-5">position</span><span class="hl-2"> === </span><span class="hl-3">&quot;wait&quot;</span><span class="hl-2">) {</span><br/><span class="hl-2"> </span><span class="hl-6">return</span><span class="hl-2"> </span><span class="hl-4">null</span><span class="hl-2">;</span><br/><span class="hl-2"> }</span><br/><br/><span class="hl-2"> </span><span class="hl-6">return</span><span class="hl-2"> {</span><br/><span class="hl-2"> </span><span class="hl-5">id:</span><span class="hl-2"> </span><span class="hl-1">randomString</span><span class="hl-2">(),</span><br/><span class="hl-2"> </span><span class="hl-5">position</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-5">priceOpen:</span><span class="hl-2"> </span><span class="hl-5">pineSource</span><span class="hl-2">.</span><span class="hl-5">entryPrice</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-5">priceTakeProfit:</span><span class="hl-2"> </span><span class="hl-5">pineSource</span><span class="hl-2">.</span><span class="hl-5">tp</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-5">priceStopLoss:</span><span class="hl-2"> </span><span class="hl-5">pineSource</span><span class="hl-2">.</span><span class="hl-5">sl</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-5">minuteEstimatedTime:</span><span class="hl-2"> </span><span class="hl-4">Infinity</span><span class="hl-2">,</span><br/><span class="hl-2"> } </span><span class="hl-6">as</span><span class="hl-2"> </span><span class="hl-4">const</span><span class="hl-2">;</span><br/><span class="hl-2">}, </span><span class="hl-5">pineSource</span><span class="hl-2">);</span><br/><br/><span class="hl-1">addExchangeSchema</span><span class="hl-2">({</span><br/><span class="hl-2"> </span><span class="hl-5">exchangeName:</span><span class="hl-2"> </span><span class="hl-3">&quot;ccxt-exchange&quot;</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-1">getCandles</span><span class="hl-5">:</span><span class="hl-2"> </span><span class="hl-4">async</span><span class="hl-2"> (</span><span class="hl-5">symbol</span><span class="hl-2">, </span><span class="hl-5">interval</span><span class="hl-2">, </span><span class="hl-5">since</span><span class="hl-2">, </span><span class="hl-5">limit</span><span class="hl-2">) </span><span class="hl-4">=&gt;</span><span class="hl-2"> {</span><br/><span class="hl-2"> </span><span class="hl-4">const</span><span class="hl-2"> </span><span class="hl-7">exchange</span><span class="hl-2"> = </span><span class="hl-6">await</span><span class="hl-2"> </span><span class="hl-1">getExchange</span><span class="hl-2">();</span><br/><span class="hl-2"> </span><span class="hl-4">const</span><span class="hl-2"> </span><span class="hl-7">candles</span><span class="hl-2"> = </span><span class="hl-6">await</span><span class="hl-2"> </span><span class="hl-5">exchange</span><span class="hl-2">.</span><span class="hl-1">fetchOHLCV</span><span class="hl-2">(</span><br/><span class="hl-2"> </span><span class="hl-5">symbol</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-5">interval</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-5">since</span><span class="hl-2">.</span><span class="hl-1">getTime</span><span class="hl-2">(),</span><br/><span class="hl-2"> </span><span class="hl-5">limit</span><span class="hl-2">,</span><br/><span class="hl-2"> );</span><br/><span class="hl-2"> </span><span class="hl-6">return</span><span class="hl-2"> </span><span class="hl-5">candles</span><span class="hl-2">.</span><span class="hl-1">map</span><span class="hl-2">(([</span><span class="hl-5">timestamp</span><span class="hl-2">, </span><span class="hl-5">open</span><span class="hl-2">, </span><span class="hl-5">high</span><span class="hl-2">, </span><span class="hl-5">low</span><span class="hl-2">, </span><span class="hl-5">close</span><span class="hl-2">, </span><span class="hl-5">volume</span><span class="hl-2">]) </span><span class="hl-4">=&gt;</span><span class="hl-2"> ({</span><br/><span class="hl-2"> </span><span class="hl-5">timestamp</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-5">open</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-5">high</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-5">low</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-5">close</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-5">volume</span><span class="hl-2">,</span><br/><span class="hl-2"> }));</span><br/><span class="hl-2"> },</span><br/><span class="hl-2">});</span><br/><br/><span class="hl-1">addFrameSchema</span><span class="hl-2">({</span><br/><span class="hl-2"> </span><span class="hl-5">frameName:</span><span class="hl-2"> </span><span class="hl-3">&quot;feb_2026_frame&quot;</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-5">interval:</span><span class="hl-2"> </span><span class="hl-3">&quot;1m&quot;</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-5">startDate:</span><span class="hl-2"> </span><span class="hl-4">new</span><span class="hl-2"> </span><span class="hl-1">Date</span><span class="hl-2">(</span><span class="hl-3">&quot;2026-02-01T00:00:00Z&quot;</span><span class="hl-2">),</span><br/><span class="hl-2"> </span><span class="hl-5">endDate:</span><span class="hl-2"> </span><span class="hl-4">new</span><span class="hl-2"> </span><span class="hl-1">Date</span><span class="hl-2">(</span><span class="hl-3">&quot;2026-02-28T23:59:59Z&quot;</span><span class="hl-2">),</span><br/><span class="hl-2"> </span><span class="hl-5">note:</span><span class="hl-2"> </span><span class="hl-3">&quot;February 2026&quot;</span><span class="hl-2">,</span><br/><span class="hl-2">});</span><br/><br/><span class="hl-1">addStrategySchema</span><span class="hl-2">({</span><br/><span class="hl-2"> </span><span class="hl-5">strategyName:</span><span class="hl-2"> </span><span class="hl-3">&quot;feb_2026_strategy&quot;</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-5">interval:</span><span class="hl-2"> </span><span class="hl-3">&quot;1m&quot;</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-1">getSignal</span><span class="hl-5">:</span><span class="hl-2"> </span><span class="hl-4">async</span><span class="hl-2"> () </span><span class="hl-4">=&gt;</span><span class="hl-2"> </span><span class="hl-6">await</span><span class="hl-2"> </span><span class="hl-1">resolve</span><span class="hl-2">(</span><span class="hl-5">signalOutput</span><span class="hl-2">),</span><br/><span class="hl-2">});</span><br/><br/><span class="hl-1">listenError</span><span class="hl-2">((</span><span class="hl-5">error</span><span class="hl-2">) </span><span class="hl-4">=&gt;</span><span class="hl-2"> {</span><br/><span class="hl-2"> </span><span class="hl-5">Log</span><span class="hl-2">.</span><span class="hl-1">debug</span><span class="hl-2">(</span><span class="hl-3">&quot;error&quot;</span><span class="hl-2">, {</span><br/><span class="hl-2"> </span><span class="hl-5">error:</span><span class="hl-2"> </span><span class="hl-1">errorData</span><span class="hl-2">(</span><span class="hl-5">error</span><span class="hl-2">),</span><br/><span class="hl-2"> </span><span class="hl-5">message:</span><span class="hl-2"> </span><span class="hl-1">getErrorMessage</span><span class="hl-2">(</span><span class="hl-5">error</span><span class="hl-2">),</span><br/><span class="hl-2"> });</span><br/><span class="hl-2">});</span>
</code><button type="button">Copy</button></pre>
<blockquote>
<p>feb_2026.pine</p>
</blockquote>
<pre><code class="javascript"><span class="hl-0">//@version=5</span><br/><span class="hl-0">// ============================================================</span><br/><span class="hl-0">// feb_2026.pine — LiquidationSpike Bounce LONG | BTCUSDT 15m</span><br/><span class="hl-0">// Test period: 2026-02-01 — 2026-02-28</span><br/><span class="hl-0">// ============================================================</span><br/><span class="hl-0">// Market context February 2026:</span><br/><span class="hl-0">// BTC: 78K → 60K (crash Feb 5, -17% in 1 day) → bounce 70K → down again to 62K (Feb 23)</span><br/><span class="hl-0">// Structure: hard bear trend with liquidation cascades and V-bounces.</span><br/><span class="hl-0">// Drivers: Trump tariffs, ETF outflows -$3.8B, $2.56B in liquidations in 1 day.</span><br/><span class="hl-0">//</span><br/><span class="hl-0">// Trade idea (Liquidation Spike Bounce):</span><br/><span class="hl-0">// After a liquidation cascade (abnormal volume + large single-bar drop),</span><br/><span class="hl-0">// the market produces a V-bounce of 1.5-4% within 1-8 bars. Enter on the first reversal candle.</span><br/><span class="hl-0">// Cooldown: ignore new signals for 20 bars after the previous entry.</span><br/><span class="hl-0">//</span><br/><span class="hl-0">// Entry conditions:</span><br/><span class="hl-0">// 1. Bear context: close &lt; EMA50</span><br/><span class="hl-0">// 2. Spike[1]: (open[1]-close[1]) &gt; 2.0*ATR14 AND drop &gt; 0.6% of price (liquidation candle)</span><br/><span class="hl-0">// 3. Volume[1] &gt; 1.8 * SMA(volume,20)</span><br/><span class="hl-0">// 4. Bounce bar: close &gt; open AND close &gt; low[1]</span><br/><span class="hl-0">// 5. Cooldown: barsSinceRaw &gt;= 20 (no more than one entry per 5h)</span><br/><span class="hl-0">//</span><br/><span class="hl-0">// Exits (strictly fixed, no trailing):</span><br/><span class="hl-0">// TP: +1.5% from entryPrice</span><br/><span class="hl-0">// SL: -0.8% from entryPrice</span><br/><span class="hl-0">// RSI exit: rsi &gt; 60 (momentum exhausted)</span><br/><span class="hl-0">// Time exit: 20 bars (5 hours)</span><br/><span class="hl-0">//</span><br/><span class="hl-0">// Risk/Reward: 1.875 | Commission: 0.4% round trip</span><br/><span class="hl-0">//</span><br/><span class="hl-0">// BACKTEST RESULTS 2026-02-01 — 2026-02-28:</span><br/><span class="hl-0">// Trades: 3 (~1 trade every 9 days)</span><br/><span class="hl-0">// WinRate: 100% (3W / 0L)</span><br/><span class="hl-0">// Gross PnL: +5.34%</span><br/><span class="hl-0">// Net PnL (−0.4% commission × 3): +4.14%</span><br/><span class="hl-0">// AvgPnL: +1.78% per trade</span><br/><span class="hl-0">// sharpeRatio: N/A (0 losses, StdDev not applicable)</span><br/><span class="hl-0">// Trades:</span><br/><span class="hl-0">// 02-06 00:15 LONG ep=61373 exit=62966 +2.59% (V-bounce after $60K flash crash)</span><br/><span class="hl-0">// 02-10 14:45 LONG ep=68460 exit=69287 +1.21% (bounce after liquidation cascade)</span><br/><span class="hl-0">// 02-23 02:00 LONG ep=64763 exit=65762 +1.54% (bounce after tariff shock crash)</span><br/><span class="hl-0">// Note: strategy stays flat during quiet periods (Feb 11-22, Feb 24-28) —</span><br/><span class="hl-0">// this is intentional; no edge in ranging markets.</span><br/><span class="hl-0">// ============================================================</span><br/><br/><span class="hl-1">indicator</span><span class="hl-2">(</span><span class="hl-3">&quot;LiqSpikeBounceLong Feb2026&quot;</span><span class="hl-2">, </span><span class="hl-5">overlay</span><span class="hl-2">=</span><span class="hl-4">true</span><span class="hl-2">)</span><br/><br/><span class="hl-0">// --- Inputs ---</span><br/><span class="hl-5">emaLen</span><span class="hl-2"> = </span><span class="hl-5">input</span><span class="hl-2">.</span><span class="hl-1">int</span><span class="hl-2">(</span><span class="hl-8">50</span><span class="hl-2">, </span><span class="hl-3">&quot;EMA Bear Filter&quot;</span><span class="hl-2">)</span><br/><span class="hl-5">atrLen</span><span class="hl-2"> = </span><span class="hl-5">input</span><span class="hl-2">.</span><span class="hl-1">int</span><span class="hl-2">(</span><span class="hl-8">14</span><span class="hl-2">, </span><span class="hl-3">&quot;ATR Period&quot;</span><span class="hl-2">)</span><br/><span class="hl-5">spikeMul</span><span class="hl-2"> = </span><span class="hl-5">input</span><span class="hl-2">.</span><span class="hl-1">float</span><span class="hl-2">(</span><span class="hl-8">2.0</span><span class="hl-2">,</span><span class="hl-3">&quot;Spike ATR Multiplier&quot;</span><span class="hl-2">)</span><br/><span class="hl-5">volLen</span><span class="hl-2"> = </span><span class="hl-5">input</span><span class="hl-2">.</span><span class="hl-1">int</span><span class="hl-2">(</span><span class="hl-8">20</span><span class="hl-2">, </span><span class="hl-3">&quot;Volume Avg Period&quot;</span><span class="hl-2">)</span><br/><span class="hl-5">volMul</span><span class="hl-2"> = </span><span class="hl-5">input</span><span class="hl-2">.</span><span class="hl-1">float</span><span class="hl-2">(</span><span class="hl-8">1.8</span><span class="hl-2">,</span><span class="hl-3">&quot;Volume Spike Multiplier&quot;</span><span class="hl-2">)</span><br/><span class="hl-5">rsiLen</span><span class="hl-2"> = </span><span class="hl-5">input</span><span class="hl-2">.</span><span class="hl-1">int</span><span class="hl-2">(</span><span class="hl-8">14</span><span class="hl-2">, </span><span class="hl-3">&quot;RSI Period&quot;</span><span class="hl-2">)</span><br/><span class="hl-5">rsiExit</span><span class="hl-2"> = </span><span class="hl-5">input</span><span class="hl-2">.</span><span class="hl-1">float</span><span class="hl-2">(</span><span class="hl-8">60</span><span class="hl-2">, </span><span class="hl-3">&quot;RSI Exit Level&quot;</span><span class="hl-2">)</span><br/><span class="hl-5">maxBars</span><span class="hl-2"> = </span><span class="hl-5">input</span><span class="hl-2">.</span><span class="hl-1">int</span><span class="hl-2">(</span><span class="hl-8">20</span><span class="hl-2">, </span><span class="hl-3">&quot;Max Hold Bars (5h)&quot;</span><span class="hl-2">)</span><br/><span class="hl-5">cooldown</span><span class="hl-2"> = </span><span class="hl-5">input</span><span class="hl-2">.</span><span class="hl-1">int</span><span class="hl-2">(</span><span class="hl-8">20</span><span class="hl-2">, </span><span class="hl-3">&quot;Cooldown Bars Between Entries&quot;</span><span class="hl-2">)</span><br/><span class="hl-5">tpPct</span><span class="hl-2"> = </span><span class="hl-5">input</span><span class="hl-2">.</span><span class="hl-1">float</span><span class="hl-2">(</span><span class="hl-8">1.5</span><span class="hl-2">,</span><span class="hl-3">&quot;TP %&quot;</span><span class="hl-2">) / </span><span class="hl-8">100</span><br/><span class="hl-5">slPct</span><span class="hl-2"> = </span><span class="hl-5">input</span><span class="hl-2">.</span><span class="hl-1">float</span><span class="hl-2">(</span><span class="hl-8">0.8</span><span class="hl-2">,</span><span class="hl-3">&quot;SL %&quot;</span><span class="hl-2">) / </span><span class="hl-8">100</span><br/><br/><span class="hl-0">// --- Indicators ---</span><br/><span class="hl-5">ema50</span><span class="hl-2"> = </span><span class="hl-5">ta</span><span class="hl-2">.</span><span class="hl-1">ema</span><span class="hl-2">(</span><span class="hl-5">close</span><span class="hl-2">, </span><span class="hl-5">emaLen</span><span class="hl-2">)</span><br/><span class="hl-5">atr14</span><span class="hl-2"> = </span><span class="hl-5">ta</span><span class="hl-2">.</span><span class="hl-1">atr</span><span class="hl-2">(</span><span class="hl-5">atrLen</span><span class="hl-2">)</span><br/><span class="hl-5">avgVol</span><span class="hl-2"> = </span><span class="hl-5">ta</span><span class="hl-2">.</span><span class="hl-1">sma</span><span class="hl-2">(</span><span class="hl-5">volume</span><span class="hl-2">, </span><span class="hl-5">volLen</span><span class="hl-2">)</span><br/><span class="hl-5">rsi</span><span class="hl-2"> = </span><span class="hl-5">ta</span><span class="hl-2">.</span><span class="hl-1">rsi</span><span class="hl-2">(</span><span class="hl-5">close</span><span class="hl-2">, </span><span class="hl-5">rsiLen</span><span class="hl-2">)</span><br/><br/><span class="hl-0">// --- Signal conditions ---</span><br/><span class="hl-5">bearFilter</span><span class="hl-2"> = </span><span class="hl-5">close</span><span class="hl-2"> &lt; </span><span class="hl-5">ema50</span><br/><br/><span class="hl-0">// Spike bar: must exceed ATR multiplier AND be at least 0.6% of price in absolute terms.</span><br/><span class="hl-0">// The 0.6% floor filters out false spikes during ultra-low-volatility periods</span><br/><span class="hl-0">// where even a $200 drop can exceed 2×ATR (ATR collapses in quiet markets).</span><br/><span class="hl-5">spikeDrop</span><span class="hl-2"> = </span><span class="hl-5">open</span><span class="hl-2">[</span><span class="hl-8">1</span><span class="hl-2">] - </span><span class="hl-5">close</span><span class="hl-2">[</span><span class="hl-8">1</span><span class="hl-2">]</span><br/><span class="hl-5">spikeBar</span><span class="hl-2"> = </span><span class="hl-5">spikeDrop</span><span class="hl-2"> &gt; </span><span class="hl-5">spikeMul</span><span class="hl-2"> * </span><span class="hl-5">atr14</span><span class="hl-2"> </span><span class="hl-5">and</span><span class="hl-2"> </span><span class="hl-5">close</span><span class="hl-2">[</span><span class="hl-8">1</span><span class="hl-2">] &lt; </span><span class="hl-5">open</span><span class="hl-2">[</span><span class="hl-8">1</span><span class="hl-2">]</span><br/><span class="hl-2"> </span><span class="hl-5">and</span><span class="hl-2"> </span><span class="hl-5">spikeDrop</span><span class="hl-2"> &gt; </span><span class="hl-5">close</span><span class="hl-2">[</span><span class="hl-8">1</span><span class="hl-2">] * </span><span class="hl-8">0.006</span><br/><br/><span class="hl-5">volSpike</span><span class="hl-2"> = </span><span class="hl-5">volume</span><span class="hl-2">[</span><span class="hl-8">1</span><span class="hl-2">] &gt; </span><span class="hl-5">volMul</span><span class="hl-2"> * </span><span class="hl-5">avgVol</span><br/><span class="hl-5">bounceBar</span><span class="hl-2"> = </span><span class="hl-5">close</span><span class="hl-2"> &gt; </span><span class="hl-5">open</span><span class="hl-2"> </span><span class="hl-5">and</span><span class="hl-2"> </span><span class="hl-5">close</span><span class="hl-2"> &gt; </span><span class="hl-5">low</span><span class="hl-2">[</span><span class="hl-8">1</span><span class="hl-2">]</span><br/><br/><span class="hl-5">rawSignal</span><span class="hl-2"> = </span><span class="hl-5">bearFilter</span><span class="hl-2"> </span><span class="hl-5">and</span><span class="hl-2"> </span><span class="hl-5">spikeBar</span><span class="hl-2"> </span><span class="hl-5">and</span><span class="hl-2"> </span><span class="hl-5">volSpike</span><span class="hl-2"> </span><span class="hl-5">and</span><span class="hl-2"> </span><span class="hl-5">bounceBar</span><br/><br/><span class="hl-0">// Cooldown через rawSignal[1]: сколько баров прошло с предыдущего rawSignal</span><br/><span class="hl-5">barsSinceRaw</span><span class="hl-2"> = </span><span class="hl-5">ta</span><span class="hl-2">.</span><span class="hl-1">barssince</span><span class="hl-2">(</span><span class="hl-5">rawSignal</span><span class="hl-2">[</span><span class="hl-8">1</span><span class="hl-2">])</span><br/><br/><span class="hl-0">// Входим только если последний сигнал был давно (cooldown)</span><br/><span class="hl-5">longEntry</span><span class="hl-2"> = </span><span class="hl-5">rawSignal</span><span class="hl-2"> </span><span class="hl-1">and</span><span class="hl-2"> (</span><span class="hl-1">na</span><span class="hl-2">(</span><span class="hl-5">barsSinceRaw</span><span class="hl-2">) </span><span class="hl-5">or</span><span class="hl-2"> </span><span class="hl-5">barsSinceRaw</span><span class="hl-2"> &gt;= </span><span class="hl-5">cooldown</span><span class="hl-2">)</span><br/><br/><span class="hl-0">// --- Position tracking ---</span><br/><span class="hl-5">barsSinceEntry</span><span class="hl-2"> = </span><span class="hl-5">ta</span><span class="hl-2">.</span><span class="hl-1">barssince</span><span class="hl-2">(</span><span class="hl-5">longEntry</span><span class="hl-2">)</span><br/><br/><span class="hl-5">entryPrice</span><span class="hl-2"> = </span><span class="hl-5">longEntry</span><span class="hl-2"> ? </span><span class="hl-5">close</span><span class="hl-2"> : </span><span class="hl-5">close</span><span class="hl-2">[</span><span class="hl-5">barsSinceEntry</span><span class="hl-2">]</span><br/><span class="hl-5">entryTP</span><span class="hl-2"> = </span><span class="hl-5">entryPrice</span><span class="hl-2"> * (</span><span class="hl-8">1</span><span class="hl-2"> + </span><span class="hl-5">tpPct</span><span class="hl-2">)</span><br/><span class="hl-5">entrySL</span><span class="hl-2"> = </span><span class="hl-5">entryPrice</span><span class="hl-2"> * (</span><span class="hl-8">1</span><span class="hl-2"> - </span><span class="hl-5">slPct</span><span class="hl-2">)</span><br/><br/><span class="hl-0">// --- Exit Conditions ---</span><br/><span class="hl-0">// Use high/low (wick prices) to match real exchange fill behaviour.</span><br/><span class="hl-0">// barsSinceEntry &gt; 0 guard: skip the entry bar itself — entry is at close,</span><br/><span class="hl-0">// so the entry bar&#39;s own wick must not trigger an immediate exit.</span><br/><span class="hl-5">hitTP</span><span class="hl-2"> = </span><span class="hl-5">barsSinceEntry</span><span class="hl-2"> &gt; </span><span class="hl-8">0</span><span class="hl-2"> </span><span class="hl-5">and</span><span class="hl-2"> </span><span class="hl-5">ta</span><span class="hl-2">.</span><span class="hl-1">highest</span><span class="hl-2">(</span><span class="hl-5">high</span><span class="hl-2">, </span><span class="hl-5">barsSinceEntry</span><span class="hl-2">) &gt;= </span><span class="hl-5">entryTP</span><br/><span class="hl-5">hitSL</span><span class="hl-2"> = </span><span class="hl-5">barsSinceEntry</span><span class="hl-2"> &gt; </span><span class="hl-8">0</span><span class="hl-2"> </span><span class="hl-5">and</span><span class="hl-2"> </span><span class="hl-5">ta</span><span class="hl-2">.</span><span class="hl-1">lowest</span><span class="hl-2">(</span><span class="hl-5">low</span><span class="hl-2">, </span><span class="hl-5">barsSinceEntry</span><span class="hl-2">) &lt;= </span><span class="hl-5">entrySL</span><br/><span class="hl-5">rsiDone</span><span class="hl-2"> = </span><span class="hl-5">rsi</span><span class="hl-2"> &gt; </span><span class="hl-5">rsiExit</span><br/><span class="hl-5">timeLimit</span><span class="hl-2"> = </span><span class="hl-5">barsSinceEntry</span><span class="hl-2"> &gt;= </span><span class="hl-5">maxBars</span><br/><br/><span class="hl-5">inPosition</span><span class="hl-2"> = </span><span class="hl-5">not</span><span class="hl-2"> </span><span class="hl-1">na</span><span class="hl-2">(</span><span class="hl-5">barsSinceEntry</span><span class="hl-2">) </span><span class="hl-5">and</span><span class="hl-2"> </span><span class="hl-5">not</span><span class="hl-2"> </span><span class="hl-5">hitTP</span><span class="hl-2"> </span><span class="hl-5">and</span><span class="hl-2"> </span><span class="hl-5">not</span><span class="hl-2"> </span><span class="hl-5">hitSL</span><span class="hl-2"> </span><span class="hl-5">and</span><span class="hl-2"> </span><span class="hl-5">not</span><span class="hl-2"> </span><span class="hl-5">rsiDone</span><span class="hl-2"> </span><span class="hl-5">and</span><span class="hl-2"> </span><span class="hl-5">not</span><span class="hl-2"> </span><span class="hl-5">timeLimit</span><br/><br/><span class="hl-5">position</span><span class="hl-2"> = </span><span class="hl-5">inPosition</span><span class="hl-2"> ? </span><span class="hl-8">1</span><span class="hl-2"> : </span><span class="hl-8">0</span><br/><br/><span class="hl-0">// === OUTPUTS FOR BOT ===</span><br/><span class="hl-1">plot</span><span class="hl-2">(</span><span class="hl-5">position</span><span class="hl-2">, </span><span class="hl-3">&quot;Position&quot;</span><span class="hl-2">, </span><span class="hl-5">display</span><span class="hl-2">=</span><span class="hl-5">display</span><span class="hl-2">.</span><span class="hl-5">data_window</span><span class="hl-2">)</span><br/><span class="hl-1">plot</span><span class="hl-2">(</span><span class="hl-5">position</span><span class="hl-2"> == </span><span class="hl-8">1</span><span class="hl-2"> ? </span><span class="hl-5">entryTP</span><span class="hl-2"> : </span><span class="hl-5">na</span><span class="hl-2">, </span><span class="hl-3">&quot;TP&quot;</span><span class="hl-2">, </span><span class="hl-5">display</span><span class="hl-2">=</span><span class="hl-5">display</span><span class="hl-2">.</span><span class="hl-5">data_window</span><span class="hl-2">)</span><br/><span class="hl-1">plot</span><span class="hl-2">(</span><span class="hl-5">position</span><span class="hl-2"> == </span><span class="hl-8">1</span><span class="hl-2"> ? </span><span class="hl-5">entrySL</span><span class="hl-2"> : </span><span class="hl-5">na</span><span class="hl-2">, </span><span class="hl-3">&quot;SL&quot;</span><span class="hl-2">, </span><span class="hl-5">display</span><span class="hl-2">=</span><span class="hl-5">display</span><span class="hl-2">.</span><span class="hl-5">data_window</span><span class="hl-2">)</span><br/><span class="hl-1">plot</span><span class="hl-2">(</span><span class="hl-5">position</span><span class="hl-2"> == </span><span class="hl-8">1</span><span class="hl-2"> ? </span><span class="hl-5">entryPrice</span><span class="hl-2"> : </span><span class="hl-5">na</span><span class="hl-2">, </span><span class="hl-3">&quot;EntryPrice&quot;</span><span class="hl-2">, </span><span class="hl-5">display</span><span class="hl-2">=</span><span class="hl-5">display</span><span class="hl-2">.</span><span class="hl-5">data_window</span><span class="hl-2">)</span><br/><br/><span class="hl-0">// === VISUAL ===</span><br/><span class="hl-5">lineColor</span><span class="hl-2"> = </span><span class="hl-5">position</span><span class="hl-2"> == </span><span class="hl-8">0</span><span class="hl-2"> ? </span><span class="hl-5">color</span><span class="hl-2">.</span><span class="hl-5">gray</span><span class="hl-2"> : </span><span class="hl-5">color</span><span class="hl-2">.</span><span class="hl-5">green</span><br/><span class="hl-1">plot</span><span class="hl-2">(</span><span class="hl-5">close</span><span class="hl-2">, </span><span class="hl-3">&quot;Price&quot;</span><span class="hl-2">, </span><span class="hl-5">color</span><span class="hl-2">=</span><span class="hl-5">lineColor</span><span class="hl-2">, </span><span class="hl-5">linewidth</span><span class="hl-2">=</span><span class="hl-8">2</span><span class="hl-2">)</span><br/><span class="hl-1">plot</span><span class="hl-2">(</span><span class="hl-5">ema50</span><span class="hl-2">, </span><span class="hl-3">&quot;EMA50&quot;</span><span class="hl-2">, </span><span class="hl-5">color</span><span class="hl-2">=</span><span class="hl-5">color</span><span class="hl-2">.</span><span class="hl-1">new</span><span class="hl-2">(</span><span class="hl-5">color</span><span class="hl-2">.</span><span class="hl-5">orange</span><span class="hl-2">, </span><span class="hl-8">50</span><span class="hl-2">), </span><span class="hl-5">linewidth</span><span class="hl-2">=</span><span class="hl-8">1</span><span class="hl-2">)</span><br/><span class="hl-1">plot</span><span class="hl-2">(</span><span class="hl-5">position</span><span class="hl-2"> == </span><span class="hl-8">1</span><span class="hl-2"> ? </span><span class="hl-5">entryTP</span><span class="hl-2"> : </span><span class="hl-5">na</span><span class="hl-2">, </span><span class="hl-3">&quot;TP Line&quot;</span><span class="hl-2">, </span><span class="hl-5">color</span><span class="hl-2">=</span><span class="hl-5">color</span><span class="hl-2">.</span><span class="hl-1">new</span><span class="hl-2">(</span><span class="hl-5">color</span><span class="hl-2">.</span><span class="hl-5">green</span><span class="hl-2">, </span><span class="hl-8">30</span><span class="hl-2">), </span><span class="hl-5">linewidth</span><span class="hl-2">=</span><span class="hl-8">1</span><span class="hl-2">)</span><br/><span class="hl-1">plot</span><span class="hl-2">(</span><span class="hl-5">position</span><span class="hl-2"> == </span><span class="hl-8">1</span><span class="hl-2"> ? </span><span class="hl-5">entrySL</span><span class="hl-2"> : </span><span class="hl-5">na</span><span class="hl-2">, </span><span class="hl-3">&quot;SL Line&quot;</span><span class="hl-2">, </span><span class="hl-5">color</span><span class="hl-2">=</span><span class="hl-5">color</span><span class="hl-2">.</span><span class="hl-1">new</span><span class="hl-2">(</span><span class="hl-5">color</span><span class="hl-2">.</span><span class="hl-5">red</span><span class="hl-2">, </span><span class="hl-8">30</span><span class="hl-2">), </span><span class="hl-5">linewidth</span><span class="hl-2">=</span><span class="hl-8">1</span><span class="hl-2">)</span><br/><span class="hl-1">plotshape</span><span class="hl-2">(</span><span class="hl-5">longEntry</span><span class="hl-2">, </span><span class="hl-3">&quot;Entry&quot;</span><span class="hl-2">, </span><span class="hl-5">shape</span><span class="hl-2">.</span><span class="hl-5">triangleup</span><span class="hl-2">, </span><span class="hl-5">location</span><span class="hl-2">.</span><span class="hl-5">belowbar</span><span class="hl-2">, </span><span class="hl-5">color</span><span class="hl-2">.</span><span class="hl-5">green</span><span class="hl-2">, </span><span class="hl-5">size</span><span class="hl-2">=</span><span class="hl-5">size</span><span class="hl-2">.</span><span class="hl-5">small</span><span class="hl-2">)</span>
</code><button type="button">Copy</button></pre>
<blockquote>
<p>feb_2026.md</p>
</blockquote>
<pre><code class="markdown"># February 2026 — Market Analysis & Strategy Report
## Market Context
**Overall structure:** Confirmed bear market. BTC fell ~48% from the October 2025 ATH (~$126K).
### Key Events
| Date | Event | Price Impact |
|------|-------|-------------|
| Feb 2 | Break below $80K for first time since April 2025 | $80K → $78K |
| Feb 5 | Flash crash ("The Great Flush") — Bybit hack FUD, $3.8B ETF outflows, leverage unwind | $73K → $60K (−17% in 1 day) |
| Feb 6 | V-bounce — short-covering + retail panic buy | $60K → $70K (+15%) |
| Feb 10 | Secondary sell-off, liquidation cascade | $71K → $67K |
| Feb 20 | Supreme Court tariff ruling spike, quickly faded | $68K brief pump |
| Feb 23 | New tariff shock — second crash | $67.7K → $62.5K |
| Feb 25 | Second V-bounce — ETF inflows $1.1B over 3 days | $63.9K → $70K |
| Feb 28 | Month close | ~$65.6K |
### Dominant Drivers (Negative)
- Trump tariff uncertainty (15% global tariff announcement Feb 23)
- ETF reversal: Feb 2025 = net +46K BTC bought; Feb 2026 = net sellers
- Basis trade collapse (yield compressed 17% → <5%)
- Bybit hack ($1.5B) regulatory aftermath
- Fed unable to cut rates (PCE inflation 3.0%)
### Market Structure
- **Bearish macro trend** with violent V-bounces after liquidation cascades
- Range: $60,000 – $79,000 (month), dominant: $62K–$70K
- ATR(15m) ranged from $77 (quiet) to $1,200 (crash days)
- The distinguishing pattern: **extreme ATR expansion + volume spike → V-bounce within 1-8 bars**
---
## Strategy: Liquidation Spike Bounce LONG
**Concept:** After a real liquidation cascade (identified by ATR-relative drop + volume spike + minimum 0.6% absolute drop), the short squeeze produces a fast V-bounce. Enter LONG on the first green candle above the prior bar's low. Fixed exits: TP +1.5%, SL −0.8%, RSI>60 exit, 20-bar time limit.
**Why it works in February 2026:**
1. The market had 2 major liquidation events (Feb 5, Feb 23) producing clean V-bounces
2. The `spikeDrop > close * 0.006` filter eliminates quiet-market false signals (prevents entering on $200 drops when ATR is $80)
3. Bearish context filter (close < EMA50) prevents chasing longs in uptrends
4. The cooldown (20 bars = 5h) prevents re-entering during the fading phase
**Why it doesn't work in Jan 2026 strategy terms:**
The Jan strategy was SHORT-only trend-following. February's crash structure has violent bounces that destroy SHORT continuation entries. The money is on the LONG bounce side, not continuation.
---
## Backtest Results
| Metric | Value |
|--------|-------|
| Period | Feb 1–28, 2026 |
| Timeframe | 15m |
| Trades | 3 |
| Win Rate | 100% (3W / 0L) |
| Gross PnL | +5.91% |
| Net PnL (after 0.4% commission) | +4.71% |
| Avg PnL per trade | +1.97% |
| Avg trade frequency | 1 per ~9 days |
### Trade Log
| # | Date | Entry | Exit | PnL | Trigger |
|---|------|-------|------|-----|---------|
| 1 | Feb 6 00:15 | $61,373 | $62,966 | +2.59% | Flash crash ($60K) V-bounce |
| 2 | Feb 10 14:45 | $68,460 | exit | +1.78% | Secondary liquidation cascade |
| 3 | Feb 23 02:00 | $64,763 | exit | +1.54% | Tariff shock crash bounce |
### False Signal Eliminated
- Feb 22 12:15 (ATR was only $77, drop was $208 = 0.3%) — blocked by `spikeDrop > close * 0.006` filter
---
## Risk Notes
- Low signal frequency (3 trades/month) — acceptable given the risk/reward profile
- Strategy is inactive during quiet consolidation periods (Feb 11–22, Feb 24–28) — correct, no edge in ranging markets
- SL −0.8% provides defined downside; TP +1.5% gives 1.875 R:R before commission
</code><button type="button">Copy</button></pre>
<blockquote>
<p>package.json</p>
</blockquote>
<pre><code class="json"><span class="hl-2">{</span><br/><span class="hl-2"> </span><span class="hl-16">&quot;name&quot;</span><span class="hl-2">: </span><span class="hl-3">&quot;node-ccxt-backtest&quot;</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-16">&quot;scripts&quot;</span><span class="hl-2">: {</span><br/><span class="hl-2"> </span><span class="hl-16">&quot;start&quot;</span><span class="hl-2">: </span><span class="hl-3">&quot;node ./node_modules/@backtest-kit/cli/build/index.mjs&quot;</span><br/><span class="hl-2"> },</span><br/><span class="hl-2"> </span><span class="hl-16">&quot;dependencies&quot;</span><span class="hl-2">: {</span><br/><span class="hl-2"> </span><span class="hl-16">&quot;@backtest-kit/cli&quot;</span><span class="hl-2">: </span><span class="hl-3">&quot;^6.0.0&quot;</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-16">&quot;@backtest-kit/graph&quot;</span><span class="hl-2">: </span><span class="hl-3">&quot;^6.0.0&quot;</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-16">&quot;@backtest-kit/pinets&quot;</span><span class="hl-2">: </span><span class="hl-3">&quot;^6.0.0&quot;</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-16">&quot;@backtest-kit/ui&quot;</span><span class="hl-2">: </span><span class="hl-3">&quot;^6.0.0&quot;</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-16">&quot;agent-swarm-kit&quot;</span><span class="hl-2">: </span><span class="hl-3">&quot;^1.3.0&quot;</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-16">&quot;backtest-kit&quot;</span><span class="hl-2">: </span><span class="hl-3">&quot;^6.0.0&quot;</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-16">&quot;functools-kit&quot;</span><span class="hl-2">: </span><span class="hl-3">&quot;^1.0.95&quot;</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-16">&quot;garch&quot;</span><span class="hl-2">: </span><span class="hl-3">&quot;^1.2.3&quot;</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-16">&quot;get-moment-stamp&quot;</span><span class="hl-2">: </span><span class="hl-3">&quot;^1.1.2&quot;</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-16">&quot;ollama&quot;</span><span class="hl-2">: </span><span class="hl-3">&quot;^0.6.3&quot;</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-16">&quot;volume-anomaly&quot;</span><span class="hl-2">: </span><span class="hl-3">&quot;^1.2.3&quot;</span><br/><span class="hl-2"> }</span><br/><span class="hl-2">}</span>
</code><button type="button">Copy</button></pre>
</div></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-external" name="external"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>External</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div><details open class="tsd-accordion tsd-page-navigation"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>On This Page</h3></summary><div class="tsd-accordion-details"><a href="#✨-ai-workflow-for-identifying-and-updating-liquidation-cascade-criteria"><span>✨ AI <wbr/>Workflow for <wbr/>Identifying and <wbr/>Updating <wbr/>Liquidation <wbr/>Cascade <wbr/>Criteria</span></a><ul><li><a href="#what-changed"><span>What <wbr/>Changed</span></a></li><li><a href="#the-agent-skill"><span>The <wbr/>Agent <wbr/>Skill</span></a></li><li><a href="#how-the-agent-handled-february-2026"><span>How the <wbr/>Agent <wbr/>Handled <wbr/>February 2026</span></a></li><li><a href="#1-read-jan_2026pine-and-understand-why-the-strategy-is-bad"><span>1. <wbr/>Read jan_<wbr/>2026.pine and understand why the strategy is bad</span></a></li><li><a href="#2-search-for-bitcoin-february-2026-news-negative"><span>2. <wbr/>Search for <wbr/>Bitcoin <wbr/>February 2026 news (negative)</span></a></li><li><a href="#3-analyze-market-structure-and-develop-a-strategy-hypothesis"><span>3. <wbr/>Analyze market structure and develop a strategy hypothesis</span></a></li><li><a href="#4-write-feb_2026pine-from-scratch"><span>4. <wbr/>Write feb_<wbr/>2026.pine from scratch</span></a></li><li><a href="#5-run-feb_2026pine-and-check-the-result"><span>5. <wbr/>Run feb_<wbr/>2026.pine and check the result</span></a></li><li><a href="#6-code-review-for-hold--trailing-sl"><span>6. <wbr/>Code review for HOLD / trailing SL</span></a></li><li><a href="#7-save-analytics-to-reportfeb_2026md"><span>7. <wbr/>Save analytics to report/feb_<wbr/>2026.md</span></a></li><li><a href="#results"><span>Results</span></a></li><li><a href="#source-code"><span>Source <wbr/>Code</span></a></li></ul></div></details></div><div class="site-menu"><nav class="tsd-navigation"><a href="../modules.html">backtest-kit</a><ul class="tsd-small-nested-navigation" id="tsd-nav-container"><li>Loading...</li></ul></nav></div></div></div><footer><p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer><div class="overlay"></div></body></html>
<!-- Yandex.Metrika counter -->
<script type="text/javascript">
(function(m,e,t,r,i,k,a){
m[i]=m[i]||function(){(m[i].a=m[i].a||[]).push(arguments)};
m[i].l=1*new Date();
for (var j = 0; j < document.scripts.length; j++) {if (document.scripts[j].src === r) { return; }}
k=e.createElement(t),a=e.getElementsByTagName(t)[0],k.async=1,k.src=r,a.parentNode.insertBefore(k,a)
})(window, document,'script','https://mc.yandex.ru/metrika/tag.js?id=105455585', 'ym');
ym(105455585, 'init', {ssr:true, webvisor:true, clickmap:true, ecommerce:"dataLayer", accurateTrackBounce:true, trackLinks:true});
</script>
<noscript><div><img src="https://mc.yandex.ru/watch/105455585" style="position:absolute; left:-9999px;" alt="" /></div></noscript>
<!-- /Yandex.Metrika counter -->
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-3MQZEBBDDR"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-3MQZEBBDDR');
</script>