//
defparam calculateonlastbars = 1000
if Close>( max(max(high,high[2]),max(high[1],high[2]) ))[1] then
D=Min(Min(low,low[2]),Min(low[1],low[2]))
elsif close<(Min(Min(low,low[3]),Min(low[1],low[2])))[1] then
D=Max(Max(high,high[2]),Max(high[1],high[2]))
else
D=D[1]
endif
//plot1 = 0
//plot2 = 0
rge = averagetruerange[30](close)
if (close crosses over D) then
//plot1 = 1
DRAWARROWUP(barindex,low[1]-1*rge) coloured(0,255,255,250)
DRAWTEXT(".",BarIndex,low[1]-0.3*rge,serif,bold, 15) coloured(0,255,255,255) //(H1/H4 = +7) (1 min = -1)
levelDwn=low[0]
hh=high
//else
//plot1 = 0
endif
if (close crosses under D) then
DRAWARROWDOWN(barindex,high[1]+1*rge) coloured(250,0,0,250)
DRAWTEXT(".",BarIndex,high[1]+0.5*rge,serif,bold, 15) coloured(0,0,0,255) //(H1/H4 = +7) (1 min = -1)
//plot2=-1
//else
//plot2=0
levelUP=high[0]
ll=low
endif
return D,levelUp coloured(0,0,250) STYLE(DOTTEDLINE),levelDwn coloured(250,250,0) STYLE(DOTTEDLINE),hh coloured(0,0,250) STYLE(DOTTEDLINE),ll coloured(250,250,0) STYLE(DOTTEDLINE)