Bar within % of MA

Optuma Forums Optuma Scripting Bar within % of MA

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #60103
    AvatarTerry
    • 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
    MatthewMatthew
    • Topics: 5
    • Replies: 309
    • Posts: 314

    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 3 weeks, 4 days ago by MatthewMatthew.
    #60127
    AvatarTerry
    • Topics: 1
    • Replies: 1
    • Posts: 2

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

    #60129
    DarrenDarren
    • Topics: 56
    • Replies: 478
    • Posts: 534

    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

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