# 🧠 AI Agent Optimiser

## &#x20;Runbot AI Agent Optimizer

**Let the AI do the optimizing. You focus on the strategy.**

***

### 📘 Overview

The **AI Agent Optimizer** is a smart assistant designed to automate and simplify the strategy optimization process on Runbot. Instead of manually setting parameters and tuning for hours, the AI Agent guides you through a few quick prompts, understands your goals (APR, drawdown, winrate, etc.), and then handles the entire optimization process using the built-in Optimizer tool.

This feature is ideal for traders who want results fast, without diving into the complexity of backtest logic, parameter grids, or optimization engines.

Video Demo: <https://youtu.be/TXiL6Su-Pf4?si=UyOyrqhPqwo-pFqe>

<figure><img src="https://793384675-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsQezxfp9oB9jrccv5OA4%2Fuploads%2FDtusk72IVOhQrxSsdZtZ%2Fimage.png?alt=media&#x26;token=fcd1d8f7-43f7-443a-9217-4d6fbdec4266" alt="" width="368"><figcaption></figcaption></figure>

***

### ⚙️ How It Works

1. **Launch the AI Agent from any strategy**
2. The Agent will ask:
   * Which parameters should be optimized? (e.g. RSI period, trigger levels)
   * What duration and depth of optimization? (e.g. 1 year backtest, 10 min compute time)
3. The AI calculates the number of backtests that can be executed, then runs them in parallel based on server load and selected compute power (x1 to x4).
4. Get more backtest history, indicators and AI coupon by staking $RBOT, [learn more here](https://app.runbot.io/Staking).
5. After processing hundreds of tests, it selects and summarizes **the five best strategies** from the top 20 candidates.

***

### ✅ Optimization Results

Each optimization session always returns five curated strategies, based on multiple risk/reward trade-offs:

* **Best overall balance (Pareto frontier)**
* **Lowest drawdown**
* **Highest APR**
* **Highest Runbot Score**
* **Highest number of trades**

You can instantly click to **clone** any of these into your strategy list.

***

### 🧪 Optimisation Duration & Speed & Backtest History

When launching the AI Optimizer, you can choose:

* **Backtest history:** (This determines **how much historical market data** the AI will use to evaluate each strategy variant,  e.g. 1 month, 3 months, 1 year, 3 years...)
* **Optimization duration:** (1min to 24 hours,  the longer the duration, the more backtests can be processed)
* **Optimisation performance**: (x1 to x4): This multiplier will increase the number of backtests that will be processed during the optimisation duration&#x20;

Shorter durations (1–3 months) are useful for scalping strategies, highly reactive bots, or quickly adapting to current market conditions.

Longer durations (1–3 years) help validate strategies across different cycles, including bull, bear, and sideways markets, essential for detecting overfitting and stress-testing strategy robustness.

{% hint style="info" %}
💡 The longer the backtest history, the more robust and reliable the performance data.
{% endhint %}

{% hint style="warning" %}
The higher the speed multiplier, the more compute power (CPUs) your task gets, the higher the cost get.
{% endhint %}

You can also use **free optimization coupons** to run sessions at no cost.

***

### 📊 Behind the Scenes (How AI Computes)

1. The system first runs a test backtest to **estimate how long one iteration takes**.
2. Then it calculates:
   * Total number of CPUs allocated (based on speed multiplier)
   * Total backtests that fit within the allotted compute time

#### Example:

* You select: **1h duration, x2 speed**
* That allocates **10 CPUs** (5 base × 2)
* If each backtest takes **1 minute**, the AI can run approx. **600 backtests**
* Those 600 variants are then scored and filtered to return only the **top 5 results**

***

### 🧠 Why Use the AI Agent?

* **Save time**: No need to manually run 500+ tests
* **Better results**: AI considers multiple objectives at once
* **No code needed**: Choose what you want, Runbot AI does the rest
* **Consistent output**: Always get the most balanced and extreme variants

{% hint style="info" %}
If the optimization duration is too short, the AI may not have enough time to explore meaningful combinations or return high-quality results. Try to increase the optimieztion duration.
{% endhint %}

{% hint style="info" %}
If the core components of your strategy are weak, even the best optimization won’t produce strong performance, a solid base is essential, simply add more indicators or parameters to the strategy.
{% endhint %}

***

### 🙋 FAQ

#### ❓ How do I use my AI Agent coupon?

In order to use your coupon, chat naturally with the AI, when your configuration ie set-up, you'll have the option to use your AI Agent coupon.

<figure><img src="https://793384675-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsQezxfp9oB9jrccv5OA4%2Fuploads%2Fhn6tOjZmpyYRFrcYVl2h%2Fimage.png?alt=media&#x26;token=b6e2dc81-f29e-4abd-b23c-ddbd9cb30b26" alt=""><figcaption></figcaption></figure>

***

#### ❓ What parameters can I optimize with the AI Agent?

Anything adjustable inside your strategy: indicator periods, trigger thresholds, stop loss, entries and exit, etc.

***

#### ❓ Why the AI Agent sometimes don't understand my request  ?

The AI Agent only knows the name of your indicator, if you ask him to optimize all the indicators based on volume, it can bring confusion. Be as explicit as possible to avoid any conflicts.

***

#### ❓ Why did my backtest take more or less time than expected?

The **"optimization duration" refers to compute time**, not real-time minutes. You pay for CPU calculation time.

Runbot allocates CPU power depending on:

* Server load
* Selected optimization peformance

The AI first measures how long one backtest takes, then estimates how many backtests fit into that window. So if a backtest takes 60 seconds:

* 1 hour × 10 CPUs = 600 backtests

⚠️ Depending on server load, these can run **faster or slower in wall time**, but **you always get what you paid for in compute time**.

***

#### ❓ Will this replace the Optimizer tool?

No. The **AI Agent uses the Optimizer engine**, but in a guided, automated way. Advanced users can still access the Optimizer manually.

***

#### ❓ How do I launch it?

* Open any strategy → Go to **AI Agent Box** on the right side of the interface and start chatting
* Answer the prompt questions
* Choose backtest duration, optimization duration, speed
* Confirm → AI takes over


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.runbot.io/advanced-tools/ai-agent-optimiser.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
