TimeSinceSignal formulas

Optuma Forums Optuma Scripting TimeSinceSignal formulas

This topic contains 7 replies, has 2 voices, and was last updated by Darren Darren 2 weeks, 3 days ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #48071
    Darren
    Darren
    • Topics: 28
    • Replies: 131
    • Posts: 159

    The TimeSinceSignal function is very useful to determine how long has elapsed since a technical event (see here and here for some examples).

    Here’s a variation which counts the number of trading days since two moving averages crossed, calculating a positive number when crossing above and a negative number when crossing below. The example is for the 20EMA crossing the 50SMA:

    The script can be added to a watchlist column and also a Show View to display the results (note the Show View properties have been set to a Dot plotstyle, with a positive/negative colour scheme):

    Capture

    So NKE crossed above 105 days ago, and CVX crossed below 51 days ago.

    Also note that you can count in calendar days or weeks by changing the Units property in the TimeSinceSignal function:

    Capture

    1 user thanked author for this post.
    #48083

    Michael
    • Topics: 2
    • Replies: 4
    • Posts: 6

    Error?

    I cut and pasted the script and the last line shows as an error. The rest was all valid.  I have

     IF(r2 == 1,r1,r3)

    Is that correct? Thank you,

    #48087
    Darren
    Darren
    • Topics: 28
    • Replies: 131
    • Posts: 159

    Time Since the Signal Before Last

    To calculate the time since the signal before last use the following (note: this will return calendar days), in this case RSI crossing above 70:

    Capture2

    #48111
    Darren
    Darren
    • Topics: 28
    • Replies: 131
    • Posts: 159

    Hi Michael,

    Yes that’s correct – not sure why you are getting the error. I’ve attached a workbook that contains the scripts. Let us know how you go.

    Attachments:
    #48143

    Michael
    • Topics: 2
    • Replies: 4
    • Posts: 6

    Thank you

    Darren, the workbook is working. The script manager page is attached. I cannot understand it and maybe it is just my version of Windows creating a problem?

    Attachments:
    #48155
    Darren
    Darren
    • Topics: 28
    • Replies: 131
    • Posts: 159

    Thanks Michael. Strange – when you copied the text of the script there was a formatting issue which replaced the ‘>’ with ‘>’ in variable r2, which I think is causing the issue. What version of Windows are you using?

    If you paste to Notepad first to remove formatting, and then copy from Notepad to the Optuma script editor window does it then work?

    #48159

    Michael
    • Topics: 2
    • Replies: 4
    • Posts: 6

    that fixed it

    Thank you. It is Windows Home 10, 64-bit machine. I ran it through notepad and that fixed it. Will do that in the future. 

    #48163
    Darren
    Darren
    • Topics: 28
    • Replies: 131
    • Posts: 159

    Hmm that’s the same operating system as I’m using, so will investigate what else it could be.

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.

Pin It on Pinterest

Share This

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close