> For the complete documentation index, see [llms.txt](https://docs.primeautomation.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.primeautomation.ai/primeautomation/creating-a-custom-bot.md).

# Creating a Custom Bot

{% stepper %}
{% step %}

### 📍 Step 1: Navigate to the Custom Bot Setup

From the top navigation bar:

> 👇 Click `Custom Bot`

This opens the 3-step bot creation wizard.
{% endstep %}

{% step %}

### ⚙️ Step 2: Fill Out General Settings

On the first screen, you'll define how your custom bot behaves.

![General Settings](/files/1f50f75e89adb0086b6c4c66188d31ca8bf13e55)

*General Settings*

#### General Settings Fields

| Field                      | Description                                                                         |
| -------------------------- | ----------------------------------------------------------------------------------- |
| **Exchange**               | Choose your connected exchange (e.g. Bitget, BloFin, TradeStation)                  |
| **Trading Type**           | Choose `Spot` or `Futures`                                                          |
| **Pair(s)**                | Select the crypto pair (e.g. `BTC/USDT`) your bot will trade                        |
| **Allow Layered Entries**  | Enable to allow the bot to scale in with multiple entries                           |
| **Amount per Trade**       | Choose either: `Fixed Dollar Amount` (e.g. $20) or `% of Account Balance` (e.g. 5%) |
| **Use TradingView Amount** | If enabled, the bot will respect the size passed in your TradingView alert          |
| **Bot Name**               | Name your bot (e.g. "Breakout Sniper")                                              |
| **Bot Status**             | Set the bot to `Active` or `Inactive`                                               |
| **Margin Mode**            | Select Cross or Isolated when futures is selected                                   |
| **Limit Kill Period**      | (Optional) Auto-cancel inactive limit orders after this duration (e.g. 10 mins)     |

✅ Once filled, click the orange **Next** button to continue to the TradingView webhook instructions.
{% endstep %}

{% step %}

### 🔗 Step 3: Connect to TradingView

After saving your bot configuration, you’ll see the message:

> **"Bot created! Now connect your bot to TradingView"**

This screen gives you a unique webhook URL and important instructions.

#### ⚠️ Match Your Chart to Your Exchange

Ensure your TradingView chart matches the **exchange you selected** during bot setup.

For example:

* If you selected **Bitget**, trigger alerts from a **Bitget chart**.
* If you use a **Binance chart** for a Bitget bot, the alert will misfire or fail.

![Match Exchange](/files/6T9W1BPh5n7lyPuMWLJN)

*Ensure your TradingView chart matches the exchange you selected*
{% endstep %}

{% step %}

### 🌐 Step 4: Copy Webhook & Alert Messages

#### Webhook URL

This is your unique endpoint. Copy and paste it into the **"Webhook URL"** field when creating your TradingView alert.

```
https://api.primeautomation.ai/webhook/ChartPrime/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
```

📋 Click the copy icon in the interface to quickly grab the link.

![Webhook Alert](/files/117e2deb63f8b7f0fd655c93d6ddda86dfb9bdc5)

*Activate Webhook URL on TradingView and paste your bot's Webhook URL*

***

#### Basic Alert Message (for non-ChartPrime users)

If you're using **any TradingView strategy** other than PA Strategy Builder, use:

```
{{strategy.order.alert_message}}
```

Paste this into the **"Message"** field of your TradingView alert. It will send signal details (buy/sell/exit) automatically.

![Alert Message](/files/36e4484a855a46249aaba02a36ba12d5f1c8092a)

*Paste message here*

***

#### Full Indicator Message Templates (Advanced)

Use these JSON message formats to send custom webhook signals with full control. Each item in double braces is replaced with a value when the alert is sent to PrimeAutomation.

✅ BUY

{% code title="buy.json" %}

```json
{
  "ticker": "{{ticker}}",
  "action": "buy",
  "price": "{{close}}",
  "time": "{{timenow}}",
  "size": "{{size}}"
}
```

{% endcode %}

🟡 EXIT\_BUY

{% code title="exit\_buy.json" %}

```json
{
  "ticker": "{{ticker}}",
  "action": "exit_buy",
  "price": "{{close}}",
  "time": "{{timenow}}",
  "size": "{{size}}",
  "per": "{{per}}",
  "sl": "{{sl}}",
  "tp": "{{tp}}"
}
```

{% endcode %}

🔻 SELL

{% code title="sell.json" %}

```json
{
  "ticker": "{{ticker}}",
  "action": "sell",
  "price": "{{close}}",
  "time": "{{timenow}}",
  "size": "{{size}}"
}
```

{% endcode %}

🔴 EXIT\_SELL

{% code title="exit\_sell.json" %}

```json
{
  "ticker": "{{ticker}}",
  "action": "exit_sell",
  "price": "{{close}}",
  "time": "{{timenow}}",
  "size": "{{size}}",
  "per": "{{per}}",
  "sl": "{{sl}}",
  "tp": "{{tp}}"
}
```

{% endcode %}

📌 These are for advanced Pine Script users or when building your own signal logic. You can dynamically insert variables using TradingView alert syntax.
{% endstep %}

{% step %}

### ✅ Final Step: Deploy & Monitor

Click **Continue to Dashboard**.

Your bot is now live and ready to receive webhook alerts. You’ll see it appear on your dashboard where you can:

* 🟢 Toggle it ON/OFF
* ✏️ Edit configuration
* 📊 Track live trades and PNL
* 🧾 View trade history
  {% endstep %}
  {% endstepper %}

{% hint style="info" %}

#### 🧠 Best Practices

* 🔐 Keep your webhook URL private. It acts as the key to your bot.
  {% endhint %}

\
**Want to see how it's done?** Watch the video below ✏️

{% embed url="<https://youtu.be/kdi7o9Gl5w8>" %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.primeautomation.ai/primeautomation/creating-a-custom-bot.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
