????
You compare wrong things.
Just use this.
bool EnoughMargin(double volumen) { if(AccountFreeMargin()<MarketInfo(Symbol(),MODE_MARGINREQUIRED)*volumen) return(false); return(true); }
Ok eevviill
Thank you very much. My brain is no longer willing to learn new things lately it seems.
Greetings
BeLikeTrader

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
This is the part of my coding in my EAs that is giving me some headaches.
This will check if there is free margin to open the position, but seems is failing in some brokers that are using Stopoutmode==1.
This is the only part of the coding that I didnt make it, seems that checking free margin was easy and I folloed this code somewhere I dont remember. Normally works ok. But some brokers like FXCM that has a AccountStopOutLevel() of 100 are failing with any positions, because the function will return false everytime.
"int command" is the direction of the trade. 0=OP_BUY, etc...
bool EnoughMargin(int command, double volumen)
{/*
Alert("Acc. Free margin: ", AccountFreeMarginCheck(Symbol(),command, volumen));
Alert("Acc. Equity ", AccountEquity());
Alert("Acc. Stoplevel ",AccountStopoutLevel());
Alert("Esto mayor que Stop Level: ", (AccountFreeMarginCheck(Symbol(),command, volumen)/AccountEquity()) * 100);
*/
if (AccountStopoutMode() == 1)
if(AccountFreeMarginCheck(Symbol(),command, volumen) > AccountStopoutLevel())
return true;
if (AccountStopoutMode() == 0)
if (((AccountFreeMarginCheck(Symbol(),command, volumen)/AccountEquity()) * 100) > AccountStopoutLevel())
return true;
return false;
}
Can anyone to help me with this code that check if there is enough margin before opening a position? Im using this code for this EAs, so I need them to be perfect:
- BeLikewater: https://www.mql5.com/en/market/product/8294
- Sunday Decisions: https://www.mql5.com/en/market/product/9521
Greetings
BeLikewater