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

32
LINES

< > BotCompany Repo | #1036517 // CallbackJuicer - juicer with standard callback rate (aka trailing stop), which doubles as stop loss

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

Libraryless. Click here for Pure Java version (15119L/88K).

1  
persistable sclass CallbackJuicer extends AbstractJuicer {
2  
  settableWithVar double callbackRate = 0.5;
3  
4  
  // Highest juice value seen - we start at 0
5  
  settableWithVar double crest = 0;
6  
  
7  
  *(double *callbackRate) {}
8  
  
9  
  {
10  
    onCalculatingCloseSignals(signals -> {
11  
      if (juiceValue > crest)
12  
        crest(juiceValue);
13  
        
14  
      var signal = new CloseSignal().createdBy(this).reason(formatDouble1(callbackRate) + "% Callback");
15  
      signal.strength(doubleRatio(crest-juiceValue, callbackRate)*100);
16  
      signals.add(signal);
17  
    });
18  
  }
19  
  
20  
  toString {
21  
    ret commaCombine(
22  
      shortClassName(this),
23  
      "Callback rate: " + formatDouble2(callbackRate()),
24  
      "Highest profit seen: " + formatDouble2(crest),
25  
    );
26  
  }
27  
  
28  
  void copyTransientValuesFrom(AbstractJuicer juicer) {
29  
    if (juicer cast CallbackJuicer)
30  
      crest(juicer.crest);
31  
  }
32  
}

Author comment

Began life as a copy of #1036356

download  show line numbers  debug dex  old transpilations   

Travelled to 2 computer(s): mqqgnosmbjvj, wnsclhtenguj

No comments. add comment

Snippet ID: #1036517
Snippet name: CallbackJuicer - juicer with standard callback rate (aka trailing stop), which doubles as stop loss
Eternal ID of this version: #1036517/6
Text MD5: 38047597386324c10b3dcfb6794abc2b
Transpilation MD5: 1c9961fb1bbb18dfb72fbbc5173bc929
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2023-02-21 11:30:12
Source code size: 897 bytes / 32 lines
Pitched / IR pitched: No / No
Views / Downloads: 97 / 150
Version history: 5 change(s)
Referenced in: [show references]