Code : #
if (CCI[50](typicalPrice)>=0) then
magic=Low[0]-AverageTrueRange[5](close)
endif
if (CCI[50](typicalPrice)<0) then
magic=High[0]+AverageTrueRange[5](close)
endif
if (CCI[50](typicalPrice)>=0 and magic<magic[1]) then
magic=magic[1]
endif
if (CCI[50](typicalPrice)<0 and magic>magic[1]) then
magic=magic[1]
endif
return magic