Daily ATR Range indicator Screener/Alert

Viewing 15 posts - 1 through 15 (of 18 total)
  • Author
    Posts
  • #44372 quote
    DanT01
    Participant
    New

    Hi there,

    I am using the Daily ATR range indicator on my chart as made by Nicolas here; https://www.prorealcode.com/prorealtime-indicators/daily-atr-range-for-intraday-chart/

    I am simply looking to be able to set up a screener or alert on my platform when any currency or something in my whatchlist etc breaks above or below the ATR high/Low levels that the indicator draws on my chart.

    I have attached a picture of the indicator on my chart, the two orange lines are the indicator. I simply want to be able to screen or be alerted when price goes above or below either of the two lines.

    Thanks very much
    Dan

    DATR.jpg DATR.jpg
    #47407 quote
    DanT01
    Participant
    New

    Does anyone have any ideas how to go about this?

     

    Thank you

    #81787 quote
    DanT01
    Participant
    New

    Bump for any help with this 🙂

    #81797 quote
    robertogozzi
    Moderator
    Master

    There you go (screener not tested):

    ATRperiod = 20    //change this period as you wish
    dTR       = 0
    for i = 0 to ATRperiod
       dTR=dTR+max(abs(Dhigh(i)-Dlow(i)),max(abs(Dhigh(i)-Dclose(i+1)),abs(Dlow(i)-Dclose(i+1))))
    next
    avg      = dTR / ATRperiod
    htr      = Dlow(0)  + avg[1]
    ltr      = Dhigh(0) - avg[1]
    x = 0
    IF close > htr THEN
       x = 1
    ELSIF close < ltr THEN
       x = -1
    ENDIF
    SCREENER [x] (x AS "Signal")
    DanT01 thanked this post
    #81901 quote
    DanT01
    Participant
    New

    There you go (screener not tested):


    Thank you so much for helping with that, works great!! 🙂

    Is there a way to get the value to stay 1 or -1 once it’s been touched in the screener? As opposed to only reading 1/-1 for the duration of the time the ATR is breached? If it’s not easy to have that setting, don’t worry!

    Thanks again!

    #81921 quote
    robertogozzi
    Moderator
    Master

    Please use QUOTE only when you have to point something important out. Simply write your post in all other cases, otherwise topics will become larger and larger and difficult to read. Thank you.

    Yes, we can hold the values for some bars (you will set their number), but this will also increase the list of returned value, which might be an issue when items approach or exceed the 50/100-item limit.

    Anyway this is the code (not tested), should you need to restore a shorter life to items scanned just set the LOOKBACK value to 1:

    LookBack  = 5     //keep returned items alive for 5 bars
    ATRperiod = 20    //change this period as you wish
    dTR       = 0
    for i = 0 to ATRperiod
       dTR=dTR+max(abs(Dhigh(i)-Dlow(i)),max(abs(Dhigh(i)-Dclose(i+1)),abs(Dlow(i)-Dclose(i+1))))
    next
    avg      = dTR / ATRperiod
    htr      = Dlow(0)  + avg[1]
    ltr      = Dhigh(0) - avg[1]
    a = summation[LookBack](close > htr)
    a = (a > 0) AND (a <= LookBack)
    b = summation[LookBack](close < htr)
    b = (b > 0) AND (b <= LookBack)
    x = 0
    IF a THEN
       x = 1
    ELSIF b THEN
       x = -1
    ENDIF
    SCREENER [x] (x AS "Signal")

    should ever both A and B are true, A is returned being the first value to be checked.

    Nicolas and DanT01 thanked this post
    #81945 quote
    DanT01
    Participant
    New

    Sure, sorry about the quote, good point!

    I got a syntax error on that amendment. It says;

    “This variable is not used in the code:ltr”

    I can’t spot what it relates to. I have tried changing the ATR period but it runs the same parameters as original no matter what value you put in, so maybe that is linked?

    Sorry for all questions!

    #81946 quote
    robertogozzi
    Moderator
    Master

    My fault, please replace htr in line 12 with ltr.

    Also, should you not get good results with -1 in line 18, replace it with 2 (or whatever digit you prefer), just to keep it different from 1.

    #81949 quote
    DanT01
    Participant
    New

    ah yes, works perfectly now, thank you.

    Do you think there may be a reason that when you change the ATR value for days it makes no difference to the screening results – always brings the same whether = 20 or 100 say

    Do you have any idea why that might be?

    #81950 quote
    robertogozzi
    Moderator
    Master

    I duplicated it and modified one of it replacing 20 with 5 and returned items were completely different! I tried with 50 in place of 20 and got no results (on Currencies, 1-hour TF).

    #81951 quote
    DanT01
    Participant
    New

    ah ok, strange one. I think I have a weird bug as I am changing to currency only etc and it’s still showing me other securities as well as not changing ATR period. Maybe I need a restart!

    #81952 quote
    DanT01
    Participant
    New

    It is giving me a lot of 1/-1 signals on contracts that actually haven’t hit their ATR during the day so I don’t know why they show up, but seems to pick all others up as far as I can see so that’s not as issue, just a strange one 🙂

    #81973 quote
    Nicolas
    Keymaster
    Master

    254 bars is surely not enough to compute correctly the daily ATR with ProScreener, depending of the timeframe used..

    #112804 quote
    Fab666
    Participant
    New

    [attachment file=”112805″]

    A good idea this alert, but doesn’t seem to work for me. See attachment, display is alerted but the atr lines were never breached

    Using this code…

    LookBack = 5 //keep returned items alive for 5 bars
    ATRperiod = 20 //change this period as you wish
    dTR = 0
    for i = 0 to ATRperiod
    dTR=dTR+max(abs(Dhigh(i)-Dlow(i)),max(abs(Dhigh(i)-Dclose(i+1)),abs(Dlow(i)-Dclose(i+1))))
    next
    avg = dTR / ATRperiod
    htr = Dlow(0) + avg[1]
    ltr = Dhigh(0) – avg[1]
    a = summation[LookBack](close > htr)
    a = (a > 0) AND (a <= LookBack)
    b = summation[LookBack](close < ltr)
    b = (b > 0) AND (b <= LookBack)
    x = 0
    IF a THEN
    x = 1
    ELSIF b THEN
    x = -1
    ENDIF
    SCREENER [x] (x AS “Signal”)
    1.png 1.png
    #112810 quote
    robertogozzi
    Moderator
    Master

    >> For clarity of messages on ProRealCode’s forums, please use the “insert code PRT” button to separate the text of the code part! Thank you! <<
    🙂

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

Daily ATR Range indicator Screener/Alert


ProScreener: Market Scanners & Detection

New Reply
Author
author-avatar
DanT01 @dant01 Participant
Summary

This topic contains 17 replies,
has 4 voices, and was last updated by robertogozzi
6 years, 4 months ago.

Topic Details
Forum: ProScreener: Market Scanners & Detection
Language: English
Started: 08/22/2017
Status: Active
Attachments: 3 files
Logo Logo
Loading...