Optuma Forums › Optuma Scripting › Watchlist column showing days since current streak › Reply To: Watchlist column showing days since current streak
December 29, 2021 at 11:12 am
#67034
- Topics: 5
- Replies: 616
- Posts: 621
Hi,
I would use a mix of the LAST(), TIMESINCESIGNAL() and NONZERO() functions to get this result.
1 2 3 4 5 6 7 8 9 10 11 12 |
//Set Days Up V1 = DU() ; //Find Days Up Last Value V2 = LAST(DU()) ; //Find all instances where past DU values are the same as the current value V3 = V1 == V2; //Measure bars between each instance V4 = NONZERO(TIMESINCESIGNAL(V3)); //Add one if you want to include the trigger day V4 + 1 |
On the chart / watchlist the above script would look like this:
In the above example the current Days Up Streak is two, which last occurred 10 bars ago.
This script is dynamic, it will take the current Days Up streak value, and find when that same value streak last occurred.