-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.php
47 lines (42 loc) · 940 Bytes
/
example.php
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
36
37
38
39
40
41
42
43
44
45
46
47
<?php
require('choppiness_index.php');
$choppiness_index = new choppiness_index();
// Sample dataset
$data = [
[
'high' => 1.09437,
'low' => 1.09017,
'close' => 1.09313,
],
[
'high' => 1.09372,
'low' => 1.08528,
'close' => 1.08632,
],
[
'high' => 1.09463,
'low' => 1.07811,
'close' => 1.08272,
],
[
'high' => 1.08388,
'low' => 1.07106,
'close' => 1.07481,
],
[
'high' => 1.07994,
'low' => 1.07115,
'close' => 1.07797,
],
];
$dataset = [];
foreach ($data as $row) {
$class = new stdClass();
$class->high = $row['high'];
$class->low = $row['low'];
$class->close = $row['close'];
$dataset[] = $class;
}
// $dataset should be ordered oldest to newest
$result = $choppiness_index->get($dataset, $period = 4);
echo 'Current Choppiness Index score: ' . $result;