# DCA Calculation

% Unrealized PnL = UPNL in %\
Position Size = PS\
1st input value = A in %\
2nd input value = B in %

* DCA: \
  New position size: PS+ (B \* PS)\
  new UPNL = UPNL \* PS/ (PS+ (B \* PS)) \* 100
* Reverse DCA: \
  New position size: PS- (B \* PS)\
  % UPNL is same
* A-DCA: \
  New position size: PS\* (100 - B) + PS\* B \* (100 + UPNL)\
  new UPNL = PS\* (100 - B) \* B / (PS\* (100 - B) + PS\* B \* (100 + UPNL))

The above calculations exclude the exchange fees and the price discrepancy of market transactions at the trade execution time.\
\
Trigger conditions:\
if UPNL < 0 the condition needs to match (UPNL <= A)\
if UPNL > 0 the condition needs to match (A <= UPNL)
