英文:
Is it possible to only retrieve the latest/last value when using the request.security_lower_tf function in PineScript v5?
问题
Here's the translated code portion you requested:
这是我用来获取第二时间框架数值的代码:
secHighArr = request.security_lower_tf(syminfo.tickerid, "1S", high)
aTable = table.new(position.top_center, 2, 2)
table.cell(aTable, 1, 1, str.tostring(secHighArr))
如果我在5分钟时间框架上,显然会返回在5分钟周期内所有第二数值,有可能只获取最新/最后一个 secHighArr 值,而不是所有值吗?
英文:
So here’s the code that I’m using to retrieve the second timeframes values:
secHighArr = request.security_lower_tf(syminfo.tickerid, “1S”, high)
aTable = table.new(position.top_center,2,2)
table.cell(aTable, 1,1, str.tostring(secHighArr))
If I’m on a 5 minute timeframe this is obviously returning all the second values in the 5 minute period, is it possible to only retrieve the latest/last secHighArr value instead of all of them?
答案1
得分: 0
request.security_lower_tf
返回一个数组。您无法仅从此调用中获取一个值。
request.security_lower_tf(symbol, timeframe, expression, ignore_invalid_symbol, currency) → 数组<类型>
但是,由于它是一个数组,您可以使用以下方式获取该数组的最后一个值:
len = secHighArr.size()
float last_val = (len > 0) ? array.get(secHighArr, len - 1) : na
英文:
request.security_lower_tf
returns an array. You cannot get only one value out of this call.
request.security_lower_tf(symbol, timeframe, expression, ignore_invalid_symbol, currency) → array<type>
However, since it is an array, you can get the last value of that array with:
len = secHighArr.size()
float last_val = (len > 0) ? array.get(secHighArr, len - 1) : na
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论