I tried to add this functionality that for every 1000$ adds 0.01 but it continuously gives me problems, the functionality that checks lots is called in multiple parts of the code because it uses a lotstep to make a martingale so I am not understanding how to solve this problem.
Also as I’m sending it to you it doesn’t work well, it doesn’t do the martingale and only opens 0.01 per 1000
<code>double Expert::lotAdjust(string sym, double lots)
{
double value = 0;
double lotStep = SymbolInfoDouble(sym,SYMBOL_VOLUME_STEP);
double minLot = SymbolInfoDouble(sym,SYMBOL_VOLUME_MIN);
double maxLot = SymbolInfoDouble(sym,SYMBOL_VOLUME_MAX);
// Calculate the auto lot based on account balance
double accountBalance = AccountBalance();
double autoLots = (accountBalance / 1000.0) * 0.01;
// Normalize the lot size according to the step size
value = NormalizeDouble(autoLots / lotStep, 0) * lotStep;
if(value < minLot)
value = minLot;
if(value > maxLot)
value = maxLot;
return(value);
}
buyLot = lotAdjust(sym,BuyPriceMinLot * MathPow(nextLot,buys));
selLot = lotAdjust(sym,SelPriceMaxLot * MathPow(nextLot,sells));
</code>
<code>double Expert::lotAdjust(string sym, double lots)
{
double value = 0;
double lotStep = SymbolInfoDouble(sym,SYMBOL_VOLUME_STEP);
double minLot = SymbolInfoDouble(sym,SYMBOL_VOLUME_MIN);
double maxLot = SymbolInfoDouble(sym,SYMBOL_VOLUME_MAX);
// Calculate the auto lot based on account balance
double accountBalance = AccountBalance();
double autoLots = (accountBalance / 1000.0) * 0.01;
// Normalize the lot size according to the step size
value = NormalizeDouble(autoLots / lotStep, 0) * lotStep;
if(value < minLot)
value = minLot;
if(value > maxLot)
value = maxLot;
return(value);
}
buyLot = lotAdjust(sym,BuyPriceMinLot * MathPow(nextLot,buys));
selLot = lotAdjust(sym,SelPriceMaxLot * MathPow(nextLot,sells));
</code>
double Expert::lotAdjust(string sym, double lots)
{
double value = 0;
double lotStep = SymbolInfoDouble(sym,SYMBOL_VOLUME_STEP);
double minLot = SymbolInfoDouble(sym,SYMBOL_VOLUME_MIN);
double maxLot = SymbolInfoDouble(sym,SYMBOL_VOLUME_MAX);
// Calculate the auto lot based on account balance
double accountBalance = AccountBalance();
double autoLots = (accountBalance / 1000.0) * 0.01;
// Normalize the lot size according to the step size
value = NormalizeDouble(autoLots / lotStep, 0) * lotStep;
if(value < minLot)
value = minLot;
if(value > maxLot)
value = maxLot;
return(value);
}
buyLot = lotAdjust(sym,BuyPriceMinLot * MathPow(nextLot,buys));
selLot = lotAdjust(sym,SelPriceMaxLot * MathPow(nextLot,sells));