• Home
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • User/Email: Password:
  • 1:00pm
Menu
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • 1:00pm
Sister Sites
  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Options

Bookmark Thread

First Page First Unread Last Page Last Post

Print Thread

Similar Threads

ADR Average daily Range Indicator 156 replies

Daily Trading Strategy [ADR + RSI = High Probability] 885 replies

New Average Daily Range (ADR) Indicator 53 replies

Average Daily Range Table (ADR) 61 replies

Sound Alert for ADR (Average Daily Range) 1 reply

  • Platform Tech
  • /
  • Reply to Thread
  • Subscribe
  • 3
Attachments: Average Daily Range (ADR) - code check
Exit Attachments

Average Daily Range (ADR) - code check

  • Post #1
  • Quote
  • First Post: Mar 17, 2009 3:33pm Mar 17, 2009 3:33pm
  •  tranquilizer
  • | Joined Nov 2007 | Status: Member | 17 Posts
hey,

can someone check the following code for calculating the ADR? it is coded that way that it skips sunday bars...

Quote
Disliked
int getADR(string s, int days)
{
int adr=0,i=0;
int tmp_days = days;

for(i=1;i<=tmp_days;i++) {

if (TimeDayOfWeek(iTime(s,PERIOD_D1,i)) < 1 || TimeDayOfWeek(iTime(s,PERIOD_D1,i)) > 5) {
tmp_days++;

} else {
adr = adr + (iHigh(s,PERIOD_D1,i)-iLow(s,PERIOD_D1,i)) / MarketInfo(s,MODE_POINT);
}

}

adr = adr/days;

return (adr);
}
thank you, cheers!
  • Post #2
  • Quote
  • Jul 24, 2009 12:56am Jul 24, 2009 12:56am
  •  apparelink
  • | Joined Jul 2009 | Status: Member | 3 Posts
Quoting tranquilizer
Disliked
hey,

can someone check the following code for calculating the ADR? it is coded that way that it skips sunday bars...

thank you, cheers!
Ignored
MarketInfo(s,MODE_POINT) will result in 0 and give you a divide-by-zero error for all non-JPY currency pairs.
  • Post #3
  • Quote
  • Jul 24, 2009 1:11am Jul 24, 2009 1:11am
  •  apparelink
  • | Joined Jul 2009 | Status: Member | 3 Posts
Quoting tranquilizer
Disliked
hey,

can someone check the following code for calculating the ADR? it is coded that way that it skips sunday bars...

thank you, cheers!
Ignored
My version of implementation is this. I had to use a custom function FindAndReplace() to detect if the symbol has a Yen component. Let me know if you need the source code. If you need to skip Sunday bars you might as well switch to another MT4 broker that do not include Sunday bars. This is because your price charts will always show Sunday bars if your broker provides Sunday bars. I know some UK-based brokers do Sunday bars, unlike US-based brokers.

http://www.apparelink.com/shared/ar_code.PNG

ADR Indicator screenshot:

http://www.apparelink.com/shared/gbp_d1_ar.gif

My test results are consistent with what you see on this site http://www.aboutcurrency.com/univers...cy_pairs.shtml
  • Post #4
  • Quote
  • Sep 25, 2009 9:27am Sep 25, 2009 9:27am
  •  pipimo88
  • | Joined Jun 2007 | Status: Member | 100 Posts
I finally found the "ADR" indi which excludes the Sunday bar in calculation. I'm trying to add a label when ADR is NOT reached.. to show, in red... "Not Reached" and when it is reached then show in green "ADR Reached" (just for simplicity here).

I have made some severe hacks to script and right now it shows "Not Reached" in red... and when it is reached it does show in green "Reached"... However, I need the red label "Not reached" to disappear and be replaced with the green label and vice versa. Right now they appear one on top of the other and stay there. Do I use the "ObjectDelete" on each? In "deinit" or under each label?

NOTE to others: This indi also had ATR (which I simply commented out as I believe ATR is not relevant in Forex) and it calculates ADR correctly. I've verified it using Excel. So... it works... it's just not very pretty.

Thank you for the help
Attached File
File Type: mq4 ADR_no_sunday_bar.mq4   5 KB | 832 downloads
  • Post #5
  • Quote
  • Sep 25, 2009 7:35pm Sep 25, 2009 7:35pm
  •  twj1usa
  • | Joined Mar 2009 | Status: Member | 137 Posts
pipimo88, try this see if it works for you. if the problem happens again then change time frame to update data. if it works I will post a cleaned up version later. it worked for me on fxdd, did not have time try on different brokers.

Tom
Attached File
File Type: mq4 ADR_no_sunday_bar.v1.mq4   6 KB | 1,286 download
  • Post #6
  • Quote
  • Sep 28, 2009 10:08am Sep 28, 2009 10:08am
  •  pipimo88
  • | Joined Jun 2007 | Status: Member | 100 Posts
Attached is the image what the indi does. Once ADR is reached... The original "Not reached" in red is still there and green "reached" appears on top of it. Same issue I had as before.

The improvement is the switching timeframes will "refresh" the indi and it WILL display correctly... until the next time the "opposite" label appears.

I've definitelly seen indis where "objects" can be flipped on and off automatically... just can't get this one to do it. Thanks for trying. Any other ideas?
Attached Image
  • Post #7
  • Quote
  • Nov 15, 2009 9:15am Nov 15, 2009 9:15am
  •  BlakJak
  • | Joined Nov 2009 | Status: Junior Member | 1 Post
Hi!

I understand that the Average Daily Range is calculated over several days where each day's range (hi - lo) is averaged.

Can someone explain to me what people mean when they say Weekly ADR or Monthly ADR or 180day ADR? How is it calculated?

e.g. Does Weekly ADR = last week's ADR of the week's 5 trading days?

I have seen many people use these terms including people talk about yearly ADR but have so far never seen a rule that defines how it should be calculated.

Any help is explaining would be well appreciated.

Cheers!
  • Post #8
  • Quote
  • Apr 29, 2020 3:35pm Apr 29, 2020 3:35pm
  •  Phylo
  • Joined Feb 2012 | Status: Member | 1,710 Posts
Above text overlap corrected - https://www.forexfactory.com/showthr...8#post12909478
Posts are not necessary intended for you
  • Post #9
  • Quote
  • Last Post: Jan 10, 2021 8:16pm Jan 10, 2021 8:16pm
  •  jacryptoking
  • | Joined Jan 2021 | Status: Junior Member | 2 Posts
Quoting pipimo88
Disliked
I finally found the "ADR" indi which excludes the Sunday bar in calculation. I'm trying to add a label when ADR is NOT reached.. to show, in red... "Not Reached" and when it is reached then show in green "ADR Reached" (just for simplicity here). I have made some severe hacks to script and right now it shows "Not Reached" in red... and when it is reached it does show in green "Reached"... However, I need the red label "Not reached" to disappear and be replaced with the green label and vice versa. Right now they appear one on top of the other and...
Ignored

Can you make this for meta trader 5?
  • Platform Tech
  • /
  • Average Daily Range (ADR) - code check
  • Reply to Thread
0 traders viewing now
Top of Page
  • Facebook
  • Twitter
About FF
  • Mission
  • Products
  • User Guide
  • Media Kit
  • Blog
  • Contact
FF Products
  • Forums
  • Trades
  • Calendar
  • News
  • Market
  • Brokers
  • Trade Explorer
FF Website
  • Homepage
  • Search
  • Members
  • Report a Bug
Follow FF
  • Facebook
  • Twitter

FF Sister Sites:

  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Forex Factory® is a brand of Fair Economy, Inc.

Terms of Service / ©2021