A Node.js/TypeScript script that fetches candlestick data from Binance, computes multiple technical indicators, and outputs a clear LONG / SHORT / NEUTRAL signal with confidence, stop-loss, and take-profit.
- Fetches candlestick data from Binance REST API (both spot and futures markets)
- Calculates multiple technical indicators:
- EMA 7, EMA 25, EMA 99 (trend alignment check)
- RSI (14)
- MACD (12,26,9)
- ATR (14) for volatility, stop-loss, take-profit
- Volume vs 20-SMA (volume confirmation)
- Bollinger Bands (20, 2) for context (optional)
- Candle patterns: bullish/bearish engulfing at minimum
- Implements a weighted scoring system for determining trade signals
- Calculates risk management levels (stop-loss and take-profit)
- Multi-timeframe analysis with best choice recommendation
- Telegram bot mode for automated scanning and alerts
- Outputs structured JSON results
- Node.js (v14 or higher)
- npm or yarn
npm installnpx ts-node signal-engine.ts <symbol> [interval] [options]--futuresor-f: Use futures market instead of spot market--bestchoiceor-b: Analyze multiple timeframes and suggest the best choice--bot: Run in bot mode (requires TELEGRAM_TOKEN and CHAT_ID environment variables)
# Get signal for Bitcoin on 1-hour timeframe (spot market)
npx ts-node signal-engine.ts BTCUSDT 1h
# Get signal for Bitcoin on 1-hour timeframe (futures market)
npx ts-node signal-engine.ts BTCUSDT 1h --futures
# Get signal for Ethereum on 4-hour timeframe (spot market)
npx ts-node signal-engine.ts ETHUSDT 4h
# Get signal for Solana on 15-minute timeframe (futures market)
npx ts-node signal-engine.ts SOLUSDT 15m --futures
# Analyze multiple timeframes and suggest the best choice (spot market)
npx ts-node signal-engine.ts BTCUSDT --bestchoice
# Analyze multiple timeframes and suggest the best choice (futures market)
npx ts-node signal-engine.ts BTCUSDT --bestchoice --futures
# Run bot mode (spot market)
TELEGRAM_TOKEN=your_token CHAT_ID=your_chat_id npx ts-node signal-engine.ts --bot
# Run bot mode (futures market)
TELEGRAM_TOKEN=your_token CHAT_ID=your_chat_id npx ts-node signal-engine.ts --bot --futures- 1m, 3m, 5m, 15m, 30m
- 1h, 2h, 4h, 6h, 8h, 12h
- 1d, 3d
- 1w, 1M
The script outputs a JSON object with the following structure:
{
"symbol": "BTCUSDT",
"interval": "1h",
"signal": "NEUTRAL",
"confidence": 15,
"score": 0.1497,
"entry": 115972.69,
"stop_loss": 115641.0719,
"take_profit": 116525.3868,
"details": {
"lastClose": 115972.69,
"ema7": 115886.2851,
"ema25": 115894.3426,
"ema99": 116191.2576,
"rsi": 51.95,
"macd": -65.3526,
"macdSignal": 0,
"atr": 221.0787,
"volume": 343.95083,
"volumeSMA": 195.7411
}
}{
"symbol": "BTCUSDT",
"bestTimeframe": "15m",
"signal": "STRONG_LONG",
"confidence": 54,
"score": 0.5397,
"entry": 116033.28,
"stop_loss": 115930.3436,
"take_profit": 116204.8406,
"timeframeAnalysis": [
{
"interval": "15m",
"signal": "STRONG_LONG",
"confidence": 54,
"score": 0.5397
},
{
"interval": "1h",
"signal": "LONG",
"confidence": 34,
"score": 0.3394
},
{
"interval": "4h",
"signal": "NEUTRAL",
"confidence": 5,
"score": -0.0497
},
{
"interval": "1d",
"signal": "STRONG_LONG",
"confidence": 53,
"score": 0.5294
},
{
"interval": "1w",
"signal": "LONG",
"confidence": 22,
"score": 0.2245
}
]
}- STRONG_LONG: Strong buy signal (score ≥ +0.45)
- LONG: Buy signal (score ≥ +0.20)
- NEUTRAL: No clear signal (-0.20 < score < +0.20)
- SHORT: Sell signal (score ≤ -0.20)
- STRONG_SHORT: Strong sell signal (score ≤ -0.45)
The script calculates stop-loss and take-profit levels based on the Average True Range (ATR):
- Stop-loss: entry ± 1.5 * ATR
- Take-profit: entry ± 2.5 * ATR
The direction (plus or minus) is determined by the signal direction.
Each indicator contributes a weighted vote toward the final score:
- EMA order: 20%
- Close vs EMA: 15%
- Structure: 15%
- RSI: 12%
- MACD: 12%
- Volume: 8%
- Candle patterns: 8%
- ATR penalty: 10%
The final score ranges from -1 to +1.
When using the --bestchoice flag, the script analyzes the following timeframes:
- 15m (short-term momentum)
- 1h (intraday trend)
- 4h (daily trend)
- 1d (weekly trend context)
- 1w (long-term market direction)
The algorithm selects the timeframe with the strongest signal (highest absolute score) as the recommended choice.
The bot mode automatically scans popular cryptocurrency pairs and sends alerts via Telegram when strong signals are detected.
- Create a Telegram bot by talking to @BotFather and getting a token
- Get your chat ID (you can use @userinfobot or check updates from your bot)
- Set environment variables:
export TELEGRAM_TOKEN=your_telegram_bot_token export CHAT_ID=your_chat_id
- Run the bot:
npx ts-node signal-engine.ts --bot
/start- Show welcome message and request access (new users)/help- Show detailed help and usage instructions/status- Show bot status and statistics/opportunities- Show current trading opportunities/coin <symbol>- Analyze a specific coin (e.g.,/coin BTCUSDT)/analysis- Show prediction success rate and accuracy statistics/market- Show overall market direction analysis/notifications- Toggle prediction result notifications (on/off)/approve <user_id>- Approve user access (admin only)/deny <user_id>- Deny user access (admin only)
- User authorization system - new users must be approved by admin
- Notification preferences - users can enable/disable prediction result notifications
- Scans 20+ popular cryptocurrency pairs every 15 minutes
- Sends alerts only for STRONG_LONG and STRONG_SHORT signals
- Tracks predictions to measure accuracy over time
- Shows overall market direction based on major pairs
- Individual coin analysis with
/coincommand - Comprehensive help system with detailed usage instructions
- Works with both spot and futures markets
- When a new user starts the bot, they must be approved by the admin
- Admin receives a notification with user details and approval/denial commands
- Approved users can access all bot features
- Denied users are blocked from using the bot
- Users can toggle prediction result notifications with
/notifications - When enabled, users receive a single message when each prediction is evaluated
- Notifications include the result (CORRECT/INCORRECT) and price movement details
- Admin can see all notifications, regular users can choose their preference
The bot tracks all predictions and evaluates their accuracy after 1 hour:
- Compares the predicted direction with actual price movement
- Calculates success rate and statistics
- Shows detailed analysis with the
/analysiscommand - Sends notification when predictions are evaluated
The /market command provides an overview of the overall market sentiment by analyzing major cryptocurrency pairs (BTC, ETH, BNB, SOL) on the 1-hour timeframe.
Users can analyze specific coins with the /coin <symbol> command:
- Example:
/coin BTCUSDT - Shows detailed technical analysis for the specified coin
- Includes all timeframes and current market direction