# MACD & RSI Oscillator Engine MCP

> MACD & RSI Oscillator Engine calculates precise MACD and Relative Strength Index (RSI) technical indicators directly from price arrays. This engine handles the complex, multi-pass exponential averaging required for accurate quantitative analysis—a task most LLMs fail at due to mathematical complexity.

## Overview
- **Category:** data-analytics
- **Price:** Free
- **Tags:** technical-analysis, trading-signals, quantitative-analysis, market-indicators, financial-math

## Description

**MACD & RSI Engine - Calculate Trading Signals MCP Server**

This server exposes the `calculate_macd_rsi` tool, which calculates precise MACD or Relative Strength Index (RSI) technical oscillators directly from price arrays. You feed this engine a data array and specific configuration parameters, letting it handle the complex, multi-pass exponential averaging required for accurate quantitative analysis. It's designed specifically because standard LLMs fail at these calculations; they can't manage the deep mathematical passes needed to generate reliable trading signals.

The `calculate_macd_rsi` tool requires two primary inputs: a data array and a set of configuration parameters. The price data array must contain historical prices that you want analyzed. The accompanying parameters tell the engine exactly which indicators you need and what their specific settings should be. When you execute this function, it processes the raw price data through institutional-grade technical indicator mathematics.

When calculating MACD, for instance, the configuration parameters let you define the fast period, slow period, and signal smoothing period. The tool takes your price array, performs multiple exponential averaging passes using those specified periods, and returns a precise set of MACD values ready for immediate use in an analysis agent. Similarly, if you need RSI, the parameters specify the lookback period—like the common 14-period setting—and the engine calculates the exact relative strength index based on that definition.

The tool doesn't just give you numbers; it gives you actionable signals by providing the calculated oscillator values at every point in your data array. You define the indicator type (MACD or RSI) and its specific parameters, and the function returns a structured output containing those precise numerical results. For MACD, this means getting the main MACD line value, the signal line value, and often the histogram value itself. For RSI, you get the calculated index for every point in the data set.

This engine handles the mathematical heavy lifting that usually breaks an agent's internal math capabilities. You don't worry about writing complex financial formulas or debugging multi-pass exponential smoothing; you just define your desired parameters—say, MACD with a 12/26/9 setup, or RSI over a 14-period lookback—and the server spits out accurate results every time. It ensures that whether you're running autonomous trading simulations or simply analyzing historical price movements, the signals are mathematically sound and ready for your agent to process.

You pass the data array along with the required parameters defining either MACD or RSI calculation requirements. The tool then executes the necessary exponential averaging passes across the entire dataset. It calculates the specific technical oscillator values based on those inputs—the resulting output is a structured set of accurate, ready-to-use numerical results that you can immediately feed into subsequent decision-making logic in your AI client. You're getting clean, precise financial data points derived from complex mathematical processes, all managed through one reliable function call.

## Tools

### calculate_macd_rsi
Pass a data array and configuration parameters; this function calculates MACD or RSI technical oscillators from the price data.

## Prompt Examples

**Prompt:** 
```
Calculate the 14-period RSI for this daily stock price array. Tell me if the final day is below 30 (Oversold).
```

**Response:** 
```
The computation has been executed with mathematical precision. All results are exact and ready for review.
```

**Prompt:** 
```
Run the MACD calculator. Check the last 3 days and tell me if the MACD line has crossed above the Signal line (bullish).
```

**Response:** 
```
The computation has been executed with mathematical precision. All results are exact and ready for review.
```

**Prompt:** 
```
I see the price making a new high here. Calculate the RSI and tell me if the RSI is making a lower high (bearish divergence).
```

**Response:** 
```
The computation has been executed with mathematical precision. All results are exact and ready for review.
```

## Capabilities

### Calculate Technical Indicators
Pass a data array and configuration parameters to calculate the exact values for MACD or RSI.

## Use Cases

### Checking for Oversold Conditions
A day trader sees a dip and asks their agent: 'Calculate the RSI using this week's prices. Is the latest reading below 30?' The agent runs `calculate_macd_rsi`, gets the precise value, and confirms if the asset is in an oversold zone.

### Verifying Bullish Crosses
A quant needs to confirm a potential buy signal. They provide 100 days of data and ask their agent to run MACD analysis, specifically checking if the MACD line crossed above the Signal line in the last three periods. The engine confirms the crossover point.

### Detecting Bearish Divergence
A researcher spots a new price peak but suspects weakness. They input the historical data and ask the agent to calculate RSI while checking for divergence patterns, confirming if the current high is accompanied by an RSI lower than previous highs.

### Backtesting Signal Performance
A developer needs to test a strategy based on MACD crossovers. They feed `calculate_macd_rsi` thousands of historical price points and ask the agent to flag every instance where the indicator crossed above zero, building a clean list for backtesting.

## Benefits

- Signal Accuracy: You get exact MACD and RSI values every time. This isn't estimation; it's institutional-grade math, which is critical when detecting subtle crossover patterns.
- Direct Signal Detection: Use the results to check specific conditions—like if a price high creates a lower RSI value (bearish divergence). The engine handles this complex comparison for you.
- Handles Complexity: Don't risk using an LLM that fails on multi-pass exponential averages. `calculate_macd_rsi` manages the heavy math so your agent just needs to interpret the signal.
- Efficient Workflow: Instead of writing boilerplate code to calculate indicators, you pass the data and let the engine run it. Your agent stays focused on strategy, not calculus.
- Multi-Market Ready: The tool accepts any price array. Use it for daily stock closes, 1-hour crypto ticks, or even commodity futures.

## How It Works

The bottom line is: you get mathematically perfect indicator values without writing any complex math code yourself.

1. Provide the engine with your price data array (e.g., 100 days of closing prices) and specify the indicator type and parameters (e.g., 'RSI, period 14').
2. The agent invokes `calculate_macd_rsi`, which runs the complex, multi-pass mathematical calculation on the provided dataset.
3. You receive an exact numerical output for the requested indicators, ready to feed into a decision script or report.

## Frequently Asked Questions

**What does RSI indicate?**
RSI ranges from 0 to 100. Traditionally, a value above 70 indicates an asset is Overbought, and below 30 indicates it is Oversold.

**What are the MACD parameters?**
It uses the standard 12-period Fast EMA, 26-period Slow EMA, and 9-period Signal line to generate exact histograms.

**Is this for crypto or stocks?**
Both. Technical oscillators are mathematically agnostic and work on any sequential numeric data array, regardless of the asset class.

**How do I format the input data array when calling `calculate_macd_rsi`?**
You must provide a simple, sequential array of closing prices. The function expects pure numerical values for every point in time. Don't worry about including high, low, or opening prices.

**What happens if I pass non-numeric or incomplete data to `calculate_macd_rsi`?**
The tool will return a specific validation error message immediately. It doesn't just fail; it tells you exactly which index in the array needs fixing so you can correct your input.

**Is there a performance limit on how many data points I can pass to `calculate_macd_rsi`?**
The engine handles large historical datasets efficiently. While extreme inputs might hit runtime limits, it is optimized for deep time series analysis and runs much faster than an LLM calculation.

**Does `calculate_macd_rsi` require the data to be sorted by date?**
No, you just need a chronological sequence of prices. The tool calculates indicators based on array position (order) rather than requiring explicit date stamps in your input.

**If I want to check multiple indicators at once, can I use `calculate_macd_rsi`?**
Yes, the tool is designed to calculate both MACD and RSI simultaneously. You just need to specify all necessary configuration parameters (like period lengths) in your single request.