I am getting errors on how to do this currentIndex = ceil((sqrt(8 * sequenceValue + 1) - 1) / 2) in Pinescript
Currently at // Update currentIndex based on sequenceValue currentIndex := round((sqrt(float(8 * sequenceValue + 1)) - 1) / 2, round_half_up) any help would be appreciated.
The regular math formula for the expression ceil((sqrt(8 * sequenceValue + 1) - 1) / 2) is as follows:
- Evaluate the innermost expression:
8 * sequenceValue + 1. - Take the square root of the result from step 1:
sqrt(8 * sequenceValue + 1). - Subtract 1 from the result from step 2:
sqrt(8 * sequenceValue + 1) - 1. - Divide the result from step 3 by 2:
(sqrt(8 * sequenceValue + 1) - 1) / 2. - Apply the ceiling function to the result from step 4:
ceil((sqrt(8 * sequenceValue + 1) - 1) / 2).
In summary, the formula calculates the square root of (8 * sequenceValue + 1), subtracts 1, divides by 2, and then rounds up to the nearest integer using the ceiling function.