함수

그리기

이 묶음의 이름 11개예요.
형식과 예를 함께 적었어요.

plot

선 그리기. 최대 40개. style: line·step(계단)·area(영역)·circles(점)·cross·histogram(0 기준 막대, 기본 상승·하락색)·columns(막대). color에 함수를 주면 봉마다 색: i => up[i] ? color.green : color.red. offset: 몇 봉 오른쪽(음수는 왼쪽)으로 밀기

형식
function plot(name: string, values: Source, o?: { color?: Color | PerBarColor; width?: number; style?: PlotStyle; lineStyle?: LineStyle; offset?: number }): void
예
plot('EMA', fast, { color: (i) => (fast[i] > fast[i - 1] ? color.green : color.red), width: 2 })

hline

가로 기준선 (이름·색·모양). 최대 20개

형식
function hline(value: number, o?: { label?: string; color?: Color; style?: LineStyle; width?: number }): void
예
hline(70, { label: 'Overbought', color: color.red })

fill

두 plot 사이 칠하기 (plot 이름으로, plot 다음에). 최대 10개. 투명도가 없는 색은 옅게 칠해요. downColor: 아래 선이 위로 올라간 구간의 색. color에 함수를 주면 봉마다 색(null이면 안 칠함)

형식
function fill(upper: string, lower: string, o?: { color?: Color | PerBarColor; downColor?: Color }): void
예
plot('Upper', bb.upper)
plot('Lower', bb.lower)
fill('Upper', 'Lower', { color: color.alpha(color.blue, 0.1) })

bgcolor

배경 칠하기 (조건 + 색, 또는 봉마다 색을 주는 함수). 최대 10개. 투명도가 없는 색은 옅게

형식
function bgcolor(when: Bool | PerBarColor, o?: { color?: Color }): void
예
bgcolor(gt(close, ta.ema(close, 200)), { color: color.green })

barcolor

캔들 색 바꾸기 (캔들 위 지표). 조건 + 색, 또는 봉마다 색을 주는 함수

형식
function barcolor(when: Bool | PerBarColor, o?: { color?: Color }): void
예
barcolor(ta.crossover(close, ta.sma(close, 20)), { color: color.yellow })

plotshape

조건이 참인 봉마다 모양 표시. 최대 20개. 위쪽 모양은 봉 아래, 아래쪽 모양은 봉 위가 기본

형식
function plotshape(when: Bool, o?: { shape?: Shape; location?: Place; price?: Source; color?: Color; textColor?: Color; text?: string; size?: Size }): void
예
plotshape(ta.crossover(fast, slow), { shape: 'triangleup', text: 'Buy' })

label

글자 표시. bar는 봉 번호(-1 = 마지막 봉, bar.count + 3 = 마지막 봉 오른쪽 빈 칸). price를 주면 그 가격에. style 'text'는 배경 없이, align 'right'는 점 오른쪽으로. 가장 최근 500개

형식
function label(bar: number, text: string, o?: { location?: Place; price?: number; color?: Color; textColor?: Color; style?: 'box' | 'text'; align?: 'left' | 'center' | 'right'; size?: Size }): void
예
label(-1, 'RSI ' + last(rsi).toFixed(1))

line

두 점(봉 번호, 가격)을 잇는 선. extend: 'right'·'left'·'both'로 끝까지. 가장 최근 500개

형식
function line(x1: number, y1: number, x2: number, y2: number, o?: { color?: Color; width?: number; style?: LineStyle; extend?: Extend }): void
예
line(-50, last(high), -1, last(high), { color: color.orange, style: 'dashed', extend: 'right' })

box

사각형 (봉 번호, 가격). color는 테두리, bg는 안쪽(투명도 없으면 옅게). extend 'right'면 오른쪽 끝까지. 가장 최근 500개

형식
function box(left: number, top: number, right: number, bottom: number, o?: { color?: Color; bg?: Color; width?: number; style?: LineStyle; extend?: Extend; text?: string; textColor?: Color }): void
예
box(-30, last(high), -1, last(low), { color: color.red, bg: color.alpha(color.red, 0.15), extend: 'right', text: 'Range' })

table

차트 구석에 표(대시보드). rows는 줄 목록, 줄은 칸 목록. 최대 4개, 60줄 × 10칸

형식
function table(o: { position?: Position; rows: (string | number | null | { text: string; color?: Color; bg?: Color; align?: 'left' | 'center' | 'right' })[][]; bg?: Color; textColor?: Color; border?: Color; size?: Size }): void
예
table({ position: 'top-right', rows: [['RSI', last(rsi).toFixed(1)], ['EMA', last(fast).toFixed(2)]] })

color

색. color.up / color.down은 보는 사람의 상승·하락 색. '#RRGGBB'·'#RRGGBBAA'도 돼요. color.alpha(c, 0.2)는 불투명도 0(안 보임)~1, color.new(c, 80)은 파인처럼 투명도 0~100

형식
const color: { up: Color; down: Color; red: Color; blue: Color; green: Color; orange: Color; yellow: Color; purple: Color; pink: Color; teal: Color; gray: Color; white: Color; black: Color; alpha(c: Color, opacity: number): Color; "new"(c: Color, transparency?: number): Color; rgb(r: number, g: number, b: number, opacity?: number): Color }
예
color.alpha(color.green, 0.2)

npm · GitHub