스크립트에서 추가데이터 요청

May 31, 2022
두 개의 새로운 파인 스크립트™ 함수, request.security_lower_tf() 와 request.economic(), 또한 기존 request.security() 함수에 대한 개선으로 여러분의 스크립트에서 더 많은 데이터에 액세스할 수 있습니다.

request.security_lower_tf()

request.security_lower_tf() 함수를 사용하면 차트 타임프레임보다 더 낮은 타임프레임 데이터를 더 쉽게 요청할 수 있습니다. 이 새로운 함수가 없었을 때에는 60분 차트 바를 구성하는 모든 1분 인트라바에 액세스하려면 복잡한 사용자정의기능과 request.security() 콜을 필요로 했습니다. 새로운 request.security_lower_tf() 는 이제 각 인트라바에 대해 제공된 식의 값을 한 개씩 포함하는 어레이를 리턴하므로 이제 아주 쉽게 처리할 수 있습니다. 각차트 바에 따라 인트라바의 수가 다를 수 있습니다.

다음 보조지표는 각 차트바의 진행에 따른 1분 인트라바의 방향을 살펴봅니다. 만약 대부분의 인트라바가 차트바와 같은 극성이 아니라면, 우리는 그것의 몸체를 주황색으로 칠합니다.

//@version=5
indicator("Polarity Divergences", overlay = true)
// Fetch an array containing the +1/0/-1 direction of each 1min intrabar.
array<float> directionsArray = request.security_lower_tf(syminfo.tickerid, "1", math.sign(close - open))
// Color the chart bar orange when the majority of 
// intrabar directions does not match the chart bar's direction.
barcolor(math.sign(array.sum(directionsArray)) != math.sign(close - open) ? color.orange : na)
// Plot the number of intrabars in indicator values and the Data Window.
plotchar(array.size(directionsArray), "Intrabars", "", location.top)

request.economic()

request.economic() 함수는 국가 또는 지역에 대한 경제데이터를 가져옵니다. 경제데이터는 한 국가의 경제상태(GDP, 인플레이션율 등) 또는 특정산업(철강생산, 중환자실침대 등)과 같은 정보를 포함합니다:

//@version=5
indicator("Gross domestic product of the US")
plot(request.economic("US", "GDP"))

당사 헬프 센터 아티클에는 사용 가능한 모든 국가/지역 및 메트릭 리스트가 나와 있습니다. 각 메트릭에 대한 추가 헬프센터 글은 메트릭 내용 설명 및 그 메트릭을 쓸 수 있는 나라/지역 리스트를 보여줍니다. GDP에 대한 것은 여기에 나와 있습니다.

request.security() 개선사항

request.security() 는 이제 다음과 같은 유형의 어레이, 스트링, 불리언, 컬러 및 튜플을 리턴할 수 있습니다:

//@version=5
indicator("")

// Create an array containing OHLC values.
array<float>  ohlc = array.from(open, high, low, close)

// Request a tuple evaluated in the context of the "NASDAQ:TSLA" symbol at the chart's timeframe.
// The tuple contains:
//   - The array of OHLC values.
//   - A string representation of the OHLC values using the symbol's tick precision.
//   - The currency string of the symbol.
[ohlcArray, ohlcString, curString]  = request.security("NASDAQ:TSLA", timeframe.period, [ohlc, str.tostring(ohlc, format.mintick), syminfo.currency])

if barstate.islastconfirmedhistory
    label.new(bar_index, high, 
      "OHLC values: " + str.tostring(ohlcArray) +
      "\nFormatted OHLC values: " + ohlcString +
      "\nCurrency: " + curString)

 

새로운 파인 피처에 대한 정보를 계속 얻으려면, 유저 매뉴얼의 릴리즈 노트를 참조하십시오. 또한,  파인코더즈 어카운트는 스쿼크 박스 텔레그램채널, 트위터 어카운트, 트레이딩뷰의 “파인스크립트™ Q&A” 퍼블릭챗 등을 통해 업데이트를 내보내고 있습니다.

이러한 개선 사항이 유용하게 사용되기를 바랍니다. 계속해서 피드백을 보내주십시오. 사용자를 위해 트레이딩뷰를 만들어 나가고 있으며, 여러분의 의견은 듣고 싶습니다.

Look first Then leap

트레이딩뷰는 여러분을 위해 만들어졌으므로 트레이딩뷰의 멋진 기능을 최대한 활용하세요
차트 시작