-
Notifications
You must be signed in to change notification settings - Fork 2
/
Candle.java
74 lines (60 loc) · 1.51 KB
/
Candle.java
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
67
68
69
70
71
72
73
74
public class Candle {
//Properties ----------------------------------------------------------------
private double open;
private double high;
private double low;
private double close;
private int volume;
private String date;
//Constructor---------------------------------------------------------------
public Candle(double open, double high, double low, double close, int volume, String date) {
this.open = open;
this.high = high;
this.low = low;
this.close = close;
this.volume = volume;
this.date = date;
}
//Behaviors ----------------------------------------------------------------
//Modifies build in toString() method
public String toString() {
return this.open + "|" + this.high + "|" + this.low + "|" + this.close + "|" + this.volume + "|" +this.date +"\n";
}
//All of these methods get whichever candle property
public String getDate() {
return this.date;
}
public Double getHigh() {
return this.high;
}
public Double getOpen() {
return this.open;
}
public Double getLow() {
return this.low;
}
public Double getClose() {
return this.close;
}
public int getVolume() {
return this.volume;
}
//-----------------------------------------------------
//Calculates if candle is an up or down candle
public int upDown() {
if(open<close) {
return 1;
}
else {
return 0;
}
}
//Calculates # period RSI
public double RSICalc(int period) {
double RSI = 0.0;
return RSI;
}
public double percentChange() {
return (close-open)/open;
}
}