Hello Everyone,
Welcome back to "Thinking in Pine" short video series. In this session, we have discussed few special cases of time series variables and using historical operator within local scope.
If you have not watched our previous video - "Thinking in Pine - Time Series", request you to do that before continuing this video.
🎲 Summary of our today's discussion
🎯 Example Program Used
🎲 References:
Welcome back to "Thinking in Pine" short video series. In this session, we have discussed few special cases of time series variables and using historical operator within local scope.
If you have not watched our previous video - "Thinking in Pine - Time Series", request you to do that before continuing this video.
🎲 Summary of our today's discussion
- How historical operator works for variables defined inside an conditional block
- How historical operator works for variables defined in a loop.
🎯 Example Program Used
// Time series for variables within a condition
varip showLogInLoop = true
if(bar_index%3 == 0)
specialBarIndex = bar_index
if(bar_index > last_bar_index-3 and showLogInLoop)
log.info('Current and Previous special bar index are : {0} and {1}', specialBarIndex, specialBarIndex[1])
showLogInLoop := false
// Time series of variables within a loop
arrayOfX = array.new<int>()
arrayOfLastX = array.new<int>()
for i = 1 to 5
x = i*10
arrayOfX.push(x)
arrayOfLastX.push(x[1])
if(barstate.islastconfirmedhistory)
log.info('Array of X : {0}', arrayOfX)
log.info('Array of last X : {0}', arrayOfLastX)
🎲 References:
Trial - www.trendoscope.io/trial
Subscribe - www.trendoscope.io/pricing
Telegram: p.trendoscope.io/telegram
Rate us : www.trustpilot.com/review/trendoscope.io
Subscribe - www.trendoscope.io/pricing
Telegram: p.trendoscope.io/telegram
Rate us : www.trustpilot.com/review/trendoscope.io