Libraryless. Click here for Pure Java version (15571L/92K).
persistable sclass StopLossJuicer extends AbstractJuicer { // How much loss we will accept // Can be positive (stop loss in profit) or negative (stop loss with actual loss) settable double stopLossLimit = -0.5; settable bool stopLossEnabled = true; // Reference threshold to calculate signal below 100% // (doesn't impact closing behavior) settable double startStopLossSignalAt; *(double *stopLossLimit) {} { onCalculatingCloseSignals(signals -> { // How close are we to our loss limit? if (stopLossEnabled && stopLossLimit > -infinity()) { var signal = new CloseSignal().createdBy(this).reason("Stop loss"); if (juiceValue <= stopLossLimit) signal.strength(100); else { double startAt = max(startStopLossSignalAt, 0); if (startAt > stopLossLimit) signal.strength(doubleRatio(startAt-juiceValue, startAt-stopLossLimit)*100); } signals.add(signal); } }); } }
Began life as a copy of #1036353
download show line numbers debug dex old transpilations
Travelled to 2 computer(s): mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1036355 |
Snippet name: | StopLossJuicer - simple juicer that closes when juice level goes below a threshold |
Eternal ID of this version: | #1036355/21 |
Text MD5: | 6751fdc784b768e95a6a89645365a3df |
Transpilation MD5: | 8211a2db8a2551f4ba3955630c556ffc |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2023-04-29 00:13:40 |
Source code size: | 1038 bytes / 31 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 190 / 361 |
Version history: | 20 change(s) |
Referenced in: | #1003674 - Standard Classes + Interfaces (LIVE continued in #1034167) #1036356 - MultiPullbackJuicer - juicer with a different relative pullback for each profit level |