Waking up at 3 AM to check if BTC broke resistance? Constantly refreshing the Binance app while having dinner? We’ve all been there. It’s exhausting.
In our last post, we connected to the Binance API. Today, we are taking it a step further. We are going to build a simple Python bot that watches the market for you and sends a Telegram message directly to your phone when a coin hits your target price.
No more FOMO. Let the code do the waiting.
Step 1: Set Up Your Telegram Assistant
Before we write Python, we need a bot on Telegram.
1. Open Telegram and search for @BotFather (the official bot creator).
2. Send /newbot and follow the prompts to give your bot a name and username.
3. BotFather will give you a HTTP API Token. Copy this! Treat it like a password.
4. Now, search for your new bot in Telegram and click "Start".
5. Next, search for @userinfobot and forward a message to it (or just start it) to get your Chat ID (a string of numbers).
Step 2: The Logic Behind the Code
We are going to use the ccxt library to fetch the price, and the standard requests library to send the message to Telegram.
The core logic is a continuous loop (while True). The script asks Binance for the price, checks if it hit our target, and if not, it "sleeps" for a few seconds before asking again. This prevents us from spamming the exchange with requests.
Step 3: The Python Code
Make sure you have the libraries installed: pip install ccxt requests
import ccxt
import requests
import time
# --- YOUR SETTINGS ---
TELEGRAM_TOKEN = 'YOUR_BOT_TOKEN_HERE'
CHAT_ID = 'YOUR_CHAT_ID_HERE'
SYMBOL = 'BTC/USDT'
TARGET_PRICE = 65000 # The price you are waiting for
# Initialize Binance (No secret keys needed for public price data!)
binance = ccxt.binance()
def send_telegram_alert(message):
"""Sends a message via Telegram API"""
url = f"https://api.telegram.org/bot{TELEGRAM_TOKEN}/sendMessage?chat_id={CHAT_ID}&text={message}"
requests.get(url)
print(f"🤖 Bot started. Monitoring {SYMBOL}...")
while True:
try:
# Fetch the latest price
ticker = binance.fetch_ticker(SYMBOL)
current_price = ticker['last']
print(f"Current {SYMBOL} price: {current_price}")
# Check if target is hit
if current_price >= TARGET_PRICE:
msg = f"🚨 ALERT! {SYMBOL} just crossed {TARGET_PRICE}! Current price is {current_price}."
send_telegram_alert(msg)
print("Alert sent! Pausing for 1 hour to avoid spam...")
time.sleep(3600) # Sleep for 1 hour after sending an alert
# Wait 10 seconds before checking again
time.sleep(10)
except Exception as e:
print(f"Connection error: {e}")
time.sleep(10) # If network fails, wait and try again
Why This is Powerful
This is a basic structure, but think about the possibilities. You can easily modify this script to:
• Alert you when a coin drops below a certain price (Buy the dip!).
• Monitor 10 different coins at the same time.
• Add an RSI indicator to alert you when a coin is "Oversold".
What should we add to this bot next? RSI alerts, or moving average crossovers? Let me know in the comments below! 👇
Disclaimer: Educational purposes only. Always test scripts thoroughly before relying on them.



#TelegramBot #PythonTrading #CryptoAlerts #BinanceAPI #cryptoeducation #AlgoTrading #TechInCrypt
