Login Page - Create Account

Support Board


Date/Time: Sun, 24 Nov 2024 05:12:08 +0000



[Programming Help] - Programming Help - SpreadSheets Loop Count

View Count: 75

[2024-11-03 22:37:30]
Le Dharma - Posts: 73
Hey Sierra. I am trying to program an equation In Spreadsheets.

I would like to create a counter, which counts only the last 50 bars (rows).
The counter could start at 50 and count downwards, in P3, or It could start at 1 and count to 50, on row P53.

Can anyone help me figure out how to create a counter in spreadsheets?
Thanks,
-Ben
Date Time Of Last Edit: 2024-11-03 23:03:46
[2024-11-03 22:50:03]
User224654 - Posts: 18
Try this in cell P3:
=MOD(ROW() - 3, 50) + 1

Explanation:

ROW() returns the current row number.

ROW() - 3 adjusts the row number, as Sierra Chart data typically starts from row 3.

MOD(..., 50) calculates the remainder of division by 50, resulting in values between 0 and 49.

Adding 1 shifts the range to 1 through 50.


This formula will count from 1 to 50 and automatically reset after each 50-bar cycle.

Note: In Sierra Chart, formulas are usually entered in row 3 and applied automatically to rows below. Make sure the formula is in the correct starting row for the desired effect.
[2024-11-03 23:05:11]
Le Dharma - Posts: 73
I should not have said, I dont mind using a counter which repeats.

I do need a counter that stops after the first 50 bars.
Does anyone know how to write this?

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account