Calculate free Margin

 

hey guys,


i need your help!

how could i calculate the free margin for a trade with a given stop loss?


i want to open more than one trade and need to know how much trades i can open until i reach the maximum free margin.

i think it would depend on the Brokers Marketinfo() variables but i didnt found a good sample.


thanks a lot!

mike

 
mk77ch:

hey guys,


i need your help!

how could i calculate the free margin for a trade with a given stop loss?


i want to open more than one trade and need to know how much trades i can open until i reach the maximum free margin.

i think it would depend on the Brokers Marketinfo() variables but i didnt found a good sample.


thanks a lot!

mike

I just check free margin for actually creating the order, and therefore SL is not relevant. Something like this should do the trick for you:


if(AccountFreeMarginCheck(Symbol(),OP_BUY,dLots) <= 0)

      Print("Insufficient funds to trade");

else

  {

    proceed with your order

    ...

 
cloudbreaker:

I just check free margin for actually creating the order, and therefore SL is not relevant. Something like this should do the trick for you:


if(AccountFreeMarginCheck(Symbol(),OP_BUY,dLots) <= 0)

Print("Insufficient funds to trade");

else

{

proceed with your order

...



thats also what i tried, but this check fails and all open orders will be closed with "2009.05.28 16:02:54 2000.02.09 21:01 EA: stopped because of Stop Out"

 
mk77ch:

thats also what i tried, but this check fails and all open orders will be closed with "2009.05.28 16:02:54 2000.02.09 21:01 EA: stopped because of Stop Out"

So why do you think that you haven't enough free margin?

Apologies, you need to fully explain your EA (better still, post the code), what its meant to do, what its actually doing etc.

Reason: