PP Fractals

Category: Indicators By: Vonasi Created: December 18, 2020, 2:02 PM
December 18, 2020, 2:02 PM
Indicators
9 Comments

This indicator is called ‘PP Fractals’ as I coded it following a request from ParthaPersonal.

This indicator works on v11 onwards only.

The indicator draws lines extended forward that connect the last two fractals – however the high fractal lines must always be sloping downwards and the low fractal lines always sloping upwards. New lines are only drawn if any new fractal creates a line that meets this sloping criteria with a previous fractal.

The type of fractal can be selected by adjusting the ‘BarsBefore’ and ‘BarsAfter’ settings. So for example settings of 2 and 1 would look for fractals where there are two lower highs before a bars high and one lower high after it. The opposite using higher lows for low fractals.

On a 1 second chart for example you could use settings of 300 and 300 which would look for fractals where there has not been a higher high for 5 minutes (of 1 second bars) either side of the high.

The drawing of the resistance and support lines can be turned on or off using the ‘Resistance’ and ‘Support’ tick boxes.

Points indicating the fractal highs and lows used are drawn and these can be turned off using the ‘Points’ tick box.

As always I recommend downloading the ITF file and importing it to get full functionality.

//PP Fractals v1.2
//PRT v11
//By Vonasi
//Date: 20201217

defparam drawonlastbaronly = true
//Settings
BarsBefore = 1
BarsAfter = 1
Support = 1
Resistance = 1
Points = 1

//Make sure all settings are valid ones
BarsBefore = max(BarsBefore,1)
BarsAfter = max(BarsAfter,1)
StartBack = max(0,startback)

if barindex >= barsbefore + barsafter then

//Look for a low fractal
BarLookBack  = BarsAfter + 1
if low[BarsAfter] < lowest[BarsBefore](low)[BarLookBack] THEN
if low[BarsAfter] = lowest[BarLookBack](low) THEN
a = a + 1
$supportbar[a] = barindex[barsafter]
$supportvalue[a] = low[barsafter]
endif
endif

//Look for a high fractal
if high[BarsAfter] > highest[BarsBefore](high)[BarLookBack] THEN
if high[BarsAfter] = highest[BarLookBack](high) THEN
b = b + 1
$resistancebar[b] = barindex[barsafter]
$resistancevalue[b] = high[barsafter]
endif
endif

if islastbarupdate then
//support line
if a >= 2 then
if support then
flag = 0
zz = 0
for z = a-zz downto 1
for xx = 1 to a
if z-xx < 1 then
break
endif
if $supportvalue[z] > $supportvalue[z-xx] then
drawray($supportbar[z-xx],$supportvalue[z-xx],$supportbar[z],$supportvalue[z]) coloured(128,0,0)
if points then
drawpoint($supportbar[z],$supportvalue[z],2) coloured(128,0,0)
drawpoint($supportbar[z-xx],$supportvalue[z-xx],2) coloured(128,0,0)
endif
flag = 1
break
endif
zz = zz + 1
next
if flag = 1 then
break
endif
zz = 0
next
endif
endif

//resistance line
if b >= 2 then
if resistance then
flag = 0
zz = 0
for z = b-zz downto 1
for xx = 1 to b
if z-xx < 1 then
break
endif
if $resistancevalue[z] < $resistancevalue[z-xx] then
drawray($resistancebar[z-xx],$resistancevalue[z-xx],$resistancebar[z],$resistancevalue[z]) coloured(0,128,0)
if points then
drawpoint($resistancebar[z],$resistancevalue[z],2) coloured(0,128,0)
drawpoint($resistancebar[z-xx],$resistancevalue[z-xx],2) coloured(0,128,0)
endif
flag = 1
break
endif
zz = zz + 1
next
if flag = 1 then
break
endif
zz = 0
next
endif
endif

endif
endif


return

Download
Filename: Screenshot_2.png
Downloads: 215
Download
Filename: PP-Fractal-Lines-v1.2-1.itf
Downloads: 726
Vonasi Master
V-oyaging ON A S-mall I-ncome
Author’s Profile

Comments

Logo Logo
Loading...