Calculate historical stock returns and retrieve 52-week highs and lows in Excel with MarketXLS India. Connect your broker and add the functions to an NSE watchlist.
Try it in your own spreadsheet
Get the free MarketXLS sample workbook (.xlsx).
No account needed. MarketXLS live data requires a paid plan. Preview workbook
Get MarketXLS India: plans and subscription · See the India Excel add-in
Start with this formula
After connecting the required broker in the India add-in, enter:
=MXLSIN.ZerodhaReturn("RELIANCE", 30)
Use the example as a starting point and replace its instrument, date range or cell references with your own inputs. Historical dates in examples are sample periods; expiry-specific symbols must refer to a valid contract.
Set up the worksheet
- Open Excel and install MarketXLS India from the add-in marketplace.
- Sign in with your MarketXLS India account. For broker data, connect Zerodha or Angel One using the add-in panel. Use the broker named by a broker-specific formula.
- Enter the formula in an empty area. Leave adjacent cells clear for any table or multi-cell output.
- Confirm the instrument and settings before extending the worksheet.
Create columns for symbol, current price, return lookback, historical return, 52-week high and 52-week low. Keep the return period in a labelled input cell. Verify the returned units before formatting the results as percentages.
Build the working example
To measure distance below a high, calculate current price divided by the 52-week high minus one. Use the same instrument in both inputs. A stock close to its high and a stock with a high recent return are not necessarily the same thing; show the measures separately.
Functions and syntax
These examples use the India namespace, MXLSIN.. Square brackets in a syntax line indicate optional arguments; do not type the brackets into Excel. Keep text arguments in quotation marks and use cell references when you want editable inputs.
ZerodhaReturn
Returns the percentage price return of a symbol over the last N days, using Zerodha history.
Syntax:
MXLSIN.ZerodhaReturn(symbol, days)
Example:
=MXLSIN.ZerodhaReturn("RELIANCE", 30)
Zerodha52WeekHigh
Returns the 52-week high price of a symbol from Zerodha history.
Syntax:
MXLSIN.Zerodha52WeekHigh(symbol)
Example:
=MXLSIN.Zerodha52WeekHigh("RELIANCE")
Zerodha52WeekLow
Returns the 52-week low price of a symbol from Zerodha history.
Syntax:
MXLSIN.Zerodha52WeekLow(symbol)
Example:
=MXLSIN.Zerodha52WeekLow("RELIANCE")
AngelOneReturn
Returns the percentage price return of a symbol over the last N days, using Angel One history.
Syntax:
MXLSIN.AngelOneReturn(symbol, days)
Example:
=MXLSIN.AngelOneReturn("SBIN", 30)
Check the result
Historical comparisons depend on available data and corporate-action treatment. A split or other adjustment can affect interpretation. Check the broker's series before comparing periods, and do not label a price return as a total return including dividends.
If Excel reports #NAME?, confirm the India add-in is loaded and the function name is spelled correctly. If a table reports #SPILL!, clear the cells in its output area. For missing broker data, check the connection in the add-in panel, verify the symbol, and test one request before expanding the sheet. Do not replace an error with zero when zero would change your analysis.
Can I compare several stocks at once?
Yes. Use a consistent lookback and observation date across the watchlist. Leave missing history visible so a stock with insufficient data is not ranked as if its return were zero.
Get this working in your Excel
Choose a MarketXLS India subscription, install the India add-in, and follow the steps above. The pricing page lists the current subscription options; broker access requirements are separate from the spreadsheet formulas.
Use the India function library for the complete parameter reference, or contact the India team with the formula, instrument and error message if you need setup help. Never send broker passwords or access tokens.
Continue with the India Excel workflow series for related guides.

