- This topic has 1 reply, 2 voices, and was last updated 7 months ago by .
Viewing 2 posts - 1 through 2 (of 2 total)
Viewing 2 posts - 1 through 2 (of 2 total)
- You must be logged in to reply to this topic.
Optuma Forums › Optuma Scripting › Watchlist column showing days since current streak
Hi,
I’m looking for a way to add a column to a watchlist that would show the # of days since a stock’s current Days Up (or Days Down) streak. For example, if the stock is currently up 3 days in a row, and it has been 45 days since it was last up 3 days in a row, the column would show “45”. If the stock rises tomorrow, so it’s up 4 days in a row, then the column would change to “125” (or however long it’s been since it was last up 4 days in a row).
I can do this easily by hardcoding the DU()==3, but then I’d have to change it each day, and it would differ depending on the stocks in the watchlist.
I can’t figure out how to get the TIMESINCESIGNAL formula to reflect today’s value, because it’s kind of circular.
Thanks for any help!
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.
Cookie | Duration | Description |
---|---|---|
cname | 14 days | This cookie is set by Optuma. The cookies is used to store the users campaign selection for selecting the correct version of Optuma to trial and is "Necessary". |
cookielawinfo-checbox-analytics | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics". |
cookielawinfo-checbox-functional | 11 months | The cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional". |
cookielawinfo-checbox-others | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other. |
cookielawinfo-checkbox-necessary | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary". |
cookielawinfo-checkbox-performance | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance". |
viewed_cookie_policy | 11 months | The cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data. |