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.

persistable sclass TradingCandles extends NotifyingList<TradingCandle> {
  *() {}
  *(List<TradingCandle> *list) { super(list); }
  
  // how high a high is (lol)
  IntPair highLevel(int idx) {
    ret intPair(highLeft(idx), highRight(idx));
  }
  
  int highLeft(int idx) {
    double high = get(idx).high();
    for (int j = 1; j < idx; j++)
      if (get(idx-j).high() > high)
        ret j-1;
    ret idx;
  }
  
  int highRight(int idx) {
    double high = get(idx).high();
    int n = size();
    for (int j = 1; j < n-idx; j++)
      if (get(idx+j).high() > high)
        ret j-1;
    ret n-idx;
  }
  
  // how low a low is (see highs)
  IntPair lowLevel(int idx) {
    ret intPair(lowLeft(idx), lowRight(idx));
  }
  
  int lowLeft(int idx) {
    double low = get(idx).low();
    for (int j = 1; j < idx; j++)
      if (get(idx-j).low() < low)
        ret j-1;
    ret idx;
  }
  
  int lowRight(int idx) {
    double low = get(idx).low();
    int n = size();
    for (int j = 1; j < n-idx; j++)
      if (get(idx+j).low() < low)
        ret j-1;
    ret n-idx;
  }
}

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: 139 / 216
Version history: 6 change(s)
Referenced in: [show references]