Close within % of Recent 20 Day High

Optuma Forums Optuma Scripting Close within % of Recent 20 Day High

This topic contains 2 replies, has 2 voices, and was last updated by Avatar Tonia 1 week, 5 days ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #53973
    Avatar
    Tonia
    • Topics: 4
    • Replies: 4
    • Posts: 8

    Hi Guys

    I’m not the least bit script savvy, but I’ve been playing around with a script idea for a day or so and so far I can’t get any results from it. I want to identify a recent 20 day high occurring within last 10 days, then I want to identify a close occurring within the last 2 days which comes near (within 2%) of the recent 20 day high.  Here’s what I have so far, and though it does not highlight any coding errors, I can’t get it to return any results. Would love some help please.

    //Calc 20Day High in last 10 days;

    V1 = HIGH() > HIGHESTHIGH(BARS=20, BACKTYPE=Days);

    V2 = V1 and TIMESINCESIGNAL(V1)<10;

    //Close occurring within last 2 days comes within 2% of recent 20 Day High;

    V3 = CLOSE()<V1 and CLOSE()>(V1*0.98); V3 and TIMESINCESIGNAL()<2

    #53975
    Matthew
    Matthew
    • Topics: 4
    • Replies: 165
    • Posts: 169

    Hi Tonia,

    There’s a few issues with the script you’ve setup…

    On the V3 variable you set, you have the Close() being lower than V1, however V1 is a Boolean (True or False), so V1 only returns a 1 or a 0, so depending on the chart, the Close won’t be lower than that. You don’t really need this part of V3 for the script to return the result you’re after.

    V3 is also using V1 * 0.98, as per above, with V1 being a Boolean, this won’t be within 2% of the 20 day high, but of the 1 or 0.  You need to split V1 into two variables, one for the 20 day high value itself, and another where the High() > than the 20 day high.

    Also in the V3 variable you have a TimeSinceSignal() function, but it’s not referencing an event, it’s been left blank (but it’s been setup correctly in the V2 line).

    The adjusted script would look like this:

    #53979
    Avatar
    Tonia
    • Topics: 4
    • Replies: 4
    • Posts: 8

    Matthew you’ve been so helpful, thank you – that works perfectly.

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

You must be logged in to reply to this topic.

Pin It on Pinterest

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