Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

48
LINES

< > BotCompany Repo | #1036565 // TradingCandles

JavaX fragment (include) [tags: use-pretranspiled]

Transpiled version (11038L) is out of date.

1  
persistable sclass TradingCandles extends NotifyingList<TradingCandle> {
2  
  *() {}
3  
  *(List<TradingCandle> *list) { super(list); }
4  
  
5  
  // how high a high is (lol)
6  
  IntPair highLevel(int idx) {
7  
    ret intPair(highLeft(idx), highRight(idx));
8  
  }
9  
  
10  
  int highLeft(int idx) {
11  
    double high = get(idx).high();
12  
    for (int j = 1; j < idx; j++)
13  
      if (get(idx-j).high() > high)
14  
        ret j-1;
15  
    ret idx;
16  
  }
17  
  
18  
  int highRight(int idx) {
19  
    double high = get(idx).high();
20  
    int n = size();
21  
    for (int j = 1; j < n-idx; j++)
22  
      if (get(idx+j).high() > high)
23  
        ret j-1;
24  
    ret n-idx;
25  
  }
26  
  
27  
  // how low a low is (see highs)
28  
  IntPair lowLevel(int idx) {
29  
    ret intPair(lowLeft(idx), lowRight(idx));
30  
  }
31  
  
32  
  int lowLeft(int idx) {
33  
    double low = get(idx).low();
34  
    for (int j = 1; j < idx; j++)
35  
      if (get(idx-j).low() < low)
36  
        ret j-1;
37  
    ret idx;
38  
  }
39  
  
40  
  int lowRight(int idx) {
41  
    double low = get(idx).low();
42  
    int n = size();
43  
    for (int j = 1; j < n-idx; j++)
44  
      if (get(idx+j).low() < low)
45  
        ret j-1;
46  
    ret n-idx;
47  
  }
48  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 2 computer(s): mqqgnosmbjvj, wnsclhtenguj

No comments. add comment

Snippet ID: #1036565
Snippet name: TradingCandles
Eternal ID of this version: #1036565/7
Text MD5: 816fbe7cd1f559d643a7be96c530c7d0
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2023-03-10 23:31:25
Source code size: 1123 bytes / 48 lines
Pitched / IR pitched: No / No
Views / Downloads: 140 / 217
Version history: 6 change(s)
Referenced in: [show references]