Bar within % of MA

Optuma Forums Optuma Scripting Bar within % of MA

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #60103
    Terry
    • Topics: 1
    • Replies: 1
    • Posts: 2

    Trying to write a script to show the last bar within a certain percentage of a MA.

    Like this: [today’s close < today’s SMA(80,close) * 1.02]
    and [today’s close > today’s SMA(80,close) * 0.98]

    I don’t see an option in Optuma for multiplication, so I’ve tried to run the script like this as the results would be similar.

    MA1 = MA(BARS=78); MA2 = MA(BARS=82) ; CLOSE() < MA1 CLOSE() > MA2

    Unfortunately, I’m pulling zero results… The pain of learning scripting manager.

    #60116
    Matthew
    • Topics: 5
    • Replies: 430
    • Posts: 435

    Hi,

    The WithinRange() function allows you to find where a value is within x% of another value.  For example a Close within 2% of a Moving Average.

    The shaded green zone in the following example shows where the script triggers, when the Close is within 2% of the 80SMA (within the blue dashed lines).

    Ex6

    More information: https://help.optuma.com/kb/faq.php?id=1038

    • This reply was modified 1 year ago by Matthew.
    #60127
    Terry
    • Topics: 1
    • Replies: 1
    • Posts: 2

    Thank you! It’s always a bit difficult learning a new scripting format.

    #60129
    Darren
    • Topics: 66
    • Replies: 680
    • Posts: 746

    Hi Terry,

    Just to let you know that * should be used to multiply, so this would work as well to define the 2% band:

    For a free scripting tutorial course sign in here:

    https://learn.optuma.com/scripting-courses/

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

Pin It on Pinterest