#### Topic: LotSize Calculation Percentage of Balance

I try to find out how we can use Lotsize calculation of x percent of Account Balance.

Here is my code

```
// Function to calculate lot size based on account balance and risk percentage
double CalculateLotSize(double risk_percentage)
{
// Get the current account balance
double account_balance = AccountInfoDouble(ACCOUNT_BALANCE);
// Define the amount of balance to risk (risk_percentage of the balance)
double risk_amount = (risk_percentage / 100.0) * account_balance;
// Get the tick value and point size for the symbol
double tick_value = SymbolInfoDouble(_Symbol, SYMBOL_TRADE_TICK_VALUE);
double tick_size = SymbolInfoDouble(_Symbol, SYMBOL_TRADE_TICK_SIZE);
// Risk per lot (pip value per lot)
double risk_per_lot = tick_value / tick_size;
// Assuming 100 pips as stop loss (modify this based on your strategy)
double stop_loss_pips = 100;
// Calculate lot size based on risk amount and stop loss
double lot_size = risk_amount / (stop_loss_pips * risk_per_lot);
// Ensure the lot size is within the broker's minimum and maximum allowed limits
double min_lot = SymbolInfoDouble(symbol, SYMBOL_VOLUME_MIN);
double max_lot = SymbolInfoDouble(symbol, SYMBOL_VOLUME_MAX);
double step_lot = SymbolInfoDouble(symbol, SYMBOL_VOLUME_STEP);
// Round the lot size to the nearest lot step
lot_size = MathMax(min_lot, MathMin(max_lot, NormalizeDouble(lot_size, int(log10(1.0/step_lot)))));
return lot_size;
}
```

The problem here is that the Lotsize Calculation depends of the stopLoss. So i ask how i can get the stoploss of the strategy which will open a trade next time. Maybe someone have idea or a better solution

```
// Calculate lot size based on risk amount and stop loss
double lot_size = risk_amount / (stop_loss_pips * risk_per_lot);
```

How can i get the stopLoss out of the signal ? someone have an idea..