Range Compression Indicator
Forums › ProRealTime English forum › ProBuilder support › Range Compression Indicator
- This topic has 17 replies, 5 voices, and was last updated 4 years ago by Frankkeyo.
Tagged: ADR, atr, compression, range
-
-
08/21/2019 at 2:30 PM #105199
Hi All,
I am trying to build an indicators that draws a box around a range that represents an area of consolidation. I define this as a range less that 30% of the daily ATR. I have written the below but cannot seem to get it to draw anything. The use of for loops in PRT is not something I’ve tried before so I’d really appreciate some input if anyone can help.
Thanks
123456789101112131415161718192021222324252627282930313233343536// Daily ATRATRperiod = 20// ---dTR = 0for i = 0 to ATRperioddTR=dTR+max(abs(Dhigh(i)-Dlow(i)),max(abs(Dhigh(i)-Dclose(i+1)),abs(Dlow(i)-Dclose(i+1))))next// dATRavg = dTR/ATRperiod// ATR thresholdATRt = 0.3 * avg// Donchian ChannelDonchPeriod = 50dh = HIGHEST[DonchPeriod](high)dl = LOWEST[DonchPeriod](low)DonchRange = dh - dlif DonchRange <= ATRt thenfor i = 0 to DonchPeriod doif high[i]=dh thenx2 = barindex[i]endifif low[i]=dl thenx1 = barindex[i]endifnextif ABS(x2-x1) >= DonchPeriod thenDRAWRECTANGLE(x1,dl,x2,dh)coloured(255,10,10)endifendifRETURN08/21/2019 at 11:27 PM #105243I figured it out in the end and it was much more simple than I thought. In essence I wanted to identify periods of consolidation and mark these out as ranges so that I could play breakout of these ranges. I use a Donchian channel and calculate when the range of the channel is less than a certain percentage of the daily ATR – e.g. in the example below I use 10 period Donchain and calculate when it is less than 10% of the daily ATR. I define this as a consolidation range and draw lines to mark it out.
Here is the code to draw lines on the chart.
123456789101112131415161718192021222324252627// Daily ATRATRperiod = 20// ---dTR = 0for i = 0 to ATRperioddTR=dTR+max(abs(Dhigh(i)-Dlow(i)),max(abs(Dhigh(i)-Dclose(i+1)),abs(Dlow(i)-Dclose(i+1))))next// dATRavg = dTR/ATRperiod// ATR thresholdATRt = 0.1 * avg// Donchian ChannelDonchPeriod = 10dh = HIGHEST[DonchPeriod](high)dl = LOWEST[DonchPeriod](low)DonchRange = dh - dlif DonchRange <= ATRt thenhh = dhll = dlendifreturn hh as "hh", ll as "ll"It can also be useful as an indicator on a separate panel where a line for the ATR threshold is drawn and then the Donchain range is overlaid when the range is below the ATR threshold we are in consolidation and when above in a breakout
12345678910111213141516171819202122// Daily ATRATRperiod = 20// ---dTR = 0for i = 0 to ATRperioddTR=dTR+max(abs(Dhigh(i)-Dlow(i)),max(abs(Dhigh(i)-Dclose(i+1)),abs(Dlow(i)-Dclose(i+1))))next// dATRavg = dTR/ATRperiod// ATR thresholdATRt = 0.1 * avg// Donchian ChannelDonchPeriod = 10dh = HIGHEST[DonchPeriod](high)dl = LOWEST[DonchPeriod](low)DonchRange = dh - dlRETURN DonchRange COLOURED(70,130,180) as "DR", ATRt COLOURED(255,69,0) as "ATRt"08/27/2019 at 3:31 PM #10566206/14/2020 at 10:11 PM #135932I have used the code on my platform, but I am having difficulty with the code that boxes areas of the chart. The other code that shows DR and ATRT is a little confusing for me. One chart I noticed that it shows a break in consolidation when the gap between the two is at a certain point, but that is not the same with other charts. Anyone be kind to explain the full use if the indicator?
Thanks in advance.
06/15/2020 at 2:59 PM #136002Hi Nicolas or Thally,
I can’t seem to get this code that you guys write/used to work and draw those boxes. Any help, please?
123456789101112131415161718192021222324252627// Daily ATRATRperiod = 20// ---dTR = 0for i = 0 to ATRperioddTR=dTR+max(abs(Dhigh(i)-Dlow(i)),max(abs(Dhigh(i)-Dclose(i+1)),abs(Dlow(i)-Dclose(i+1))))next// dATRavg = dTR/ATRperiod// ATR thresholdATRt = 0.1 * avg// Donchian ChannelDonchPeriod = 10dh = HIGHEST[DonchPeriod](high)dl = LOWEST[DonchPeriod](low)DonchRange = dh - dlif DonchRange <= ATRt thenhh = dhll = dlendifreturn hh as "hh", ll as "ll"06/15/2020 at 4:51 PM #13601606/16/2020 at 10:31 AM #13608906/16/2020 at 10:39 AM #13609506/16/2020 at 12:15 PM #13611406/16/2020 at 12:51 PM #13611806/24/2020 at 10:27 AM #13699306/24/2020 at 10:31 AM #13699406/24/2020 at 10:46 AM #13699906/24/2020 at 10:47 AM #13700006/24/2020 at 11:52 AM #137007Open the properties of the price chart and tick the option to scale data, on the lower side of the properties.
-
AuthorPosts
Find exclusive trading pro-tools on