-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSwingpoint.fs
35 lines (29 loc) · 1.12 KB
/
Swingpoint.fs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
module GeldMachine.Indicator.Swingpoint
open Deedle
open System
open GeldMachine.Data
type Swingpoint =
| SPH
| SPL
let private getSPs (data:OHLC list) (property:OHLC -> decimal) (compare:decimal -> decimal ->bool) =
match data with
| h :: t ->
let mutable potentialSwingPoint = h
let mutable successive = 0
let mutable sps = []
for row in data do
if(compare (property row) (property potentialSwingPoint)) then
successive <- successive + 1
if(successive >= 6) then
sps <- potentialSwingPoint :: sps
potentialSwingPoint <- row
successive <- 0
else
potentialSwingPoint <- row
successive <- 0
sps
| _ -> []
let getSPLs (data:OHLC list) = getSPs data (fun row -> row.Low) (fun current best -> current > best)
let getSPHs (data:OHLC list) = getSPs data (fun row -> row.High) (fun current best -> current < best)
let getSPLs' (data:Frame<string,string>) = data?SPL <- []
let getSPHs' (data:Frame<string,string>) = data?SPH <- []