Skip to main content
Glama

analyze

Perform technical analysis on any cryptocurrency to compute RSI, SMA, volatility, z-score, and trend direction. Get actionable signals by specifying the symbol and lookback period.

Instructions

Technical analysis for any crypto: RSI, SMA, volatility, z-score, trend direction. Actionable signals included.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
symbolYesCrypto symbol
daysNoLookback period in days (default: 30)

Implementation Reference

  • The `technicalAnalysis` function that executes the analyze tool logic. Computes RSI (14-period), SMA (20/50), volatility (log-returns annualized), z-score, trend direction, and price vs SMA comparison.
    function technicalAnalysis(candles) {
      const closes = candles.map(c => c.close);
      const n = closes.length;
      if (n < 14) return { error: 'Need at least 14 candles for analysis' };
    
      // SMA
      const sma20 = closes.slice(-20).reduce((a, b) => a + b, 0) / Math.min(20, n);
      const sma50 = n >= 50 ? closes.slice(-50).reduce((a, b) => a + b, 0) / 50 : null;
    
      // RSI (14-period)
      let gains = 0, losses = 0;
      for (let i = n - 14; i < n; i++) {
        const diff = closes[i] - closes[i - 1];
        if (diff > 0) gains += diff;
        else losses -= diff;
      }
      const avgGain = gains / 14;
      const avgLoss = losses / 14;
      const rs = avgLoss === 0 ? 100 : avgGain / avgLoss;
      const rsi = 100 - (100 / (1 + rs));
    
      // Volatility
      const returns = [];
      for (let i = 1; i < n; i++) {
        returns.push(Math.log(closes[i] / closes[i - 1]));
      }
      const mean = returns.reduce((a, b) => a + b, 0) / returns.length;
      const variance = returns.reduce((a, b) => a + (b - mean) ** 2, 0) / returns.length;
      const volatility = Math.sqrt(variance);
    
      // Z-score
      const allMean = closes.reduce((a, b) => a + b, 0) / n;
      const std = Math.sqrt(closes.reduce((a, b) => a + (b - allMean) ** 2, 0) / n);
      const zscore = std > 0 ? (closes[n - 1] - allMean) / std : 0;
    
      // Trend
      const recent = closes.slice(-5);
      const older = closes.slice(-10, -5);
      const recentAvg = recent.reduce((a, b) => a + b, 0) / recent.length;
      const olderAvg = older.length > 0 ? older.reduce((a, b) => a + b, 0) / older.length : recentAvg;
    
      const current = closes[n - 1];
    
      return {
        current_price: current,
        sma_20: Math.round(sma20 * 100) / 100,
        sma_50: sma50 ? Math.round(sma50 * 100) / 100 : 'insufficient data',
        rsi_14: Math.round(rsi * 100) / 100,
        rsi_signal: rsi > 70 ? 'OVERBOUGHT' : rsi < 30 ? 'OVERSOLD' : 'NEUTRAL',
        volatility: Math.round(volatility * 10000) / 10000,
        volatility_annualized: Math.round(volatility * Math.sqrt(365 * 24) * 10000) / 100 + '%',
        zscore: Math.round(zscore * 100) / 100,
        zscore_signal: zscore > 2 ? 'EXTENDED HIGH' : zscore < -2 ? 'EXTENDED LOW' : 'NORMAL',
        trend: recentAvg > olderAvg * 1.01 ? 'UPTREND' : recentAvg < olderAvg * 0.99 ? 'DOWNTREND' : 'SIDEWAYS',
        price_vs_sma20: current > sma20 ? 'ABOVE' : 'BELOW',
        high: Math.max(...closes),
        low: Math.min(...closes),
        range_pct: ((Math.max(...closes) - Math.min(...closes)) / Math.min(...closes) * 100).toFixed(2) + '%',
      };
    }
  • Schema definition for the 'analyze' tool: requires 'symbol' (string) and optional 'days' (number, default 30).
    name: 'analyze',
    description: 'Technical analysis for any crypto: RSI, SMA, volatility, z-score, trend direction. Actionable signals included.',
    inputSchema: {
      type: 'object',
      properties: {
        symbol: { type: 'string', description: 'Crypto symbol' },
        days: { type: 'number', description: 'Lookback period in days (default: 30)' }
      },
      required: ['symbol']
    }
  • index.js:287-298 (registration)
    Registration of the 'analyze' tool in the getToolDefinitions() array of tool definitions.
    {
      name: 'analyze',
      description: 'Technical analysis for any crypto: RSI, SMA, volatility, z-score, trend direction. Actionable signals included.',
      inputSchema: {
        type: 'object',
        properties: {
          symbol: { type: 'string', description: 'Crypto symbol' },
          days: { type: 'number', description: 'Lookback period in days (default: 30)' }
        },
        required: ['symbol']
      }
    },
  • The tool call handler for 'analyze' in handleToolCall() switch case. Fetches candles then delegates to technicalAnalysis().
    case 'analyze': {
      const candles = await getCryptoCandles(args.symbol, '1h', args.days || 30);
      return technicalAnalysis(candles);
    }
  • The getCryptoCandles helper that fetches OHLCV data from CoinGecko, called by the analyze handler to provide candle data for analysis.
    async function getCryptoCandles(symbol, interval = '1h', days = 7) {
      const id = symbol.toLowerCase().replace('usdt', '').replace('usd', '');
      const idMap = {
        btc: 'bitcoin', eth: 'ethereum', sol: 'solana', doge: 'dogecoin',
        xrp: 'ripple', bnb: 'binancecoin', ada: 'cardano', avax: 'avalanche-2',
      };
      const coinId = idMap[id] || id;
    
      const data = await fetch(
        `https://api.coingecko.com/api/v3/coins/${coinId}/ohlc?vs_currency=usd&days=${days}`
      );
    
      return data.map(c => ({
        time: new Date(c[0]).toISOString(),
        open: c[1],
        high: c[2],
        low: c[3],
        close: c[4],
      }));
    }
Behavior2/5

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

No annotations provided. Description does not disclose behavioral traits like data sources, rate limits, or limitations on coin types. Minimal info beyond listing indicators.

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

Conciseness5/5

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

Single sentence front-loads key information (technical analysis, indicators, signals) with no waste.

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

Completeness2/5

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

Despite listing indicators, description is brief. No output schema provided, so agent cannot infer return structure. Missing info on error handling or validity. Incomplete for a multi-indicator tool.

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

Parameters3/5

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

Schema coverage is 100%, so parameters are well-documented in schema. Description adds no extra meaning beyond what schema already provides (symbol, lookback days).

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?

Description clearly states it performs technical analysis on crypto, listing specific indicators (RSI, SMA, etc.) and mentions actionable signals. It distinguishes from siblings like 'price' or 'candles'.

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

Usage Guidelines3/5

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

The description implies use for technical analysis but does not explicitly state when to use this tool vs alternatives or provide exclusions. No comparison to sibling tools.

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/ShipItAndPray/mcp-market-data'

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