Hello everyone,
Welcome back to "Thinking in Pine" short video series. In this video, we discuss the concept of time series variables in Pinescript.
If you are not familiar with var and varip type of variables - please step back and watch this video before continuing - "Thinking in Pine - var, varip and regular variables"
🎲 Summary of our discussion is as follows
🎯 Example Program Used
Pine Script®
There are pitfalls of using historical operators within loop or under if condition. We will discuss that in our next video.
🎲 References:
Welcome back to "Thinking in Pine" short video series. In this video, we discuss the concept of time series variables in Pinescript.
If you are not familiar with var and varip type of variables - please step back and watch this video before continuing - "Thinking in Pine - var, varip and regular variables"
🎲 Summary of our discussion is as follows
- What are time series variables, and how are they used in Pinescript?
- How do we access historical values of time series?
- Limitations of accessing historical values
🎯 Example Program Used
currentBar = bar_index
var currentBarUsingVar = 0
currentBarUsingVar := bar_index
varip showLog = true
valueAt200thBar = ta.valuewhen(bar_index == 500, currentBar, 0)
if(barstate.islast and showLog)
log.info("Current Bar Values using regular and var variables : {0}, {1}", currentBar, currentBarUsingVar)
log.info("Last Bar Values using regular and var variables : {0}, {1}", currentBar[1], currentBarUsingVar[1])
log.info("Values 500 bars ago using regular and var variables : {0}, {1}", currentBar[500], currentBarUsingVar[500])
offset = bar_index-25000
log.info("Values at 25000th bar using regular and var variables : {0}, {1}", currentBar[offset], currentBarUsingVar[offset])
showLog := false
plot(bar_index, "Bar Index", color = color.blue, display = display.data_window)
var currentBarUsingVar = 0
currentBarUsingVar := bar_index
varip showLog = true
valueAt200thBar = ta.valuewhen(bar_index == 500, currentBar, 0)
if(barstate.islast and showLog)
log.info("Current Bar Values using regular and var variables : {0}, {1}", currentBar, currentBarUsingVar)
log.info("Last Bar Values using regular and var variables : {0}, {1}", currentBar[1], currentBarUsingVar[1])
log.info("Values 500 bars ago using regular and var variables : {0}, {1}", currentBar[500], currentBarUsingVar[500])
offset = bar_index-25000
log.info("Values at 25000th bar using regular and var variables : {0}, {1}", currentBar[offset], currentBarUsingVar[offset])
showLog := false
plot(bar_index, "Bar Index", color = color.blue, display = display.data_window)
There are pitfalls of using historical operators within loop or under if condition. We will discuss that in our next video.
🎲 References:
- Pine Script® User Manual - Execution Model
- Pine Script® User Manual - Time Series
- Pine Script® User Manual - History Referencing Operator
- [url=tradingview.com/pine-script-reference/v5/[]]Pine Script® Reference Manual - History Referencing Operator
Trial - trendoscope.io/trial
Subscribe - trendoscope.io/pricing
Blog - docs.trendoscope.io
Subscribe - trendoscope.io/pricing
Blog - docs.trendoscope.io
관련 발행물
면책사항
이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.
Trial - trendoscope.io/trial
Subscribe - trendoscope.io/pricing
Blog - docs.trendoscope.io
Subscribe - trendoscope.io/pricing
Blog - docs.trendoscope.io
관련 발행물
면책사항
이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.