Is it possible to only retrieve the latest/last value when using the request.security_lower_tf function in PineScript v5?

huangapple go评论44阅读模式
英文:

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&lt;type&gt;

However, since it is an array, you can get the last value of that array with:

len = secHighArr.size()
float last_val = (len &gt; 0) ? array.get(secHighArr, len - 1) : na

huangapple
  • 本文由 发表于 2023年5月7日 23:40:41
  • 转载请务必保留本文链接:https://go.coder-hub.com/76194868.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定