ADR no sunday bar

Category: Indicators By: Nicolas Created: August 20, 2018, 8:31 AM
August 20, 2018, 8:31 AM
Indicators
10 Comments

This indicator displays ADR information in the lower left side of the chart screen. It calculates the Average Daily Range with exclusion of the Sunday bar to be more accurate with the real daily range of the market.

5 text lines are displayed, from top to bottom:

  • Information about the current daily range and if it has reached or not the ADR value. If the today range is superior to the ADR, the market could have not more “space” to move further
  • the ADR value (period is in parenthesis, you can change the period in the indicator’ setting)
  • the today range in points
  • Room up: how many points up still available to reach the ADR
  • Room down: how many points down still available to reach the ADR

 

//PRC_ADR no sunday bar | indicator
//17.08.2018
//Nicolas @ www.prorealcode.com
//Sharing ProRealTime knowledge

defparam drawonlastbaronly=true
defparam calculateonlastbars=10000

//--- settings
ADRperiod = 20
RoomLimitRatio = 0.1
//--- end of settings

sum = 0
a=0

if day<>day[1] and dayofweek<>0 then
 hh=0
 ll=close*100
 daycount=daycount+1
endif
if dayofweek<>0 then
 hh=max(hh,high)
 ll=min(ll,low)
endif

sum=0
a=0
if day<>day[1] and daycount>=ADRPeriod then
 for i = 0 to barindex do
  if day[i]<>day[i+1] and dayofweek[i]<>0 then
   a = a + 1
   sum=sum+((hh[i+1]-ll[i+1])/ticksize)
  endif
  if(a=1) then
   adr1=Round(sum)
  endif
  if(a=5) then
   adr5=Round(sum/5)
  endif
  if(a=10) then
   adr10=Round(sum/10)
  endif
  if(a=20) then
   adr20=Round(sum/20)
  endif
  if a = adrperiod then
   break
  endif
 next
 adr = Round((adr1+adr5+adr10+adr20)/4.0)//round((sum/adrperiod))
endif


low0  =  dLow(0)
high0 =  dhigh(0)
t = Round((high0 - low0)/ticksize)
RmUp =  Round(adr - (close-low0)/ticksize)
RmDn =  Round(adr - (high0-close)/ticksize)
RmLmt = round(adr*RoomLimitRatio)

if(rmup<rmlmt) then
 upr=255
 upg=0
else
 upr=0
 upg=100
endif
if(rmdn<rmlmt) then
 dnr=255
 dng=0
else
 dnr=0
 dng=100
endif

drawtext("Room Up: #RmUp#",barindex,-0.4,Dialog,Bold,14) coloured(upr,upg,0)
drawtext("Room Down: #RmDn#",barindex,-0.5,Dialog,Bold,14) coloured(dnr,dng,0)
drawtext("Today= #t#",barindex,-0.3,Dialog,Bold,14) coloured(128,0,128)
drawtext("ADR(#ADRperiod#)= #adr#",barindex,-0.2,dialog,Bold,22) coloured(0,0,255)

if(rmup<0 or rmdn<0) then
 drawtext("ADR REACHED",barindex,-0.1,dialog,bold,24) coloured(0,145,0)
else
 drawtext("ADR NOT REACHED",barindex,0.1,dialog,bold,24) coloured(255,0,0)
endif

return

 

Download
Filename: PRC_ADR-no-sunday-bar.itf
Downloads: 166
Nicolas Master
I created ProRealCode because I believe in the power of shared knowledge. I spend my time coding new tools and helping members solve complex problems. If you are stuck on a code or need a fresh perspective on a strategy, I am always willing to help. Welcome to the community!
Author’s Profile

Comments

Logo Logo
Loading...