Optuma Forums Optuma Scripting VALUEWHEN of an OFFSET

  • This topic has 2 replies, 2 voices, and was last updated 9 months ago by Kim.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • #60609
    • Topics: 16
    • Replies: 19
    • Posts: 35


    I’m trying to determine the price of 2 signals, but can’t get VALUEWHEN to return the earlier signal. I’ve indicated in the code what isn’t working.
    In the attached screenshot:

    • The green arrows are entry signals
    • The red arrow is an exit signal
    • The hover shows the price of the earliest entry signal
    • The column “Signal” shows the value of Entry2 in the code below; it’s the value of the latest entry signal

    Is this something that just isn’t possible as VALUEWHEN doesn’t have an OFFSET facility?



    PS This is related to an enhancement suggestion that Mathew said he’d look at, I’m just impatient!! 🙂

    Back Test Results

    • Topics: 66
    • Replies: 633
    • Posts: 699

    Hi Kim,

    Offsets are used with bar values not signals, so an offset of 1 will get the value of the bar before the signal, not the previous signal.

    Here’s a work around using the NonZero function, where variable P2 gets the bardate of the previous signal, and EntryPrice2 get the close value on that bardate i.e. $12.42 in the case of AERI:


    2 users thanked author for this post.
    • Topics: 16
    • Replies: 19
    • Posts: 35

    Hi again, an FYI.

    The script works perfectly on a chart, but the back tester always sees the latest signal as of today rather than the latest signal as of the point in time being back tested. Oh well, looks like I’ll have to wait for the new back tester.

    Thanks again


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

Pin It on Pinterest