Skip to main content
Glama
patch-ridermg48

TradingView MCP Server

consecutive_candles_scan

Scan cryptocurrency exchanges for assets showing consecutive bullish or bearish candle patterns on specified timeframes to identify momentum opportunities.

Instructions

Scan for coins with consecutive growing/shrinking candles pattern.

Args:
    exchange: Exchange name (BINANCE, KUCOIN, etc.)
    timeframe: Time interval (5m, 15m, 1h, 4h)
    pattern_type: "bullish" (growing candles) or "bearish" (shrinking candles)
    candle_count: Number of consecutive candles to check (2-5)
    min_growth: Minimum growth percentage for each candle
    limit: Maximum number of results to return

Returns:
    List of coins with consecutive candle patterns

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
exchangeNoKUCOIN
timeframeNo15m
pattern_typeNobullish
candle_countNo
min_growthNo
limitNo

Implementation Reference

  • The primary handler for the 'consecutive_candles_scan' tool. Decorated with @mcp.tool() for automatic registration in FastMCP. Implements pattern scanning by analyzing current candle body/range ratio, price change, RSI momentum, volume, and position relative to SMAs as proxy for consecutive candles since historical data unavailable. Sanitizes inputs, fetches analysis via tradingview_ta.get_multiple_analysis, filters and scores coins, sorts by strength.
    @mcp.tool()
    def consecutive_candles_scan(
        exchange: str = "KUCOIN",
        timeframe: str = "15m",
        pattern_type: str = "bullish",
        candle_count: int = 3,
        min_growth: float = 2.0,
        limit: int = 20
    ) -> dict:
        """Scan for coins with consecutive growing/shrinking candles pattern.
        
        Args:
            exchange: Exchange name (BINANCE, KUCOIN, etc.)
            timeframe: Time interval (5m, 15m, 1h, 4h)
            pattern_type: "bullish" (growing candles) or "bearish" (shrinking candles)
            candle_count: Number of consecutive candles to check (2-5)
            min_growth: Minimum growth percentage for each candle
            limit: Maximum number of results to return
        
        Returns:
            List of coins with consecutive candle patterns
        """
        try:
            exchange = sanitize_exchange(exchange, "KUCOIN")
            timeframe = sanitize_timeframe(timeframe, "15m")
            candle_count = max(2, min(5, candle_count))
            min_growth = max(0.5, min(20.0, min_growth))
            limit = max(1, min(50, limit))
            
            # Get symbols for the exchange
            symbols = load_symbols(exchange)
            if not symbols:
                return {
                    "error": f"No symbols found for exchange: {exchange}",
                    "exchange": exchange,
                    "timeframe": timeframe
                }
            
            # Limit symbols for performance (we need historical data)
            symbols = symbols[:min(limit * 3, 200)]
            
            # We need to get data from multiple timeframes to analyze candle progression
            # For now, we'll use current timeframe data and simulate pattern detection
            screener = EXCHANGE_SCREENER.get(exchange, "crypto")
            
            try:
                analysis = get_multiple_analysis(
                    screener=screener,
                    interval=timeframe,
                    symbols=symbols
                )
                
                pattern_coins = []
                
                for symbol, data in analysis.items():
                    if data is None:
                        continue
                        
                    try:
                        indicators = data.indicators
                        
                        # Calculate current candle metrics
                        open_price = indicators.get("open")
                        close_price = indicators.get("close")
                        high_price = indicators.get("high") 
                        low_price = indicators.get("low")
                        volume = indicators.get("volume", 0)
                        
                        if not all([open_price, close_price, high_price, low_price]):
                            continue
                        
                        # Calculate current candle body size and change
                        current_change = ((close_price - open_price) / open_price) * 100
                        candle_body = abs(close_price - open_price)
                        candle_range = high_price - low_price
                        body_to_range_ratio = candle_body / candle_range if candle_range > 0 else 0
                        
                        # For consecutive pattern, we'll use available indicators to simulate
                        # In a real implementation, we'd need historical OHLC data
                        
                        # Use RSI and price momentum as proxy for consecutive pattern
                        rsi = indicators.get("RSI", 50)
                        sma20 = indicators.get("SMA20", close_price)
                        ema50 = indicators.get("EMA50", close_price)
                        
                        # Calculate momentum indicators
                        price_above_sma = close_price > sma20
                        price_above_ema = close_price > ema50
                        strong_momentum = abs(current_change) >= min_growth
                        
                        # Pattern detection logic
                        pattern_detected = False
                        pattern_strength = 0
                        
                        if pattern_type == "bullish":
                            # Bullish pattern: price rising, good momentum, strong candle body
                            conditions = [
                                current_change > min_growth,  # Current candle is bullish
                                body_to_range_ratio > 0.6,    # Strong candle body
                                price_above_sma,              # Above short MA
                                rsi > 45 and rsi < 80,        # RSI in momentum range
                                volume > 1000                 # Decent volume
                            ]
                            
                            pattern_strength = sum(conditions)
                            pattern_detected = pattern_strength >= 3
                            
                        elif pattern_type == "bearish":
                            # Bearish pattern: price falling, bearish momentum
                            conditions = [
                                current_change < -min_growth,  # Current candle is bearish
                                body_to_range_ratio > 0.6,     # Strong candle body
                                not price_above_sma,           # Below short MA
                                rsi < 55 and rsi > 20,         # RSI in bearish range
                                volume > 1000                  # Decent volume
                            ]
                            
                            pattern_strength = sum(conditions)
                            pattern_detected = pattern_strength >= 3
                        
                        if pattern_detected:
                            # Calculate additional metrics
                            metrics = compute_metrics(indicators)
                            
                            coin_data = {
                                "symbol": symbol,
                                "price": round(close_price, 6),
                                "current_change": round(current_change, 3),
                                "candle_body_ratio": round(body_to_range_ratio, 3),
                                "pattern_strength": pattern_strength,
                                "volume": volume,
                                "bollinger_rating": metrics.get('rating', 0) if metrics else 0,
                                "rsi": round(rsi, 2),
                                "price_levels": {
                                    "open": round(open_price, 6),
                                    "high": round(high_price, 6), 
                                    "low": round(low_price, 6),
                                    "close": round(close_price, 6)
                                },
                                "momentum_signals": {
                                    "above_sma20": price_above_sma,
                                    "above_ema50": price_above_ema,
                                    "strong_volume": volume > 5000
                                }
                            }
                            
                            pattern_coins.append(coin_data)
                            
                    except Exception as e:
                        continue
                
                # Sort by pattern strength and current change
                if pattern_type == "bullish":
                    pattern_coins.sort(key=lambda x: (x['pattern_strength'], x['current_change']), reverse=True)
                else:
                    pattern_coins.sort(key=lambda x: (x['pattern_strength'], -x['current_change']), reverse=True)
                
                return {
                    "exchange": exchange,
                    "timeframe": timeframe,
                    "pattern_type": pattern_type,
                    "candle_count": candle_count,
                    "min_growth": min_growth,
                    "total_found": len(pattern_coins),
                    "data": pattern_coins[:limit]
                }
                
            except Exception as e:
                return {
                    "error": f"Pattern analysis failed: {str(e)}",
                    "exchange": exchange,
                    "timeframe": timeframe
                }
                
        except Exception as e:
            return {
                "error": f"Consecutive candles scan failed: {str(e)}",
                "exchange": exchange,
                "timeframe": timeframe
            }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It describes the scanning function but lacks details on performance (e.g., rate limits, latency), data freshness, error handling, or authentication needs. The return format is mentioned but not elaborated, leaving gaps in understanding how results are structured or limited.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and front-loaded, starting with the core purpose followed by a structured list of args and returns. Every sentence adds value, with no redundant information, though it could be slightly more concise by integrating the purpose with the parameter explanations.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (6 parameters, no annotations, no output schema), the description is moderately complete. It covers the purpose and parameters well but lacks behavioral context (e.g., performance, errors) and detailed output explanation. Without an output schema, the brief return statement ('List of coins with consecutive candle patterns') is insufficient for full understanding, leaving gaps in how results are formatted or what data they include.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It effectively adds meaning by explaining each parameter's purpose (e.g., 'pattern_type: "bullish" (growing candles) or "bearish" (shrinking candles)'), including constraints like 'candle_count: Number of consecutive candles to check (2-5)' and clarifying units like 'min_growth: Minimum growth percentage for each candle'. This provides essential context beyond the bare schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with specific verbs ('scan for coins') and resources ('consecutive growing/shrinking candles pattern'), distinguishing it from siblings like 'bollinger_scan' or 'volume_breakout_scanner' by focusing on consecutive candle patterns rather than technical indicators or volume analysis.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No explicit guidance on when to use this tool versus alternatives is provided. While the purpose implies it's for identifying coins with specific candle patterns, there's no mention of when it's preferable over siblings like 'advanced_candle_pattern' or 'coin_analysis', nor any prerequisites or exclusions stated.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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