How to use TradingAPI Technical Analysis API for Stocks, forex and commodities?

Created by TradingAPI Support, Modified on Sat, 28 Sep at 4:35 AM by TradingAPI Support

To use the POST endpoints for analyzing custom data like stocks, forex, and commodities for technical analysis, follow these steps:

  1. Endpoint: Use the Technical Analysis endpoint: https://tradingapi.rest/v1/indicator/{indicator}
  2. Replace {indicator} with the desired technical indicator (e.g., "rsi", "macd", "bbands").
  3. Required Parameters (as query parameters):
    • timestamp: Set to 1 to include timestamps in the response
    • timeperiod: The period for the indicator calculation (e.g., 14 for RSI)
    • backtrack: Number of periods to go back in time
    • backtracks: Number of periods to calculate the indicator
    • reverse: Set to 1 to reverse the order of returned data
  4. Required Headers:
    • Accept: "application/json"
    • Content-Type: "application/json"
    • User-Agent: Your custom User Agent (optional)
  5. Request Body: Provide an array of price data points, each containing:
    • open: Opening price
    • high: Highest price
    • low: Lowest price
    • close: Closing price
    • volume: Trading volume
    • timestamp: Unix timestamp in milliseconds


import requests

url = "https://tradingapi.rest/v1/indicator/rsi"
params = {
    "timestamp": 1,
    "timeperiod": 14,
    "backtrack": 50,
    "backtracks": 50,
    "reverse": 0
}
headers = {
    "Accept": "application/json",
    "Content-Type": "application/json",
    "User-Agent": "YOUR-USER-AGENT"
}
data = [
    {
        "open": "34557.67",
        "high": "34612.33",
        "low": "34535.68",
        "close": "34606.34",
        "volume": "39.206917",
        "timestamp": "1698939120000"
    },
    {
        "open": "34658.34",
        "high": "34658.34",
        "low": "34548.35",
        "close": "34557.67",
        "volume": "48.949532",
        "timestamp": "1698939060000"
    }
    # Add more data points as needed
]

response = requests.post(url, params=params, headers=headers, json=data)
result = response.json()
print(result)

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article