如何引用证券的高低价?使用request.security能否直接获取标的高低价?
关于Pine Script中request.security获取多数据系列的问题
当你调用request.security("SPX", timeframe.period, close)时,这个请求仅会返回SPX在当前时间框架下的收盘价数据。如果你需要获取同一标的的最高价(high)或最低价(low),不能直接引用,必须通过以下两种方式之一获取:
- 发起额外的
request.security()请求,分别指定目标数据系列:
spxClose = request.security("SPX", timeframe.period, close) spxHigh = request.security("SPX", timeframe.period, high) spxLow = request.security("SPX", timeframe.period, low)
- 在单次请求中同时获取多个数据系列,用元组打包返回(更高效,减少请求次数):
[spxClose, spxHigh, spxLow] = request.security("SPX", timeframe.period, [close, high, low])
内容的提问来源于stack exchange,提问作者KarlEs
相关产品推荐
相关产品推荐

