Libraryless. Click here for Pure Java version (15119L/88K).
persistable sclass CallbackJuicer extends AbstractJuicer { settableWithVar double callbackRate = 0.5; // Highest juice value seen - we start at 0 settableWithVar double crest = 0; *(double *callbackRate) {} { onCalculatingCloseSignals(signals -> { if (juiceValue > crest) crest(juiceValue); var signal = new CloseSignal().createdBy(this).reason(formatDouble1(callbackRate) + "% Callback"); signal.strength(doubleRatio(crest-juiceValue, callbackRate)*100); signals.add(signal); }); } toString { ret commaCombine( shortClassName(this), "Callback rate: " + formatDouble2(callbackRate()), "Highest profit seen: " + formatDouble2(crest), ); } void copyTransientValuesFrom(AbstractJuicer juicer) { if (juicer cast CallbackJuicer) crest(juicer.crest); } }
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: | 164 / 237 |
Version history: | 5 change(s) |
Referenced in: | [show references] |