콘텐츠로 이동

ta.* 함수 레퍼런스

ta 네임스페이스는 TSeries 기반 기술 지표/유틸리티를 제공합니다.

시그니처 요약

함수 시그니처 반환
ta.sma (source, length) TSeries
ta.ema (source, length) TSeries
ta.wma (source, length) TSeries
ta.rma (source, length) TSeries
ta.rsi (source, length=14) TSeries
ta.macd (source, fast=12, slow=26, signal=9) (TSeries, TSeries, TSeries)
ta.stoch (high, low, close, k_period=14, d_period=3, smooth_k=3) (TSeries, TSeries)
ta.cci (high, low, close, length=20) TSeries
ta.bbands (source, length=20, mult=2.0) (TSeries, TSeries, TSeries)
ta.atr (high, low, close, length=14) TSeries
ta.stdev (source, length) TSeries
ta.mom (source, length=10) TSeries
ta.roc (source, length=10) TSeries
ta.adx (high, low, close, length=14) TSeries
ta.obv (close, volume) TSeries
ta.vwap (high, low, close, volume) TSeries
ta.highest (source, length) TSeries
ta.lowest (source, length) TSeries
ta.change (source, length=1) TSeries
ta.crossover (s1, s2) bool
ta.crossunder (s1, s2) bool
ta.sum (source, length) TSeries
ta.valuewhen (condition, source) TSeries
ta.barssince (condition) TSeries

자주 쓰는 예제

이동평균 + RSI

c = chart("1D")
fast = ta.ema(c.close, 12)
slow = ta.ema(c.close, 26)
rsi = ta.rsi(c.close, 14)

if fast.cross_up(slow) and rsi[0] < 60:
    buy(tag="EMA 상향 + RSI 확인")
elif fast.cross_down(slow):
    sell(tag="EMA 하향")
else:
    hold()

CCI (주의: high/low/close 3개 입력)

c = chart("1D")
cci = ta.cci(c.high, c.low, c.close, 20)

if cci[0] < -100:
    buy(tag="CCI 과매도")
elif cci[0] > 100:
    sell(tag="CCI 과매수")

crossover/crossunder

c = chart("1D")
sma5 = ta.sma(c.close, 5)
sma20 = ta.sma(c.close, 20)

if ta.crossover(sma5, sma20):
    buy(tag="골든크로스")
elif ta.crossunder(sma5, sma20):
    sell(tag="데드크로스")

valuewhen/barssince

c = chart("1D")
rsi = ta.rsi(c.close, 14)
cond = rsi < 30

last_price_when_oversold = ta.valuewhen(cond, c.close)
bars_after_oversold = ta.barssince(cond)

log("last oversold price:", last_price_when_oversold[0])
log("bars since oversold:", bars_after_oversold[0])

입력/출력 규칙

  • 대부분 입력은 TSeries지만 내부적으로 list, tuple, 숫자도 허용됩니다.
  • 반환은 대부분 TSeries이며, 다중 반환 함수는 튜플입니다.
  • TSeries 비교는 최신값([0]) 기준으로 평가됩니다.

관련 문서