Skip to main content
Glama

backtest_strategy

Test a Simple Moving Average crossover strategy by simulating trades based on SMA crossovers, comparing results against buy-and-hold performance for informed investment decisions.

Instructions

Backtest a Simple Moving Average (SMA) crossover strategy. [PRO]

Tests: Buy when short SMA crosses above long SMA, sell when it crosses below. Compares strategy return vs buy-and-hold.

Args: symbol: Stock ticker (e.g., RELIANCE, AAPL, TCS) short_window: Short SMA period in days (default: 20) long_window: Long SMA period in days (default: 50) period: Backtest period: 1y, 2y, 5y (default: 2y) initial_capital: Starting capital (default: 100000)

Examples: backtest_strategy("RELIANCE") → Default 20/50 SMA backtest backtest_strategy("AAPL", 10, 30, "5y") → Custom 10/30 SMA, 5 years backtest_strategy("TCS", 50, 200, "5y", 500000) → Golden cross, 5L capital

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
symbolYes
short_windowNo
long_windowNo
periodNo2y
initial_capitalNo

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/finstacklabs/finstack-mcp'

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