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

/* * */

Calculate ->
Arg Distances : &List : Integer <- Distance,
    Days : Array : DayData    

Days_around, Bound_in_array = 2

Do i = Bound_in_array + 1 to Days._ - Bound_in_array
 If !Distances->>Day_of_month 
    ' Day_of_month = DayFrom( Days.i.Date, 'YYYYMMDD', DT_DAY_OF_MONTH ) then
  Distances->Day_of_month = <
                              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.
   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

/

