Distance >>
 Total : Float
 Divider : Integer
 Trends, Waves : Integer
;

/* * */

Calculate ->
Arg Distances : &List : Integer <- Distance 
    Days : Array : DayData    
    What_to_inspect : DT_*
    Days_around : Integer
    [ What_to_inspect = DT_DAY_OF_MONTH, DT_DAY_OF_WEEK ]

From_to = Days_around

Do i = From_to + 1 to Days._ - From_to
 If !Distances->>Day_of_month_or_week
    ' Day_of_month_or_week = DayFrom Days.i.Date 'YYYYMMDD' What_to_inspect then
  Distances->Day_of_month_or_week = <
                                      Total  : (Day2DayStep Days i (i + 1)), Divider : 1
                                      Trends : (LooksLikeTrend Days.i Days.(i - Days_around) Days.(i + Days_around))
                                      Waves  : (LooksLikeWave Days.i Days.(i - Days_around) Days.(i + Days_around))
                                    >
 Else
  Distances->Day_of_month_or_week.
   Total  += (Day2DayStep Days i (i + 1)); Divider ++
   Trends += (LooksLikeTrend Days.i Days.(i - Days_around) Days.(i + Days_around))
   Waves  += (LooksLikeWave Days.i Days.(i - Days_around) Days.(i + Days_around))
  ;
 ;
;

/

/* * */

Day2DayStep ->
Arg Days : Array : DayData 
    Position, Next_position : Integer 
  - Distance = 0.00 ..

Stock_split_or_no_data = 0.25

A = AveragePrice Days.Position
B = AveragePrice Days.Next_position

Distance = RelativeDistance A B
Distance = 0 [ Distance > Stock_split_or_no_data ]

/

AveragePrice ->
Arg Day : DayData

(Day.Open + Day.High + Day.Low + Day.Close) / 4

/

RelativeDistance ->
Arg A, B : Float

(Abs (B - A)) / A

/

