This moving average is a adaptable linear regression of the price controlled by a proportion of the price itself
ONCE AFR = MedianPrice
p = ROUND(y*CustomClose)/100
IF CustomClose > AFR THEN
AFR = AFR + p
ELSE
AFR = AFR - p
ENDIF
AvgAFR = AVERAGE[period](AFR)
IF CustomClose > AVGAFR THEN
DRAWPOINT(barindex, CustomClose, 1)coloured (0,0,255)
DRAWSEGMENT(barindex, high, barindex, low) coloured(0,0,255)
ELSE
DRAWPOINT(barindex, CustomClose, 1)coloured (255,0,255)
DRAWSEGMENT(barindex, high, barindex, low) coloured(255,0,255)
ENDIF
RETURN CustomCLose, AFR, AVGAFR