- This topic has 4 replies, 2 voices, and was last updated 2 months ago by .
Viewing 5 posts - 1 through 5 (of 5 total)
Viewing 5 posts - 1 through 5 (of 5 total)
- You must be logged in to reply to this topic.
Optuma Forums › Optuma Scripting › Help with Last Occurring Signal Script
Hi. I am trying to capture the last time a Signal occurred.
I am capturing a high pivot as a Signal and tried using BARDATE where the Signal occurs and then returning the last BARDATE.
Nothing appears to happen when I use this in a Show Bar:
1 2 3 4 5 6 7 8 9 |
cond1 = HIGH() > HIGH(OFFSET=1); cond2 = HIGH() > HIGH(OFFSET=-1); sig = cond1 and cond2; v2 = BARDATE(); v3 = VALUEWHEN(sig, v2); v4 = v2 == LAST(v3); v4 |
Hi,
I think the issue is with the V3 variable, the two items within the brackets need to swap order.
1 2 3 4 5 6 7 8 9 |
cond1 = HIGH() > HIGH(OFFSET=1); cond2 = HIGH() > HIGH(OFFSET=-1); sig = cond1 and cond2; v2 = BARDATE(); v3 = VALUEWHEN(v2, sig); v4 = v2 == LAST(v3); v4 |
Thanks for the correction. However, I could not get it to work:
cond1 = HIGH() > HIGH(OFFSET=1);
cond2 = HIGH() > HIGH(OFFSET=-1);
sig = cond1 and cond2;
v2 = BARDATE();
v3 = VALUEWHEN(v2, sig);
v4 = v2 == LAST(v3);
v4
But when I tried the following instead, it worked:
cond1 = HIGH() > HIGH(OFFSET=1);
cond2 = HIGH() > HIGH(OFFSET=-1);
sig = cond1 and cond2;
v2 = BARDATE();
v3 = VALUEWHEN(HIGH(), sig);
v4 = HIGH() == LAST(v3);
v4
The problem with the latter script is that the same High, even if rare, can possibly occur multiple times and I want the last bar where the Signal is true.
Which part of the adjusted script did not work for you?
I’ve used it here and checked it against the raw output of the SIG variable it is producing the expected result.
It appears to be working now.
For some reason it was slow to appear and I had to click somewhere on the chart after applying the Show Bar.
Might need a reboot.
Thanks for clarifying.
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. |