This ProBuilder code snippet demonstrates how to dynamically adjust the trading lot size based on the performance of a trading strategy. The lot size increases or decreases based on the equity change, aiming to compound gains or reduce risk during drawdowns.
ONCE MyEquity = 10000
ONCE nLots = 1
IF Not OnMarket THEN
IF Strategyprofit >= (MyEquity * 1.03) THEN
MyEquity = Strategyprofit
nLots = nLots + 1
ELSIF Strategyprofit <= (MyEquity * 0.97) THEN
MyEquity = Strategyprofit
nLots = nLots - 1
nLots = max(1, nLots) //do not allow nLots to fall below 1
ENDIF
ENDIF
Explanation of the Code:
This approach helps in scaling the trading size according to performance, potentially maximizing gains during profitable periods and minimizing losses during downturns.
Check out this related content for more information:
https://www.prorealcode.com/topic/compounding-2/#post-69905
Visit Link