ขอข้อมูลเพิ่มเติมจากสคริปต์ของคุณ

May 31, 2022

สองฟังก์ชั่นใหม่ของ Pine Script™  request.security_lower_tf() และ request.economic(), และ การปรับปรุงฟังก์ชัน request.security() ที่มีอยู่ทำให้สคริปต์ของคุณเข้าถึงข้อมูลได้มากขึ้น

request.security_lower_tf()

ฟังก์ชันใหม่ request.security_lower_tf() ช่วยให้ขอข้อมูลจากไทม์เฟรมที่ต่ำกว่าชาร์ตได้ง่ายขึ้น ก่อนฟังก์ชันใหม่นี้ การเข้าถึง intrabars 1 นาทีทั้งหมดที่สร้างบาร์ชาร์ต  60 นาทีจำเป็นต้องมีฟังก์ชันที่ผู้ใช้กำหนดเองที่ซับซ้อนและการเรียก request.security() ใหม่ request.security_lower_tf() ตอนนี้ทำให้เป็น doddle โดยการส่งคืนอาร์เรย์ที่มีค่าหนึ่งของนิพจน์ที่ให้มาสำหรับแต่ละ intrabar โปรดทราบว่าจำนวน intrabars อาจแตกต่างกันไปตามแต่ละบาร์ชาร์ต

อินดิเคเตอร์ต่อไปนี้จะดูที่ทิศทางของ intrabars 1 นาทีในการขยายของแต่ละบาร์ชาร์ต หาก intrabars ส่วนใหญ่ไม่มีขั้วเดียวกันกับบาร์ชาร์ตจะระบายสีตัวของบาร์นั้นให้เป็นสีส้ม

//@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 อัตราเงินเฟ้อ ฯลฯ) หรือของอุตสาหกรรมเฉพาะ (การผลิตเหล็ก เตียง ICU ฯลฯ):

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

ศูนย์ช่วยเหลือด้านบทความของเราแสดงรายการประเทศ/ภูมิภาคและอินดิเคเตอร์ทั้งหมดที่มี บทความในศูนย์ช่วยเหลือเพิ่มเติมสำหรับแต่อินดิเคเตอร์จะอธิบายและแสดงรายการประเทศ/ภูมิภาคที่สามารถใช้ได้ นี่คือหนึ่งสำหรับ GDP นี่คือหนึ่งใน GDP.

request.security() improvements

ตอนนี้ 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)

หากต้องการรับทราบข้อมูลคุณสมบัติใหม่ ๆ ของ Pine โปรดติดตามบรรณานุกรมคู่มือผู้ใช้ บัญชี PineCoders ยังออกอากาศการอัปเดตจากช่อง Squawk Box Telegram ,บัญชี Twitter account, และจากการแชทสาธารณะ “Pine Script™ Q&A” บน TradingView

เราหวังว่าคุณจะพบว่าการปรับปรุงเหล่านี้มีประโยชน์ โปรดส่งความคิดเห็นของคุณถึงเราต่อไป เราสร้าง TradingView สำหรับผู้ใช้ของเรา และเรายินดีรับฟังความคิดเห็นจากคุณ

Look first Then leap

TradingView is built for you, so make sure you're getting the most of our awesome features
เปิดชาร์ต