AO=Average[5](MedianPrice)-Average[34](MedianPrice)

if AO < 0 then

n=n+1

aoLOW = LOWest[n](AO)

elsif AO crosses OVer 0 then

$aoLOWprev[t+1]=aoLOW[1]

$aoLOWprevx[t+1]=barindex-barssince(ao=aoLOW)

t=1+t

else

n=0

endif

//(x-x1)/(x2-x1) = (y-y1)/(y2-y1)

y1 = $aoLOWprev[max(0,t-1)]

x1 = $aoLOWprevx[max(0,t-1)]

y2 = $aoLOWprev[t]

x2 = $aoLOWprevx[t]

yy = y1+(barindex-x1)*(y2-y1)/(x2-x1)

if y1 < y2 and ao[0] < yy and ao[1] > yy then

//res = 1

DRAWARROWdown(barindex, ao)COLOURED("RED")

drawsegment(x1,y1,barindex,yy)

//else

//res = 0

endif

RETURN aolow coloured("red")style(dottedline,2), ao, $aolowprev[t] coloured("blue"), 0 style(dottedline,1)