Download MetaTrader 5

How can the maximum volume be calculated?

To add comments, please log in or register
Have you installed MetaTrader 5? Find out more about it!
Armand
48
Armand 2012.02.07 15:00 

I have a problem. When I run my EA, it does a couple of trades, and increases the volume each time a new position is opened, until it reaches a point where the volume becomes invalid(Maybe too much). What have I done wrong?


Here's the error message:

2010.06.11 15:00:20 failed instant sell 1.22877K EURUSD at 1.20895 sl: 1.22895 [Invalid Volume].


Here is how everything was before the trade attempt:

Leverage.................................................1:500

Free Margin.............................................2337014.33

Margin.....................................................101353.0

Equity(Margin + Free Margin).................2438367.33

Balance...................................................2463527.73

Bid Price.................................................1.20895

Attempted Volume..................................1228.77


What is wrong with the volume?

If the volume is too much, how do I calculate the maximum volume?


Another question

      If there are no open positions, will the Balance be equal to the Equity and Free Margin?

      Balance=Equity=Free Margin?


Any help would be greatly appreciated.

Biantoro Kunarto
14896
Biantoro Kunarto 2012.02.09 06:20  

Another question

      If there are no open positions, will the Balance be equal to the Equity and Free Margin?

      Balance=Equity=Free Margin?


Any help would be greatly appreciated.

right..if you dont have position, the balance=equity=freemargin.
Biantoro Kunarto
14896
Biantoro Kunarto 2012.02.09 06:28  
Armand:

I have a problem. When I run my EA, it does a couple of trades, and increases the volume each time a new position is opened, until it reaches a point where the volume becomes invalid(Maybe too much). What have I done wrong?


Here's the error message:

2010.06.11 15:00:20 failed instant sell 1.22877K EURUSD at 1.20895 sl: 1.22895 [Invalid Volume].


Here is how everything was before the trade attempt:

Leverage.................................................1:500

Free Margin.............................................2337014.33

Margin.....................................................101353.0

Equity(Margin + Free Margin).................2438367.33

Balance...................................................2463527.73

Bid Price.................................................1.20895

Attempted Volume..................................1228.77


What is wrong with the volume?

If the volume is too much, how do I calculate the maximum volume?


I dont know about this volume, but as far as I know if you want to open position with this condition, margin for volume 1228.77 should be 297104.3.

Margin = 1.20895 x 100000 *1228.77 / 500

           = 297104.3

I think this margin is enough to open position.


Armand
48
Armand 2012.02.09 20:13  
biantoro:

I dont know about this volume, but as far as I know if you want to open position with this condition, margin for volume 1228.77 should be 297104.3.

Margin = 1.20895 x 100000 *1228.77 / 500

           = 297104.3

I think this margin is enough to open position.


Ok thank you, that helped me very much. So this new value that has been calculated, will be subtracted from the free margin?
Biantoro Kunarto
14896
Biantoro Kunarto 2012.02.10 03:52  
Armand:
Ok thank you, that helped me very much. So this new value that has been calculated, will be subtracted from the free margin?
The free margin will be subtracted with new margin , and the margin will be added with new margin. Btw I still dont know about your invalid volume problem, do you already solve the problem? thank you.
Armand
48
Armand 2012.02.10 14:39  

I have not yet solved the problem, but now I know exactly how the margin, free margin equity and leverage is linked together. It looks like I've had an open position before I have made the trade request, but even if I subtract the new margin from the free margin, I would still have lots of free margin left. So the volume is not too big. So there must be something else wrong with the volume.

Is there a limit in how much volume one can buy?


For now I will still look for the error, and If I find it I will let you know too.

Thanks for the help.

Biantoro Kunarto
14896
Biantoro Kunarto 2012.02.11 01:47  
Armand:

I have not yet solved the problem, but now I know exactly how the margin, free margin equity and leverage is linked together. It looks like I've had an open position before I have made the trade request, but even if I subtract the new margin from the free margin, I would still have lots of free margin left. So the volume is not too big. So there must be something else wrong with the volume.

Is there a limit in how much volume one can buy?


For now I will still look for the error, and If I find it I will let you know too.

Thanks for the help.

You can use SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_MAX) to know maximal volume for a deal

and SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_LIMIT) to know maximum allowed total volume of the open position and pending orders (regardless of direction) for one symbol



  
Documentation on MQL5: Standard Constants, Enumerations and Structures / Environment State / Symbol Properties
  • www.mql5.com
Standard Constants, Enumerations and Structures / Environment State / Symbol Properties - Documentation on MQL5
Armand
48
Armand 2012.02.12 21:01  
biantoro:

You can use SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_MAX) to know maximal volume for a deal

and SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_LIMIT) to know maximum allowed total volume of the open position and pending orders (regardless of direction) for one symbol



  

Hey I have found the problem! The margin exceeds the leverage limitations. I only need to find the margin requirements that matches this example.

Check out this link:

http://alpari-forex.com/en/trader/margin_requirements/#1

Biantoro Kunarto
14896
Biantoro Kunarto 2012.02.13 01:54  
Armand:

Hey I have found the problem! The margin exceeds the leverage limitations. I only need to find the margin requirements that matches this example.

Check out this link:

http://alpari-forex.com/en/trader/margin_requirements/#1

ok..
To add comments, please log in or register