Skip to main content
Glama
trendStrategies.js10.3 kB
const { z } = require("zod"); const { absolutePriceOscillatorStrategy, aroonStrategy, balanceOfPowerStrategy, chandeForecastOscillatorStrategy, kdjStrategy, macdStrategy, parabolicSarStrategy, typicalPriceStrategy, volumeWeightedMovingAverageStrategy, vortexStrategy, } = require("indicatorts"); const fetchOhlcvData = require("../utils/fetchOhlcvData"); module.exports = (server) => { server.tool( "calculate_absolute_price_oscillator_strategy", "Calculate the Absolute Price 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(12).describe("Fast period for APO"), slowPeriod: z.number().default(26).describe("Slow period for APO"), 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 = absolutePriceOscillatorStrategy(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_aroon_strategy", "Calculate the Aroon 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 Aroon"), 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 = aroonStrategy(asset, { period }); return { content: [{ type: "text", text: JSON.stringify(result) }] }; } catch (error) { return { content: [{ type: "text", text: `Error: ${error.message}` }] }; } } ); server.tool( "calculate_balance_of_power_strategy", "Calculate the Balance of Power 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 BOP"), 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 = balanceOfPowerStrategy(asset, { period }); return { content: [{ type: "text", text: JSON.stringify(result) }] }; } catch (error) { return { content: [{ type: "text", text: `Error: ${error.message}` }] }; } } ); server.tool( "calculate_chande_forecast_oscillator_strategy", "Calculate the Chande Forecast 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 CFO"), 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 = chandeForecastOscillatorStrategy(asset, { period }); return { content: [{ type: "text", text: JSON.stringify(result) }] }; } catch (error) { return { content: [{ type: "text", text: `Error: ${error.message}` }] }; } } ); server.tool( "calculate_kdj_strategy", "Calculate the KDJ 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(9).describe("Period length for KDJ"), signalPeriod: z.number().default(3).describe("Signal period for KDJ"), 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 = kdjStrategy(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_macd_strategy", "Calculate the MACD 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(12).describe("Fast period for MACD"), slowPeriod: z.number().default(26).describe("Slow period for MACD"), signalPeriod: z.number().default(9).describe("Signal period for MACD"), limit: z.number().default(100).describe("Number of OHLCV data points to fetch"), }, async ({ symbol, timeframe, fastPeriod, slowPeriod, signalPeriod, limit }) => { try { const asset = await fetchOhlcvData(symbol, timeframe, limit); const result = macdStrategy(asset, { fast: fastPeriod, slow: slowPeriod, signal: signalPeriod }); return { content: [{ type: "text", text: JSON.stringify(result) }] }; } catch (error) { return { content: [{ type: "text", text: `Error: ${error.message}` }] }; } } ); server.tool( "calculate_parabolic_sar_strategy", "Calculate the Parabolic SAR 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'"), accelerationFactorStep: z.number().default(0.02).describe("Acceleration factor step for PSAR"), accelerationFactorMax: z.number().default(0.2).describe("Maximum acceleration factor for PSAR"), limit: z.number().default(100).describe("Number of OHLCV data points to fetch"), }, async ({ symbol, timeframe, accelerationFactorStep, accelerationFactorMax, limit }) => { try { const asset = await fetchOhlcvData(symbol, timeframe, limit); const result = parabolicSarStrategy(asset, { accelerationFactorStep, accelerationFactorMax }); return { content: [{ type: "text", text: JSON.stringify(result) }] }; } catch (error) { return { content: [{ type: "text", text: `Error: ${error.message}` }] }; } } ); server.tool( "calculate_typical_price_strategy", "Calculate the Typical Price 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 Typical Price"), 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 = typicalPriceStrategy(asset, { period }); return { content: [{ type: "text", text: JSON.stringify(result) }] }; } catch (error) { return { content: [{ type: "text", text: `Error: ${error.message}` }] }; } } ); server.tool( "calculate_volume_weighted_moving_average_strategy", "Calculate the VWMA 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 VWMA"), 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 = volumeWeightedMovingAverageStrategy(asset, { period }); return { content: [{ type: "text", text: JSON.stringify(result) }] }; } catch (error) { return { content: [{ type: "text", text: `Error: ${error.message}` }] }; } } ); server.tool( "calculate_vortex_strategy", "Calculate the Vortex 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 Vortex"), 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 = vortexStrategy(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