//----- Highs -----
ONCE HighCount = Undefined
ONCE HighFractal = Undefined
IF (High > High[1]) AND (High > High[2]) THEN
HighLevel = High
ENDIF
IF (High < HighLevel) THEN
HighCount = HighCount - 1
ELSIF (High >= HighLevel) THEN
HighCount = 0
ENDIF
IF HighCount = -2 THEN
HighFractal = HighLevel
ELSE
HighFractal = HighFractal
ENDIF
if high crosses over Highfractal and signal<=0 then
DRAWARROWUP(barindex, low +0.0001)coloured(0,255,0)
signal=1
endif
//----- Lows -----
ONCE LowCount = Undefined
ONCE LowFractal = Undefined
IF (Low < Low[1]) AND (Low < Low[2]) THEN
LowLevel = Low
ENDIF
IF (Low > LowLevel) THEN
LowCount = LowCount + 1
ELSIF (Low <= LowLevel) THEN
LowCount = 0
ENDIF
IF LowCount = 2 THEN
LowFractal = LowLevel
ELSE
LowFractal = LowFractal
ENDIF
if LOW crosses UNDER LOWfractal and signal>=0 then
DRAWARROWDOWN(barindex, high -0.0001)coloured(255,10,10)
signal=-1
endif
RETURN HighFractal as "High Level", LowFractal as "Low Level"