Pine 스크립트 인디케이터 보기

From TradingView Wiki
Jump to: navigation, search
Language: English  • 日本語 • 한국어 • Русский


Pine 프로그램은 함수와 변수로 이루어진다. 함수는 필요한 계산을 나타내는 명령과 계산과정에서 나오는 값들을 저장하는 변수를 포함한다. 소스 코드는 빈칸으로 시작해서는 안 된다 (단, “멀티라인 함수 신택스” 는 예외). 스크립트는 스크립트 이름 및 스크립트 프로퍼티를 지정하는 study 함수를 반드시 써야 한다. 스크립트 본문은 함수와 변수를 써서 얻은 결과값을 plot 함수로 차트에 그린다. 첫 보기로, MACD 지표가 어떻게 되어 있는지 살펴보기로 하자:

study("MACD")
fast = 12, slow = 26
fastMA = ema(close, fast)
slowMA = ema(close, slow)
macd = fastMA - slowMA
signal = sma(macd, 9)
plot(macd, color=blue)
plot(signal, color=orange)
study("MACD")
Sets the name of the indicator — “MACD”
fast = 12, slow = 26
Defines two integer variables, ‘fast’ and ‘slow’.
fastMA = ema(close, fast)
Defines the variable fastMA, containing the result of the calculation EMA (Exponential Moving Average) with the length equal to ‘fast’ (12) on ’close’ series (closing prices of bars).
slowMA = ema(close, slow)
Defines the variable slowMA, containing the result of the calculation EMA with the length equal to ‘slow’ (26) from ‘close’.
macd = fastMA - slowMA
Defines the variable ‘macd’, which is being calculated as a difference between two EMA with different length inputs.
signal = sma(macd, 9)
Defines the variable ‘signal’, calculated as a smooth value of the variable ‘macd’ by the algorithm SMA (Simple Moving Average) with length equal to
plot(macd, color=blue)
Call function ‘plot’, which would draw a chart based on values, saved in the variable ‘macd’ (the color of the line is blue).
plot(signal, color=orange)
Call function ‘plot’, which would draw a chart for the variable ‘signal’ with an orange color.

After adding the indicator “MACD” to the chart we would see the following:

Macd pine.png

Pine contains a variety of built-in functions for the most popular algorithms (sma, ema, wma, etc.) as well as making it possible to create your custom functions. You can find a description of all available built-in functions here. In the following sections the document will describe in full all the Pine Script capabilities.


Previous: Introduction/ko, Next: Structure of the Script/ko, Up: Pine Script Tutorial/ko