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

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

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:

  1. 这是我用来获取第二时间框架数值的代码:
  2. secHighArr = request.security_lower_tf(syminfo.tickerid, "1S", high)
  3. aTable = table.new(position.top_center, 2, 2)
  4. table.cell(aTable, 1, 1, str.tostring(secHighArr))
  5. 如果我在5分钟时间框架上,显然会返回在5分钟周期内所有第二数值,有可能只获取最新/最后一个 secHighArr 值,而不是所有值吗?
英文:

So here’s the code that I’m using to retrieve the second timeframes values:

  1. secHighArr = request.security_lower_tf(syminfo.tickerid, 1S”, high)
  2. aTable = table.new(position.top_center,2,2)
  3. 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 返回一个数组。您无法仅从此调用中获取一个值。

  1. request.security_lower_tf(symbol, timeframe, expression, ignore_invalid_symbol, currency) 数组<类型>

但是,由于它是一个数组,您可以使用以下方式获取该数组的最后一个值:

  1. len = secHighArr.size()
  2. 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.

  1. 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:

  1. len = secHighArr.size()
  2. 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:

确定