OHLC HLC HL

Optuma Forums Optuma Scripting OHLC HLC HL

This topic contains 4 replies, has 3 voices, and was last updated by Avatar Liam 2 weeks, 6 days ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #54149
    Avatar
    Liam
    • Topics: 3
    • Replies: 4
    • Posts: 7

    Is there a quick way or function to get OHLC or HLC or HL instead of for example (OPEN + HIGH + LOW + CLOSE) / 4

    It would be great if I could do OHLC – OHLC (1) for example.

    Many thanks,

    #54151
    Matthew
    Matthew
    • Topics: 4
    • Replies: 172
    • Posts: 176

    Hi Liam,

    You can use a 1 period SMA to do this.  In the example of OHLC you could use:

    #54153
    Avatar
    Liam
    • Topics: 3
    • Replies: 4
    • Posts: 7

    I thought about that, many thanks,

    #54155
    Avatar
    Dean
    • Topics: 13
    • Replies: 22
    • Posts: 35

    An alternative that might be useful

    Hi Liam, while Matthew’s response makes use of Optuma’s excellent in-built functions and is the most elegant method to achieve what you want, there is a longer alternative that might be useful to you:

    Why would you care about this alternative? You might find that you need to apply a similar concept elsewhere if Optuma does not have an in-built function that you need. The shorthand bar index notation (last bar = [0] , second last bar = [1], etc.) can be extremely useful. It can also be very helpful for debugging purposes to explicitly use bar index notation at all times (e.g. OHLCAvg[0] instead of just OHLCAvg) because then there is no ambiguity on what the intent of the script is.

    Carefully note that Open, High, Low, Close use parenthesis ‘(‘, ‘)’ for their bar index notation, while variables use square brackets ‘[‘, ‘]’ for their bar index notation.

    Just some additional information and techniques to put into your scripting toolkit. 🙂

    Cheers, Dean

    #54165
    Avatar
    Liam
    • Topics: 3
    • Replies: 4
    • Posts: 7

    Many thanks Dean, I can see the use cases for both ways. Thanks for sharing.

Viewing 5 posts - 1 through 5 (of 5 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