Skip to main content
Glama
patch-ridermg48

TradingView MCP Server

coin_analysis

Analyze cryptocurrency performance using technical indicators and metrics for specific coins, exchanges, and timeframes to support trading decisions.

Instructions

Get detailed analysis for a specific coin on specified exchange and timeframe.

Args:
    symbol: Coin symbol (e.g., "ACEUSDT", "BTCUSDT")
    exchange: Exchange name (BINANCE, KUCOIN, etc.) 
    timeframe: Time interval (5m, 15m, 1h, 4h, 1D, 1W, 1M)

Returns:
    Detailed coin analysis with all indicators and metrics

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
symbolYes
exchangeNoKUCOIN
timeframeNo15m

Implementation Reference

  • The coin_analysis tool handler. Uses tradingview_ta.get_multiple_analysis to fetch indicators for the specified symbol, computes metrics using compute_metrics, and returns a comprehensive analysis dictionary including price data, Bollinger Band analysis, technical indicators (RSI, MACD, ADX, Stoch), and market sentiment.
    @mcp.tool()
    def coin_analysis(
        symbol: str,
        exchange: str = "KUCOIN",
        timeframe: str = "15m"
    ) -> dict:
        """Get detailed analysis for a specific coin on specified exchange and timeframe.
        
        Args:
            symbol: Coin symbol (e.g., "ACEUSDT", "BTCUSDT")
            exchange: Exchange name (BINANCE, KUCOIN, etc.) 
            timeframe: Time interval (5m, 15m, 1h, 4h, 1D, 1W, 1M)
        
        Returns:
            Detailed coin analysis with all indicators and metrics
        """
        try:
            exchange = sanitize_exchange(exchange, "KUCOIN")
            timeframe = sanitize_timeframe(timeframe, "15m")
            
            # Format symbol with exchange prefix
            if ":" not in symbol:
                full_symbol = f"{exchange.upper()}:{symbol.upper()}"
            else:
                full_symbol = symbol.upper()
            
            screener = EXCHANGE_SCREENER.get(exchange, "crypto")
            
            try:
                analysis = get_multiple_analysis(
                    screener=screener,
                    interval=timeframe,
                    symbols=[full_symbol]
                )
                
                if full_symbol not in analysis or analysis[full_symbol] is None:
                    return {
                        "error": f"No data found for {symbol} on {exchange}",
                        "symbol": symbol,
                        "exchange": exchange,
                        "timeframe": timeframe
                    }
                
                data = analysis[full_symbol]
                indicators = data.indicators
                
                # Calculate all metrics
                metrics = compute_metrics(indicators)
                if not metrics:
                    return {
                        "error": f"Could not compute metrics for {symbol}",
                        "symbol": symbol,
                        "exchange": exchange,
                        "timeframe": timeframe
                    }
                
                # Additional technical indicators
                macd = indicators.get("MACD.macd", 0)
                macd_signal = indicators.get("MACD.signal", 0)
                adx = indicators.get("ADX", 0)
                stoch_k = indicators.get("Stoch.K", 0)
                stoch_d = indicators.get("Stoch.D", 0)
                
                # Volume analysis
                volume = indicators.get("volume", 0)
                
                # Price levels
                high = indicators.get("high", 0)
                low = indicators.get("low", 0)
                open_price = indicators.get("open", 0)
                close_price = indicators.get("close", 0)
                
                return {
                    "symbol": full_symbol,
                    "exchange": exchange,
                    "timeframe": timeframe,
                    "timestamp": "real-time",
                    "price_data": {
                        "current_price": metrics['price'],
                        "open": round(open_price, 6) if open_price else None,
                        "high": round(high, 6) if high else None,
                        "low": round(low, 6) if low else None,
                        "close": round(close_price, 6) if close_price else None,
                        "change_percent": metrics['change'],
                        "volume": volume
                    },
                    "bollinger_analysis": {
                        "rating": metrics['rating'],
                        "signal": metrics['signal'],
                        "bbw": metrics['bbw'],
                        "bb_upper": round(indicators.get("BB.upper", 0), 6),
                        "bb_middle": round(indicators.get("SMA20", 0), 6),
                        "bb_lower": round(indicators.get("BB.lower", 0), 6),
                        "position": "Above Upper" if close_price > indicators.get("BB.upper", 0) else 
                                   "Below Lower" if close_price < indicators.get("BB.lower", 0) else 
                                   "Within Bands"
                    },
                    "technical_indicators": {
                        "rsi": round(indicators.get("RSI", 0), 2),
                        "rsi_signal": "Overbought" if indicators.get("RSI", 0) > 70 else
                                     "Oversold" if indicators.get("RSI", 0) < 30 else "Neutral",
                        "sma20": round(indicators.get("SMA20", 0), 6),
                        "ema50": round(indicators.get("EMA50", 0), 6),
                        "ema200": round(indicators.get("EMA200", 0), 6),
                        "macd": round(macd, 6),
                        "macd_signal": round(macd_signal, 6),
                        "macd_divergence": round(macd - macd_signal, 6),
                        "adx": round(adx, 2),
                        "trend_strength": "Strong" if adx > 25 else "Weak",
                        "stoch_k": round(stoch_k, 2),
                        "stoch_d": round(stoch_d, 2)
                    },
                    "market_sentiment": {
                        "overall_rating": metrics['rating'],
                        "buy_sell_signal": metrics['signal'],
                        "volatility": "High" if metrics['bbw'] > 0.05 else "Medium" if metrics['bbw'] > 0.02 else "Low",
                        "momentum": "Bullish" if metrics['change'] > 0 else "Bearish"
                    }
                }
                
            except Exception as e:
                return {
                    "error": f"Analysis failed: {str(e)}",
                    "symbol": symbol,
                    "exchange": exchange,
                    "timeframe": timeframe
                }
                
        except Exception as e:
            return {
                "error": f"Coin analysis failed: {str(e)}",
                "symbol": symbol,
                "exchange": exchange,
                "timeframe": timeframe
            }
  • Helper function compute_metrics called within coin_analysis to calculate key metrics: price change, Bollinger Band width (bbw), BB rating and signal from raw indicators.
    def compute_metrics(indicators: Dict) -> Optional[Dict]:
        try:
            open_price = indicators["open"]
            close = indicators["close"]
            sma = indicators["SMA20"]
            bb_upper = indicators["BB.upper"]
            bb_lower = indicators["BB.lower"]
            bb_middle = sma
    
            change = compute_change(open_price, close)
            bbw = compute_bbw(sma, bb_upper, bb_lower)
            rating, signal = compute_bb_rating_signal(close, bb_upper, bb_middle, bb_lower)
    
            return {
                "price": round(close, 4),
                "change": round(change, 3),
                "bbw": round(bbw, 4) if bbw is not None else None,
                "rating": rating,
                "signal": signal,
            }
        except (KeyError, TypeError):
            return None
  • The @mcp.tool() decorator registers the coin_analysis function as an MCP tool.
    @mcp.tool()

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/patch-ridermg48/tradingview-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server