How can I get the Free Balance while a pisition is open?

 

Hi guys, i`m developing an EA and I need to know how much money I have available to open more positions.

The idea is, if I have already  a position open, I would like to know how much money do I have left to buy other stocks.

I`m using, inside OnTick the AccountInfoDouble() method.

While the first position is open, ACCOUNT_BALANCE shows the initial balance, meanwhile ACCOUNT_EQUITY and ACCOUNT_MARGIN_FREE shows the value of ACCOUNT_BALANCE  plus the current profit/loss.

I would like to know how much money I have free (ACCOUNT_BALANCE minus the money I used to open the first position).

Someone know how can I obtain this information?

 
Thiago Tenório: ACCOUNT_BALANCE minus the money I used to open the first position.
You didn't use any money to open the first position. You used some Free Margin.
 
William Roeder:
You didn't use any money to open the first position. You used some Free Margin.
Even if my leverage is 1:1 and I`m buyng stocks? Is there any option to disable it? Or to set that I want to use the money I set in the Balance config?
 
you might want to refer to this and to understand some basic important trading terms

https://www.babypips.com/learn/forex/what-is-free-margin

 
Soewono Effendi:
you might want to refer to this and to understand some basic important trading terms

https://www.babypips.com/learn/forex/what-is-free-margin

Thanks for this post! It was very clarifying. But I think I misspoke. I need the free margin.

The problem is that after I buy something (on the backtest) using less then money set in "Deposit" the value of AccountInfoDouble(ACCOUNT_MARGIN_FREE) is still the same value of AccountInfoDouble(ACCOUNT_BALANCE).

Shouldn`t it be the value of Balance - Required Margin (like your post said)?

Only after the position is closed the AccountInfoDouble(ACCOUNT_MARGIN_FREE) value changes.