Fractals Box

Category: Indicators By: Nicolas Created: February 8, 2018, 4:24 PM
February 8, 2018, 4:24 PM
Indicators
8 Comments

This indicator represents the last levels of fractals with boxes allowing to trade the breakouts of these zones of supports and resistances.

Boxes are created on the fly at each new bar. The indicator using loops being prone to heavy calculation, I suggest you use only a relatively weak lookback period (parameter to be changed in the indicator window).

It is possible to modify the transparency of boxes using the variable “alpha”, located at 100 by default (maximum = 255).The boxes can be of different colors by adjusting the MaxPipsBox setting highlighting red boxes larger than MaxBoxPips.

The indicator has been converted from a Metatrader4 version following a request from someone in the corresponding forum.

//PRC_FractalsBox | indicator
//08.02.2017
//Nicolas @ www.prorealcode.com
//Sharing ProRealTime knowledge

defparam drawonlastbaronly=true

// --- settings 
LookBackBars = 100
MaxPipsBox = 0
MaxBoxPips = 15
alpha = 100
// --- end of settings 

//fractals
cp = 2
if high[cp] >= highest[2*cp+1](high) then
 hil = high[cp]
else
 hil=0
endif
if low[cp] <= lowest[2*cp+1](low)  then
 lol=low[cp]
else
 lol=0
endif

if barindex>LookBackBars then 
 for li28 = LookBackBars downto 0 do 
  if(hil[li28]<>0) then 
   price4=hil[li28]
  endif
  if(lol[li28]<>0) then 
   price12=lol[li28]
  endif

  if(MaxPipsBox and price4-price12>MaxBoxPips*pipsize) then 
   r=240
   g=0
   b=0
  else
   r=100
   g=100
   b=100
  endif
  drawrectangle(barindex[li28+cp],price4,barindex[li28+cp+1],price12) coloured(r,g,b,alpha)
 next
 drawrectangle(barindex[0],price4,barindex[li28+cp+1],price12) coloured(r,g,b,alpha)
endif

return

 

Download
Filename: PRC_FractalsBox.itf
Downloads: 392
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...