Tutorial: Build your own stock signals with a technical indicators API


A stock signals API usually hands you a verdict: BUY, SELL or HOLD. What it often doesn’t hand you is why. You can’t see the rules, you can’t tune them, and you can’t tell whether a signal changed because the market moved or because the vendor changed its model.

Most of those signals are built from the same handful of indicators anyway: trend filters, RSI and MACD. So in this tutorial you’ll build your own. You’ll fetch SuperTrend, RSI and MACD for US stocks from the TAAPI.IO API, turn them into BUY, SELL and HOLD signals with rules you can read in ten lines of Python, scan a watchlist every morning, and look back 100 days to see when the rules fired.

Every request and output below comes from the live API on 24 November 2026.

Signals from technical indicators are a starting point, not investment advice. Test any rule on your own markets before you trade with it.

What you need

  • Python 3.9 or newer and pip install requests
  • A TAAPI.IO API key in an environment variable, so it never ends up in your code:
export TAAPI_KEY_V2="your_api_key"

US stock data is on the Pro plan and higher, and Pro allows 3 constructs per bulk request. A construct is one symbol and timeframe, so one request covers three stocks. See pricing for the plans and the 7-day free trial.

The rules

We’ll use three indicators on daily candles, all with their default settings:

Indicator Settings Role in the signal
SuperTrend 7, 3 The trigger: valueAdvice is long or short, and a change from one candle to the next is a trend flip
RSI 14 The filter: skip a BUY when RSI is 70 or above, because the move may already be stretched
MACD 12, 26, 9 The context: a histogram crossing zero is an early hint, shown as a note on HOLD

Put together:

  • BUY: SuperTrend flipped to long on the last closed candle and RSI is below 70
  • SELL: SuperTrend flipped to short on the last closed candle
  • HOLD: no flip. Report the current trend and RSI, and note a MACD histogram crossing if there was one

These rules are deliberately simple. The point is that you can see them and change them.

Step 1: Get all three indicators in one request

The /bulk endpoint calculates several indicators on the same candles in one call. For Apple:

import os
import requests

body = {'constructs': [{
    'id': 'AAPL', 'exchange': 'stocks', 'symbol': 'AAPL', 'timeframe': '1d',
    'indicators': [
        {'id': 'supertrend', 'indicator': 'supertrend', 'results': 2, 'backtrack': 1},
        {'id': 'rsi', 'indicator': 'rsi', 'backtrack': 1},
        {'id': 'macd', 'indicator': 'macd', 'results': 2, 'backtrack': 1},
    ],
}]}
r = requests.post('https://v2.taapi.io/bulk', json=body,
                  headers={'Authorization': f"Bearer {os.environ['TAAPI_KEY_V2']}"})
print(r.json())
  • backtrack=1 skips today’s candle, which is still forming, so the signal is based on the last closed day.
  • results=2 on SuperTrend and MACD returns the last two closed candles, which is what you need to spot a flip or a zero crossing.

This is the response from the morning of 24 November 2026, so the last closed candle is Monday 23 November:

{
  "AAPL": {
    "supertrend": {
      "value": [328.1856529085241, 328.1856529085241],
      "valueAdvice": ["long", "long"],
      "timestamp": [1795132800, 1795392000]
    },
    "rsi": {
      "value": [52.629055311618025],
      "timestamp": [1795392000]
    },
    "macd": {
      "valueMACD": [3.1276167841888878, 2.896369864771657],
      "valueMACDSignal": [3.5621263331804864, 3.4289750394987206],
      "valueMACDHist": [-0.43450954899159866, -0.5326051747270637],
      "timestamp": [1795132800, 1795392000]
    }
  }
}

Arrays are ordered oldest first. The two SuperTrend timestamps are Friday 20 and Monday 23 November: the market was closed at the weekend, so there are no candles in between. Apple’s trend is long on both days, so no flip, and RSI is a neutral 52.6.

Step 2: Turn the values into a signal

The rules from above, as a function that takes one stock’s part of the bulk response:

def signal(d):
    prev_trend, trend = d['supertrend']['valueAdvice']
    rsi = d['rsi']['value'][-1]
    prev_hist, hist = d['macd']['valueMACDHist']

    if trend != prev_trend:
        if trend == 'long' and rsi < 70:
            return 'BUY', f'SuperTrend flipped long, RSI {rsi:.1f}'
        if trend == 'short':
            return 'SELL', f'SuperTrend flipped short, RSI {rsi:.1f}'
    note = f'trend {trend}, RSI {rsi:.1f}'
    if prev_hist < 0 <= hist:
        note += ', MACD crossed up'
    elif prev_hist > 0 >= hist:
        note += ', MACD crossed down'
    return 'HOLD', note

Every signal comes with its reason. When you look at a BUY later, you know exactly which condition produced it.

Step 3: Scan a watchlist every morning

The full script splits the watchlist into groups of three, one bulk request per group, and prints a signal per stock. The call() helper retries on 202 (data still being fetched) and 429 (rate limit), so it keeps working when you add more stocks:

import os
import time
from datetime import datetime, timezone

import requests

API_URL = 'https://v2.taapi.io'
API_KEY = os.environ.get('TAAPI_KEY_V2')

WATCHLIST = ['AAPL', 'MSFT', 'NVDA', 'AMZN', 'TSLA', 'META']
CONSTRUCTS_PER_REQUEST = 3  # Pro plan: 3 constructs per bulk request


def call(method, path, **kwargs):
    """Send a request, wait and retry on 202 (queued) and 429 (rate limit)."""
    for _ in range(5):
        r = requests.request(method, f'{API_URL}{path}', timeout=30,
                             headers={'Authorization': f'Bearer {API_KEY}'}, **kwargs)
        if r.status_code == 202:
            time.sleep(2)
        elif r.status_code == 429:
            time.sleep(r.json().get('retryAfter', 15))
        else:
            r.raise_for_status()
            return r.json()
    raise RuntimeError(f'{path}: no result after 5 attempts')


def construct(symbol):
    return {
        'id': symbol, 'exchange': 'stocks', 'symbol': symbol, 'timeframe': '1d',
        'indicators': [
            {'id': 'supertrend', 'indicator': 'supertrend', 'results': 2, 'backtrack': 1},
            {'id': 'rsi', 'indicator': 'rsi', 'backtrack': 1},
            {'id': 'macd', 'indicator': 'macd', 'results': 2, 'backtrack': 1},
        ],
    }


def signal(d):
    prev_trend, trend = d['supertrend']['valueAdvice']
    rsi = d['rsi']['value'][-1]
    prev_hist, hist = d['macd']['valueMACDHist']

    if trend != prev_trend:
        if trend == 'long' and rsi < 70:
            return 'BUY', f'SuperTrend flipped long, RSI {rsi:.1f}'
        if trend == 'short':
            return 'SELL', f'SuperTrend flipped short, RSI {rsi:.1f}'
    note = f'trend {trend}, RSI {rsi:.1f}'
    if prev_hist < 0 <= hist:
        note += ', MACD crossed up'
    elif prev_hist > 0 >= hist:
        note += ', MACD crossed down'
    return 'HOLD', note


results = {}
for i in range(0, len(WATCHLIST), CONSTRUCTS_PER_REQUEST):
    batch = WATCHLIST[i:i + CONSTRUCTS_PER_REQUEST]
    results.update(call('POST', '/bulk', json={'constructs': [construct(s) for s in batch]}))

first = results[WATCHLIST[0]]['supertrend']['timestamp'][-1]
print(f"Signals for the daily candle of {datetime.fromtimestamp(first, timezone.utc):%Y-%m-%d}")
for symbol in WATCHLIST:
    d = results[symbol]
    if d.get('_error'):
        print(f'{symbol:<5} error: {d["_error"]}')
        continue
    action, why = signal(d)
    print(f'{symbol:<5} {action:<4}  {why}')

Save it as signals.py and run python3 signals.py. Our run on 24 November:

Signals for the daily candle of 2026-11-23
AAPL  HOLD  trend long, RSI 52.6
MSFT  HOLD  trend short, RSI 38.4
NVDA  HOLD  trend short, RSI 43.9
AMZN  HOLD  trend long, RSI 49.4
TSLA  HOLD  trend short, RSI 52.9
META  HOLD  trend short, RSI 41.6

Six HOLDs is a normal day. A trend-flip rule on daily candles fires only a handful of times per stock in 100 trading days (see Step 4), not every day, which is the point: you want to hear from it when something changes. If a symbol is wrong, its construct comes back with _error and the others still work, so one typo doesn’t break the scan.

When to run it. TAAPI.IO stock data includes the pre-market and after-hours session, and a new daily candle starts with the pre-market at 4:00 AM New York time. Run the scan any time between then and the 9:30 AM open, and backtrack=1 gives you the full previous trading day. We ran it at 8:17 AM New York time. With cron, for example:

CRON_TZ=America/New_York
0 8 * * 1-5  /usr/bin/python3 /path/to/signals.py >> /path/to/signals.log

Step 4: Look back 100 days

Before trusting a rule, see when it would have fired. Ask for results=101 instead of 2, add the price indicator for the closes, and run the same signal() function on every pair of neighbouring candles. Add this below the signal() function, in place of the watchlist loop:

DAYS = 100
symbol = 'AAPL'

body = {'constructs': [{
    'id': symbol, 'exchange': 'stocks', 'symbol': symbol, 'timeframe': '1d',
    'indicators': [
        {'id': 'supertrend', 'indicator': 'supertrend', 'results': DAYS + 1, 'backtrack': 1},
        {'id': 'rsi', 'indicator': 'rsi', 'results': DAYS + 1, 'backtrack': 1},
        {'id': 'macd', 'indicator': 'macd', 'results': DAYS + 1, 'backtrack': 1},
        {'id': 'price', 'indicator': 'price', 'results': DAYS + 1, 'backtrack': 1},
    ],
}]}
d = call('POST', '/bulk', json=body)[symbol]

st, rsi, hist = d['supertrend'], d['rsi']['value'], d['macd']['valueMACDHist']
for i in range(1, len(st['timestamp'])):
    day = {
        'supertrend': {'valueAdvice': st['valueAdvice'][i - 1:i + 1]},
        'rsi': {'value': [rsi[i]]},
        'macd': {'valueMACDHist': hist[i - 1:i + 1]},
    }
    action, why = signal(day)
    if action != 'HOLD':
        date = datetime.fromtimestamp(st['timestamp'][i], timezone.utc)
        print(f"{date:%Y-%m-%d}  {action:<4}  close {d['price']['value'][i]:.2f}  ({why})")

All four indicators use the same results and backtrack, so their arrays line up candle for candle. For Apple, over the 100 trading days to 23 November:

2026-07-06  BUY   close 312.65  (SuperTrend flipped long, RSI 63.6)
2026-07-30  SELL  close 312.33  (SuperTrend flipped short, RSI 46.0)
2026-09-03  BUY   close 327.70  (SuperTrend flipped long, RSI 62.7)
2026-11-02  SELL  close 328.81  (SuperTrend flipped short, RSI 40.9)
2026-11-11  BUY   close 356.35  (SuperTrend flipped long, RSI 59.8)

Five signals in 100 days, and the latest, the BUY on 11 November, is still in force: that’s why the scan in Step 3 shows Apple as trend long. The BUY in July and the SELL that followed closed 32 cents apart, a reminder that a trend filter loses a little in sideways markets and earns its keep in the longer moves. A list like this is not a backtest, because it ignores costs, slippage and position sizing, but it shows in a minute how often your rules fire and where.

Make the rules your own

Everything above is a starting point. Some changes to try:

  • Tune SuperTrend. Add 'period': 10, 'multiplier': 3 to the SuperTrend indicator to match the default on many charting platforms. A lower multiplier gives more, earlier flips; a higher one gives fewer. See the SuperTrend settings.
  • Confirm with a second timeframe. Pro allows 3 constructs, so pair 1d with 1w for one stock and only take a BUY when the weekly trend is long too.
  • Add or swap indicators. Any of the 250+ indicators works in the same bulk request, for example ADX to skip signals when there’s no trend.
  • Send the signals somewhere. Replace the print with a message to Slack, Telegram or email, and only send when the action isn’t HOLD.

The same code works for crypto: change exchange to binance and the symbols to pairs like BTCUSDT. Crypto also runs on the Basic plan, which allows 1 construct per bulk request, so set CONSTRUCTS_PER_REQUEST = 1 there.