Williams %R, anchoring a date in a script/formula

Optuma Forums Optuma Scripting Williams %R, anchoring a date in a script/formula

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #57705
    James
    • Topics: 16
    • Replies: 11
    • Posts: 27

    Hi, I would like to anchor the date in a Williams %R column script instead of having to manually calculate the number of days since a certain event.

    Thanks, Jamie

    • This topic was modified 2 years ago by Darren.
    #57707
    Darren
    • Topics: 70
    • Replies: 788
    • Posts: 858

    Hi Jamie,

    You can do this using a combination of BarDate, StrDate, and ValueWhen functions. User the BarDate/StrDate to specify the date, and then nest the WR() function in the ValueWhen. The following in a watchlist shows the WR% value as of March 23rd 2020, ie -97.46 for XLF:

    Capture

    #57823
    James
    • Topics: 16
    • Replies: 11
    • Posts: 27

    Hi Darren, thanks for your response. Is there a way to fix the date in WR like you can in the RIC function? Example: I want to calculate WR from 2/19/20. As of now, I have to manually count the days since 2/19 and input into WR function.   As of today it would be 47 BARS so I would use WR(BARS=47). Can I fix the BARS to a date?

    Thanks, Jamie

    #57845
    Darren
    • Topics: 70
    • Replies: 788
    • Posts: 858

    Hi Jamie,

    Ah sorry I understand now! The WR() function doesn’t have a fixed date option, but by calculating the time since a specific date we can use it in a $BARS variable within the WR() function. Use this in a Show View:

    Currently it’s been 48 trading days since Feb 19th, so the green plot matches the 48 Period WR tool. Tomorrow the green line will automatically update to 49 periods.

    Capture

    #67259
    Louis
    • Topics: 33
    • Replies: 55
    • Posts: 88

    Hi Darren,

    I am having a problem using the above script with a ROC. Please see my version of the script below. Pictures attached. I made sure the watchlist is covering a date range of more than 1 year since the fixed date is almost 2 years. How can I get this to work?

    thank you

    #67267
    Darren
    • Topics: 70
    • Replies: 788
    • Posts: 858

    Hi Louis,

    Instead of using ROC() use the CHANGE() function and that will allow you to select a fixed date to calculate from.

    #67271
    Louis
    • Topics: 33
    • Replies: 55
    • Posts: 88

    Thank you, Darren! Worked perfectly.

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.

Pin It on Pinterest