Hi!

I'm new to forex, but am a skilled programmer and intend to write an expert advisor for the Metatrader4 platform. Before that, I test my scalping algorithms in another programming language with historical data that can be downloaded from Metatrader4.

I have some questions that I so far have not been able to find any straight answers to.

Assuming a leverage of 1:100, the currency pair EUR/USD, a capital of USD 10,000. My credited balance should at first look like this:

EUR 0 | USD 1,000,000

That is, I should have a credit of USD 10,000 x 100 = USD 1,000,000 to start with.

If we then assumes an exchange rate of 1 : 1.4 and a spread of 0 to simplify it. Then I should be able to "buy" 7 lots of EUR for 7 x 100,000 x 1.4 = -980,000. And my balance should then look like:

EUR 700,000 | 20,000

So the leverage sets the limit for how much EUR I can buy, and we assumes that I only can buy whole lots, not fractions, then I have reached the limit when I've bought 7 lots of EUR. I only have USD 20,000 left.

But if we instead of buying makes the opposite and "Sell" 7 lots of EUR the balance would look...

EUR -700,000 | USD 1,980,000

Now there's theoretically no limit for selling more lots of EUR. If we sell 10 lots the balance would look like:

EUR -1,000,000 | USD 2,400,000

So, now the question. Is there any limit for how many lots that can be sold? It's easy to understand "buying", because it "eats" up your credit, and the leverage sets that limit. But what for selling lots.

Another questions is the leverage. Does the leverage credit follows the capital balance. That is, if I makes profit will my credit also increase; and if my capital drops below the initial 10,000, will then also my leverage credit drop equally?

Thanks in advance.

//Carl