feat: Implement ATR-based dynamic TP2 system and fix P&L calculation
- Add ATR-based dynamic TP2 scaling from 0.7% to 3.0% based on volatility - New config options: useAtrBasedTargets, atrMultiplierForTp2, minTp2Percent, maxTp2Percent - Enhanced settings UI with ATR controls and updated risk calculator - Fix external closure P&L calculation using unrealized P&L instead of volatile current price - Update execute and test endpoints to use calculateDynamicTp2() function - Maintain 25% runner system for capturing extended moves (4-5% targets) - Add environment variables for ATR-based configuration - Better P&L accuracy for manual position closures
This commit is contained in:
17
.env
17
.env
@@ -105,7 +105,22 @@ TAKE_PROFIT_2_PERCENT=0.7
|
||||
|
||||
# Take Profit 2 Size: What % of remaining position to close at TP2
|
||||
# Example: 100 = close all remaining position
|
||||
TAKE_PROFIT_2_SIZE_PERCENT=75
|
||||
TAKE_PROFIT_2_SIZE_PERCENT=0
|
||||
|
||||
# ATR-based dynamic targets (capture big moves like 4-5% drops)
|
||||
# Enable dynamic TP2 based on market volatility
|
||||
USE_ATR_BASED_TARGETS=true
|
||||
|
||||
# ATR multiplier for TP2 calculation (TP2 = ATR × this value)
|
||||
# Example: ATR=0.8% × 2.0 = 1.6% TP2 target
|
||||
ATR_MULTIPLIER_FOR_TP2=2.0
|
||||
|
||||
# Minimum TP2 level regardless of ATR (safety floor)
|
||||
MIN_TP2_PERCENT=0.7
|
||||
|
||||
# Maximum TP2 level cap (prevents excessive targets)
|
||||
# Example: 3.0% = 30% account gain at 10x leverage
|
||||
MAX_TP2_PERCENT=3.0
|
||||
|
||||
# Emergency Stop: Hard stop if this level is breached
|
||||
# Example: -2.0% on 10x = -20% account loss (rare but protects from flash crashes)
|
||||
|
||||
Reference in New Issue
Block a user