ATR% of Close Price

Optuma Forums Optuma Scripting ATR% of Close Price

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #57899
    AvatarBrad
    • Topics: 4
    • Replies: 5
    • Posts: 9

    Hi,

    I have created 2 “ATR% of Close Price” Scripts, I don’t think they are working correctly?

    ATR20  of current day is less than 15% of Closing Price –

    • ATR(BARS=30)/CLOSE() < 15/100

    ATR20 of 1 day ago is less than 15% of Closing Price –

    • ATR(BARS=30)/CLOSE() [1] < 15/100

    What changes if any are required to make them work correctly?

     

    Thanks, Brad

    #57903
    AvatarTrevor R
    • Topics: 74
    • Replies: 239
    • Posts: 313

    Hi Brad,

    I suspect your premise will nearly always be achieved.

    You are calculating the Average True Range of the movement of the Close price of a group of bars, which is always significantly smaller than the Close prices, and looking for that value to be less than 15% of a Close price.

    As a couple of  examples:

    • Sugar (SBVolSpot) at the present ATR(30) = 0.393, while the Close price in 10.37, 15% of which is 1.55.
    • SPI 200 Index (APCVolSpot) at present ATR(30) = 224.186, while the Close price in 5,539.00, 15% of which is 830.85.

    The only exception I could find was the recent extreme movement in Crude Oil which came up with this result on 30 Apr 2020: ATR(30) = 3.867, while the Close price in 18.84, 15% of which is 2.826.

    20200501 ATR vs Close

    I’d also recommend bracketing your formula to ensure the correct comparison sequence of calculation:

    (ATR(BARS=10)/CLOSE()) < (15/100)

    I’d also simplify your formula to save an unnecessary calculation::

    (ATR(BARS=10)/CLOSE()) < 0.15

    Cheers

    Trevor

    • This reply was modified 3 weeks, 6 days ago by AvatarTrevor R.
    #57915
    AvatarBrad
    • Topics: 4
    • Replies: 5
    • Posts: 9

    Hi Trevor,

    Thanks for your reply, testing and advice, I will consider it in future scripting.

    I thought I had a couple of exceptions but haven’t been able to find them again.

    Did you think the below Script was correctly written?

    ATR20 of 1 day ago is less than 15% of Closing Price –

    • ATR(BARS=30)/CLOSE() [1] < 15/100

     

    Thanks, Brad

    #57931
    MathewMathew
    • Topics: 28
    • Replies: 1,335
    • Posts: 1,363

    Hi Brad,

    Just remember to add parenthesis. It’s not always needed but my OCD programming brain always wants to remove all doubt.

    One way your script could be processed is

    ATR(Bars=30) divided by (Close()[1] < 15/100)

    Close()[1] < 15/100 will evaluate to either 1 (true) to 0 (false).

    Precedence of operators should make sure that never happens but I still like to be explicit on these things. Perhaps early tesing of scripting has scared me!

    Make your script

    (ATR(BARS=30)/CLOSE() [1]) < 15/100

    All the best

    Mathew

    #57963
    AvatarBrad
    • Topics: 4
    • Replies: 5
    • Posts: 9

    Hi Matthew,

    Thanks for your helpfull reply.

    Cheers,  Brad

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