为什么我在尝试使用 TradingView 终端为股票代码创建价格表时出现语法错误?

问题描述 投票:0回答:0

`我正在为多个股票代码创建价格表,包括 HDFCBANK、KOTAKBANK、SBIN、AXISBANK、ICICIBANK、AUBANK 和 INDUSINDBK。该表应显示每只股票的当前价格、与前一天收盘价相比的百分比变化,以及股票交易价格是否高于前一天的高点 (PDH) 和前一天的低点 (PDL)。该表应根据最新的价格数据实时更新。当我尝试在交易视图终端中运行代码时,它在代码的第 5 行显示一些错误

//@version=5
indicator("Futures Price Table", overlay=true)

// Define the list of futures symbols
symbols = ["NIFTY1!", "BANKNIFTY1!", "YM1!", "NQ1!"]

// Define the table columns
tableCols = ["Symbol", "Price"]

// Define the table rows
var tableRows = array.new_string()

// Define the table data
var tableData = array.new_float()

// Define the function to update the table data
updateTableData() =>
    array.clear(tableRows)
    array.clear(tableData)
    for i = 0 to array.size(symbols) - 1
        // Get the latest price data for the symbol
        price = request.security(symbols[i], "D", close)

        // Add the data to the table
        array.push(tableRows, symbols[i])
        array.push(tableData, price)

// Call the function to update the table data
updateTableData()

// Define the function to display the table
displayTable() =>
    // Define the table header
    tableHeader = "<table><tr>"
    for i = 0 to array.size(tableCols) - 1
        tableHeader := tableHeader + "<th>" + tableCols[i] + "</th>"
    tableHeader := tableHeader + "</tr>"

    // Define the table rows
    tableRowsHtml = ""
    for i = 0 to array.size(tableRows) - 1
        tableRowHtml = "<tr>"
        tableRowHtml := tableRowHtml + "<td>" + tableRows[i] + "</td>"
        tableRowHtml := tableRowHtml + "<td>" + tostring(tableData[i], "#.##") + "</td>"
        tableRowHtml := tableRowHtml + "</tr>"
        tableRowsHtml := tableRowsHtml + tableRowHtml

    // Define the table footer
    tableFooter = "</table>"

    // Display the table
    htmlobject(tableHeader + tableRowsHtml + tableFooter)

// Call the function to display the table
displayTable()

// Define the function to update the table in real-time
updateTableRealtime() =>
    // Call the function to update the table data
    updateTableData()

    // Call the function to display the table
    displayTable()

// Call the function to update the table in real-time
timer = timer.new(1, updateTableRealtime, true)

如果有人有任何想法,请帮助我

tradingview-api
© www.soinside.com 2019 - 2024. All rights reserved.