Skip to main content
Glama
momentumStrategies.js6.3 kB
const { z } = require("zod"); const { momentumStrategy, awesomeOscillatorStrategy, ichimokuCloudStrategy, rsi2Strategy, stochasticOscillatorStrategy, williamsRStrategy, } = require("indicatorts"); const fetchOhlcvData = require("../utils/fetchOhlcvData"); module.exports = (server) => { server.tool( "calculate_momentum_strategy", "Calculate the Momentum Strategy for a given trading pair using Binance OHLCV data. Outputs: -1 (SELL), 0 (HOLD), 1 (BUY)", { symbol: z.string().describe("Trading pair, e.g., 'BTC/USDT'"), timeframe: z.string().default("1h").describe("Timeframe, e.g., '1m', '1h', '1d'"), period: z.number().default(14).describe("Period length for Momentum"), limit: z.number().default(100).describe("Number of OHLCV data points to fetch"), }, async ({ symbol, timeframe, period, limit }) => { try { const asset = await fetchOhlcvData(symbol, timeframe, limit); const result = momentumStrategy(asset, { period }); return { content: [{ type: "text", text: JSON.stringify(result) }] }; } catch (error) { return { content: [{ type: "text", text: `Error: ${error.message}` }] }; } } ); server.tool( "calculate_awesome_oscillator_strategy", "Calculate the Awesome Oscillator Strategy for a given trading pair using Binance OHLCV data. Outputs: -1 (SELL), 0 (HOLD), 1 (BUY)", { symbol: z.string().describe("Trading pair, e.g., 'BTC/USDT'"), timeframe: z.string().default("1h").describe("Timeframe, e.g., '1m', '1h', '1d'"), fastPeriod: z.number().default(5).describe("Fast period for AO"), slowPeriod: z.number().default(34).describe("Slow period for AO"), limit: z.number().default(100).describe("Number of OHLCV data points to fetch"), }, async ({ symbol, timeframe, fastPeriod, slowPeriod, limit }) => { try { const asset = await fetchOhlcvData(symbol, timeframe, limit); const result = awesomeOscillatorStrategy(asset, { fast: fastPeriod, slow: slowPeriod }); return { content: [{ type: "text", text: JSON.stringify(result) }] }; } catch (error) { return { content: [{ type: "text", text: `Error: ${error.message}` }] }; } } ); server.tool( "calculate_ichimoku_cloud_strategy", "Calculate the Ichimoku Cloud Strategy for a given trading pair using Binance OHLCV data. Outputs: -1 (SELL), 0 (HOLD), 1 (BUY)", { symbol: z.string().describe("Trading pair, e.g., 'BTC/USDT'"), timeframe: z.string().default("1h").describe("Timeframe, e.g., '1m', '1h', '1d'"), conversionPeriod: z.number().default(9).describe("Conversion line period"), basePeriod: z.number().default(26).describe("Base line period"), spanPeriod: z.number().default(52).describe("Leading span period"), limit: z.number().default(100).describe("Number of OHLCV data points to fetch"), }, async ({ symbol, timeframe, conversionPeriod, basePeriod, spanPeriod, limit }) => { try { const asset = await fetchOhlcvData(symbol, timeframe, limit); const result = ichimokuCloudStrategy(asset, { conversion: conversionPeriod, base: basePeriod, span: spanPeriod }); return { content: [{ type: "text", text: JSON.stringify(result) }] }; } catch (error) { return { content: [{ type: "text", text: `Error: ${error.message}` }] }; } } ); server.tool( "calculate_rsi2_strategy", "Calculate the RSI2 Strategy for a given trading pair using Binance OHLCV data. Outputs: -1 (SELL), 0 (HOLD), 1 (BUY)", { symbol: z.string().describe("Trading pair, e.g., 'BTC/USDT'"), timeframe: z.string().default("1h").describe("Timeframe, e.g., '1m', '1h', '1d'"), period: z.number().default(14).describe("Period length for RSI2"), limit: z.number().default(100).describe("Number of OHLCV data points to fetch"), }, async ({ symbol, timeframe, period, limit }) => { try { const asset = await fetchOhlcvData(symbol, timeframe, limit); const result = rsi2Strategy(asset, { period }); return { content: [{ type: "text", text: JSON.stringify(result) }] }; } catch (error) { return { content: [{ type: "text", text: `Error: ${error.message}` }] }; } } ); server.tool( "calculate_stochastic_oscillator_strategy", "Calculate the Stochastic Oscillator Strategy for a given trading pair using Binance OHLCV data. Outputs: -1 (SELL), 0 (HOLD), 1 (BUY)", { symbol: z.string().describe("Trading pair, e.g., 'BTC/USDT'"), timeframe: z.string().default("1h").describe("Timeframe, e.g., '1m', '1h', '1d'"), period: z.number().default(14).describe("Period length for STOCH"), signalPeriod: z.number().default(3).describe("Signal period for STOCH"), limit: z.number().default(100).describe("Number of OHLCV data points to fetch"), }, async ({ symbol, timeframe, period, signalPeriod, limit }) => { try { const asset = await fetchOhlcvData(symbol, timeframe, limit); const result = stochasticOscillatorStrategy(asset, { period, signal: signalPeriod }); return { content: [{ type: "text", text: JSON.stringify(result) }] }; } catch (error) { return { content: [{ type: "text", text: `Error: ${error.message}` }] }; } } ); server.tool( "calculate_williams_r_strategy", "Calculate the Williams R Strategy for a given trading pair using Binance OHLCV data. Outputs: -1 (SELL), 0 (HOLD), 1 (BUY)", { symbol: z.string().describe("Trading pair, e.g., 'BTC/USDT'"), timeframe: z.string().default("1h").describe("Timeframe, e.g., '1m', '1h', '1d'"), period: z.number().default(14).describe("Period length for WILLR"), limit: z.number().default(100).describe("Number of OHLCV data points to fetch"), }, async ({ symbol, timeframe, period, limit }) => { try { const asset = await fetchOhlcvData(symbol, timeframe, limit); const result = williamsRStrategy(asset, { period }); return { content: [{ type: "text", text: JSON.stringify(result) }] }; } catch (error) { return { content: [{ type: "text", text: `Error: ${error.message}` }] }; } } ); };

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/kukapay/crypto-indicators-mcp'

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