AutomationFlowsSlack & Telegram › Bybit Trading Bot

Bybit Trading Bot

BYBIT Trading Bot. Uses httpRequest, writeBinaryFile, telegram. Scheduled trigger; 10 nodes.

Cron / scheduled trigger★★★★☆ complexity10 nodesHTTP RequestWrite Binary FileTelegram
Slack & Telegram Trigger: Cron / scheduled Nodes: 10 Complexity: ★★★★☆ Added:

This workflow follows the HTTP Request → Telegram recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "name": "BYBIT Trading Bot",
  "nodes": [
    {
      "parameters": {
        "triggerTimes": {
          "item": [
            {
              "mode": "everyX",
              "unit": "minutes",
              "value": 5
            }
          ]
        }
      },
      "name": "Cron",
      "type": "n8n-nodes-base.cron",
      "typeVersion": 1,
      "position": [
        100,
        300
      ]
    },
    {
      "parameters": {
        "method": "GET",
        "url": "https://api.bybit.com/v2/public/tickers?symbol=BTCUSDT"
      },
      "name": "Fetch Market Data",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        300,
        300
      ]
    },
    {
      "parameters": {
        "functionCode": "const price = items[0].json.result[0].last_price;\nlet prices = [];\nprices.push(price);\nconst smaPeriod = 5;\nif (prices.length >= smaPeriod) {\n  const sma = prices.slice(-smaPeriod).reduce((a, b) => a + b) / smaPeriod;\n  return [{ json: { signal: price > sma ? 'buy' : 'sell' } }];\n}\nreturn [{ json: { signal: 'wait' } }];"
      },
      "name": "Generate Signal",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        500,
        300
      ]
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "{{$node[\"Generate Signal\"].json[\"signal\"]}}",
              "operation": "equals",
              "value2": "buy"
            }
          ]
        }
      },
      "name": "IF Buy",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        700,
        200
      ]
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "{{$node[\"Generate Signal\"].json[\"signal\"]}}",
              "operation": "equals",
              "value2": "sell"
            }
          ]
        }
      },
      "name": "IF Sell",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        700,
        400
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.bybit.com/v2/private/order/create",
        "options": {},
        "bodyParametersUi": {
          "parameter": [
            {
              "name": "side",
              "value": "Buy"
            },
            {
              "name": "symbol",
              "value": "BTCUSDT"
            },
            {
              "name": "order_type",
              "value": "Market"
            },
            {
              "name": "qty",
              "value": 0.001
            },
            {
              "name": "time_in_force",
              "value": "GoodTillCancel"
            }
          ]
        },
        "headersUi": {
          "parameter": [
            {
              "name": "api_key",
              "value": "YOUR_API_KEY"
            },
            {
              "name": "timestamp",
              "value": "{{Math.floor(Date.now() / 1000)}}"
            },
            {
              "name": "sign",
              "value": "YOUR_SIGNATURE"
            }
          ]
        }
      },
      "name": "Execute Buy Order",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        900,
        100
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.bybit.com/v2/private/order/create",
        "options": {},
        "bodyParametersUi": {
          "parameter": [
            {
              "name": "side",
              "value": "Sell"
            },
            {
              "name": "symbol",
              "value": "BTCUSDT"
            },
            {
              "name": "order_type",
              "value": "Market"
            },
            {
              "name": "qty",
              "value": 0.001
            },
            {
              "name": "time_in_force",
              "value": "GoodTillCancel"
            }
          ]
        },
        "headersUi": {
          "parameter": [
            {
              "name": "api_key",
              "value": "YOUR_API_KEY"
            },
            {
              "name": "timestamp",
              "value": "{{Math.floor(Date.now() / 1000)}}"
            },
            {
              "name": "sign",
              "value": "YOUR_SIGNATURE"
            }
          ]
        }
      },
      "name": "Execute Sell Order",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        900,
        500
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.bybit.com/v2/private/stop-order/create",
        "options": {},
        "bodyParametersUi": {
          "parameter": [
            {
              "name": "side",
              "value": "Sell"
            },
            {
              "name": "symbol",
              "value": "BTCUSDT"
            },
            {
              "name": "order_type",
              "value": "Market"
            },
            {
              "name": "qty",
              "value": 0.001
            },
            {
              "name": "stop_px",
              "value": 30000
            },
            {
              "name": "base_price",
              "value": 31000
            }
          ]
        },
        "headersUi": {
          "parameter": [
            {
              "name": "api_key",
              "value": "YOUR_API_KEY"
            },
            {
              "name": "timestamp",
              "value": "{{Math.floor(Date.now() / 1000)}}"
            },
            {
              "name": "sign",
              "value": "YOUR_SIGNATURE"
            }
          ]
        }
      },
      "name": "Set Stop-Loss",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        1100,
        300
      ]
    },
    {
      "parameters": {
        "path": "/path/to/log/file.log",
        "options": {}
      },
      "name": "Logger",
      "type": "n8n-nodes-base.writeBinaryFile",
      "typeVersion": 1,
      "position": [
        1300,
        300
      ]
    },
    {
      "parameters": {
        "chatId": "YOUR_CHAT_ID",
        "text": "Order executed: {{$node[\"Execute Buy Order\"].json}}",
        "additionalFields": {}
      },
      "name": "Telegram Notification",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1,
      "position": [
        1500,
        300
      ],
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "Cron": {
      "main": [
        [
          {
            "node": "Fetch Market Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Market Data": {
      "main": [
        [
          {
            "node": "Generate Signal",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Signal": {
      "main": [
        [
          {
            "node": "IF Buy",
            "type": "main",
            "index": 0
          },
          {
            "node": "IF Sell",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF Buy": {
      "main": [
        [
          {
            "node": "Execute Buy Order",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF Sell": {
      "main": [
        [
          {
            "node": "Execute Sell Order",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Execute Buy Order": {
      "main": [
        [
          {
            "node": "Set Stop-Loss",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Execute Sell Order": {
      "main": [
        [
          {
            "node": "Set Stop-Loss",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Stop-Loss": {
      "main": [
        [
          {
            "node": "Logger",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Logger": {
      "main": [
        [
          {
            "node": "Telegram Notification",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

BYBIT Trading Bot. Uses httpRequest, writeBinaryFile, telegram. Scheduled trigger; 10 nodes.

Source: https://gist.github.com/Idziz/349aaf93adc6df4708de3e24513351ac — original creator credit. Request a take-down →

More Slack & Telegram workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

Slack & Telegram

Daily Wrap-up. Uses scheduleTrigger, httpRequest, telegram, writeBinaryFile. Scheduled trigger; 5 nodes.

HTTP Request, Telegram, Write Binary File
Slack & Telegram

GNCA AI News Pipeline. Uses rssFeedRead, httpRequest, telegram, errorTrigger. Scheduled trigger; 29 nodes.

RSS Feed Read, HTTP Request, Telegram +1
Slack & Telegram

This workflow automates plant care reminders and records using Google Sheets, Telegram, and OpenWeather API.

Google Sheets, HTTP Request, Telegram
Slack & Telegram

Apollo Data Enrichment Using Company Id to automatically finds contacts for companies listed in your Google Sheet, enriches each person with emails and phone numbers via Apollo’s API, and writes verif

Google Sheets, HTTP Request, Error Trigger +1
Slack & Telegram

MindFrame Psychology - FREE Complete Workflow. Uses httpRequest, googleDrive, telegram. Scheduled trigger; 25 nodes.

HTTP Request, Google Drive, Telegram