- This topic has 2 replies, 2 voices, and was last updated 1 year ago by .
Viewing 3 posts - 1 through 3 (of 3 total)
Viewing 3 posts - 1 through 3 (of 3 total)
- You must be logged in to reply to this topic.
Optuma Forums › Optuma Scripting › Persistency of X
Hello,
I’m looking to establish Persistency (PS) of certain criteria over a set amount of time, for example 20 day PS of Money Flow Index > 50 would indicate that the MFI has been over 50 for more than 20 days or essentially any indicator you’re looking at above or below whatever threshold for more than whatever period. I’ve tried TIMESINCESIGNAL using the reverse thinking but not sure what to do with the repeats after the initial trigger.
Hi,
I would use the BarsTrue() function to find the point where MFI has been above 50 for 20 bars, then use switch to keep the value true until the MFI crosses below 50.
1 2 3 4 5 6 7 8 9 10 11 12 |
//Set Money Flow Index V1 = MFI() ; //Is MFI Higher than 50 V2 = V1 > 50; //MFI crosses below 50 V3 = V1 CrossesBelow 50; //MFI has been higher than 50 for 20 days V4 = BARSTRUE(V2, LOOKBACK=20) == 20; //MFI higher than 50 for 20 bars, switch to false after MFI crosses below 50 SWITCH(V4,V3) |
Chart example:
This is excellent, thanks a lot
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. |