-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy patharoon.src.js
66 lines (60 loc) · 1.45 KB
/
aroon.src.js
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
function validate (periods) {
if (typeof periods !== "number") {
error("Aroon periods must be a number");
}
if (periods % 1 !== 0) {
error("Aroon periods must be an integer");
}
if (periods > 100) {
error("Aroon maximum periods is 100");
}
if (periods <= 0) {
error("Aroon periods must be greater than zero");
}
}
function getBufferSize (periods) {
return periods;
}
function getStudyAxisConfig () {
return {
min: 0,
max: 100
};
}
function onIntervalClose (periods) {
var highestHigh,
lowestLow,
highIndex,
lowIndex;
prices(periods).forEach(function (close, index) {
if (!highestHigh || close > highestHigh) {
highestHigh = close;
highIndex = periods - index - 1;
}
if (!lowestLow || close < lowestLow) {
lowestLow = close;
lowIndex = periods - index - 1;
}
});
return [{
name: "Aroon Up",
overlay: false,
value: (highIndex / (periods - 1)) * 100,
type: "line",
color: "#90ed7d",
tooltip: {
valueDecimals: 1,
valueSuffix: "%"
}
}, {
name: "Aroon Down",
overlay: false,
value: (lowIndex / (periods - 1)) * 100,
type: "line",
color: "#f15c80",
tooltip: {
valueDecimals: 1,
valueSuffix: "%"
}
}];
}