mirror of
https://github.com/raa251/Liquidity_Predator.git
synced 2026-07-06 13:42:02 +00:00
21 lines
630 B
MQL5
21 lines
630 B
MQL5
|
|
double M_CalcMaxLotMargin(ENUM_ORDER_TYPE orderType)
|
||
|
|
{
|
||
|
|
double price = (orderType == ORDER_TYPE_BUY)
|
||
|
|
? SymbolInfoDouble(_Symbol, SYMBOL_ASK)
|
||
|
|
: SymbolInfoDouble(_Symbol, SYMBOL_BID);
|
||
|
|
|
||
|
|
double marginPerLot;
|
||
|
|
|
||
|
|
if(!OrderCalcMargin(orderType, _Symbol, 1.0, price, marginPerLot))
|
||
|
|
return 0.0;
|
||
|
|
|
||
|
|
double freeMargin = AccountInfoDouble(ACCOUNT_MARGIN_FREE);
|
||
|
|
|
||
|
|
double maxLots = freeMargin / marginPerLot;
|
||
|
|
|
||
|
|
// Auf gültige Lot-Schritte runden
|
||
|
|
double lotStep = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_STEP);
|
||
|
|
maxLots = MathFloor(maxLots / lotStep) * lotStep;
|
||
|
|
|
||
|
|
return maxLots;
|
||
|
|
}
|