How to Build a Telegram Trading Alert Bot in 30 Minutes
Build a Telegram bot that sends you real-time trading alerts based on RSI, MACD, and Bollinger Band signals from the TickAtlas API. Complete Python code included.
What You Will Build
A Python script that monitors forex and crypto pairs using the TickAtlas API, detects trading signals, and sends formatted alerts directly to your Telegram phone. Total setup time: about 30 minutes.
ALERT: EURUSD BUY Signal
RSI: 28.4 (oversold)
MACD: histogram turning positive
Price: 1.0835
Timeframe: H1
Time: 2026-03-28 14:00 UTC
Prerequisites
- Python 3.10+ with
pip install requests - A TickAtlas API key
- A Telegram account
Step 1: Create a Telegram Bot
Open Telegram, search for @BotFather, and send /newbot. Follow the prompts to get your bot token. Then send a message to your new bot and visit https://api.telegram.org/bot<TOKEN>/getUpdates to get your chat ID.
Step 2: The Alert Sender
import requests
TELEGRAM_TOKEN = "your_bot_token"
TELEGRAM_CHAT_ID = "your_chat_id"
def send_alert(message: str):
"""Send a message via Telegram."""
url = f"https://api.telegram.org/bot{TELEGRAM_TOKEN}/sendMessage"
resp = requests.post(url, json={
"chat_id": TELEGRAM_CHAT_ID,
"text": message,
"parse_mode": "Markdown"
})
if resp.status_code != 200:
print(f"Telegram error: {resp.text}") Step 3: Market Scanner
CLAW_API_KEY = "your_tickatlas_api_key"
CLAW_BASE = "https://tickatlas.com/v1"
CLAW_HEADERS = {"X-API-Key": CLAW_API_KEY}
WATCHLIST = ["EURUSD", "GBPUSD", "USDJPY", "XAUUSD", "BTCUSD"]
def scan_for_signals() -> list[dict]:
"""Scan all watchlist symbols for trading signals."""
signals = []
for symbol in WATCHLIST:
resp = requests.get(f"{CLAW_BASE}/indicators", params={
"symbol": symbol,
"timeframe": "H1",
"indicators": "RSI_14,MACD,BBANDS_20"
}, headers=CLAW_HEADERS)
if resp.status_code != 200:
continue
data = resp.json()["data"]
ind = data["indicators"]
price = data.get("price", {}).get("close", 0)
rsi = ind["RSI_14"]["value"]
macd_hist = ind["MACD"]["histogram"]
bb = ind["BBANDS_20"]
# Check for buy signals
if rsi < 30 and macd_hist > 0:
signals.append({
"symbol": symbol,
"direction": "BUY",
"reason": f"RSI oversold ({rsi:.1f}) + MACD bullish",
"price": price,
"rsi": rsi
})
elif price <= bb["lower"] * 1.002 and rsi < 35:
signals.append({
"symbol": symbol,
"direction": "BUY",
"reason": f"Bollinger lower band touch + RSI {rsi:.1f}",
"price": price,
"rsi": rsi
})
# Check for sell signals
if rsi > 70 and macd_hist < 0:
signals.append({
"symbol": symbol,
"direction": "SELL",
"reason": f"RSI overbought ({rsi:.1f}) + MACD bearish",
"price": price,
"rsi": rsi
})
elif price >= bb["upper"] * 0.998 and rsi > 65:
signals.append({
"symbol": symbol,
"direction": "SELL",
"reason": f"Bollinger upper band touch + RSI {rsi:.1f}",
"price": price,
"rsi": rsi
})
return signals Step 4: Format and Send
from datetime import datetime
def format_alert(signal: dict) -> str:
"""Format signal as a Telegram message."""
emoji = "🟢" if signal["direction"] == "BUY" else "🔴"
return (
f"{emoji} *{signal['direction']} Alert: {signal['symbol']}*\n"
f"Reason: {signal['reason']}\n"
f"Price: {signal['price']}\n"
f"RSI: {signal['rsi']:.1f}\n"
f"Time: {datetime.utcnow().strftime('%Y-%m-%d %H:%M')} UTC"
) Step 5: The Main Loop
import time
def run_alert_bot():
"""Main loop — scans market and sends alerts."""
print(f"Alert bot started. Watching: {', '.join(WATCHLIST)}")
sent_signals = set() # Avoid duplicate alerts
while True:
try:
signals = scan_for_signals()
for signal in signals:
# Create unique key to prevent duplicate alerts
key = f"{signal['symbol']}_{signal['direction']}_{datetime.utcnow().hour}"
if key not in sent_signals:
message = format_alert(signal)
send_alert(message)
sent_signals.add(key)
print(f"Alert sent: {signal['symbol']} {signal['direction']}")
# Clean old keys every hour
if datetime.utcnow().minute == 0:
sent_signals.clear()
except Exception as e:
print(f"Error: {e}")
time.sleep(300) # Check every 5 minutes
if __name__ == "__main__":
run_alert_bot() Enhancements
Add a Daily Summary
Send a morning briefing with the status of all watched pairs. Use the AI analyst pattern for natural language summaries.
Multi-Timeframe Confirmation
Only alert when H1 and H4 signals agree. This dramatically reduces false signals.
Economic Calendar Warnings
Check the /v1/calendar endpoint and warn before high-impact news events.
Further Reading
Try this with live data
Every account gets $2.50 in free PAYG credits. No card required — paste your API key and run the code above against live broker data.
Keep reading
All articles- Tutorial 11 min read
24/7 Crypto Monitoring: Building Always-On Analysis Systems
Build a monitoring system that watches crypto markets around the clock, detects significant moves, and sends alerts when conditions match your criteria.
March 28, 2026
- Tutorial 12 min read
How to Build an AI Market Analyst That Runs 24/7
Build a production-ready AI market analyst that monitors forex and crypto markets around the clock, generates daily briefings, and alerts you to opportunities via Telegram.
March 28, 2026
- Tutorial 10 min read
Using ATR for Dynamic Stop-Loss Placement
Learn how to use Average True Range (ATR) to set volatility-adjusted stop losses that adapt to market conditions, with full code examples.
March 28, 2026