balance / equity and free margin zero until finish trade
-
Hi.
Using my MT5 release provided by my Broker, the values for balance / equity and free margin remains zero all time until the trade not finish.
For example, if I got $ 100 of profit during a succesfully closed trade I will have $ 100 available for balance / equity and free margin. And so on...
But, thinking about an EA execution, can this cause some issues to start a trade ?I dont have in my code any money mgmt block basing on my balance. Can I face some issue from this way to start a trade through an EA ?
Can my EA understand that there isn't funds to start a trade transaction ?Thanks guys !
Ricardo Pelliciari.
-
I got it. Basing on MQL5 API we have a method called "AccountFreeMargin()" that returns a double value that can be handled.
Basing on this, is it possible to declare a fixed Free Margin as a variable or something like this ?Thanks !
-
Ok, I already solved this situation. It was a pretty simple solution, for instance.
Basing on this article, we have to start an EA instance the values for "balance", "equity" and "free margin". That is the same value, thinking about an EA initialization.
( http://www.luckscout.com/leverage-margi ... x-trading/ )From this way, all that we need to do is use our "onInit()" abstract EA method and setup the variables basing on a new static double variable.
And thats it ! See ya !......
margin operations.png -
Look at the name of this block - Modify Variables. Modify... Variables. Variables, not Constants. Even it's color is blue-ish, like the color of Variables. Use Variables in it, not Constants.
Variables are global variables. Constants are the same, but they are those "input" global variables... but not exactly variables, because MQL5 is giving error messages when you try to modify them.
Again, Variables are variable, they can be modified. Constants are constant, the idea is to never modify them!
Also, connect this block with other block (for example "Pass"). If a block is not connected, it is not used at all.