Description:
I am working on a custom indicator in ProRealTime, and I want it to execute only once when a new candle is formed, rather than recalculating on every tick. Currently, the indicator logic is running for every tick movement, which is not what I intend.
Here’s the logic I’ve implemented:
// Declare a variable to store the last processed bar index
if not defined lastBarIndex then
lastBarIndex = 0
endif
// Check if a new candle has formed
if barindex > lastBarIndex then
// Indicator logic
randomValue = random // Example: Generate a random number
// Update the last processed bar index
lastBarIndex = barindex
endif
// Return the result
RETURN randomValue