Margin math

I suppose the underlying reason I have been trying to use the formulas with pip values and the different lot factors is that they seem redundant in some way. Since I'm writing code here I don't want to make too much related stuff a parameter, because I'll really cause trouble if I mix them up. Of course I haven't gotten them all sorted out yet so I'm screwing up real bad doodling all this out.

I suppose it didn't help that what I was initially using when doing forex experiments was this Amibroker tutorial:

http://www.amibroker.com/kb/2006/08/09/amibroker-for-forex/

I might have to bring that up on my computer again, but I'm pretty sure the sizes its trading in the backtest aren't correct as a result of this. Funnyguy_2nd, since you are using Amibroker I wondered if you noticed anything like this.

I suppose to compromise I would take the core numbers/relationships and derive the rest from them. Things like the leverage, the price relationship, and the number of units in a lot.
 
I didn't have the settings right in AmiBroker:

Code:
Symbol	        EURUSD
Trade	        Short
Date	        7/2/2012 12:13:59 AM
Price	        1.2637
Ex. date	7/2/2012 12:23:59 AM
Ex. Price	1.26318
% chg	        -0.04%
Profit	        5143
% Profit	5.19%
Contracts	99
Position value	99000
Cum. Profit	5143
# bars	        11
Profit/bar	467.55
MAE	        -0.03%
MFE	        0.06%
Scale In/Out	0/0
I was basing off this page:
http://www.amibroker.com/kb/2006/08/09/amibroker-for-forex/

There it was claiming EURUSD was denominated in USD. So that must have been where I heard it. In the instrument's information pane, I saw a "Currency" row, which I filled in with EUR. That seems to have appropriated adjusted things.
 
leverage = 50 ;
pointvalue = 10000; // lots of 10,000 units
margindeposit = close * pointvalue / leverage;


Quote from Rocko Bonaparte:

Guys I'm just trying to figure out how the math here works. What leverage I use to fill in the blanks is not the issue.

Fine, make it 50:1

The formula for calculating a profit, without considering commissions, the spread, or what not, appears to be:

contacts * (entrance price - exit price) * 100 in a lot * margin depositor

So before with 100:1 margin with 99 EURUSD contracts, entering at 1.21800 and exiting 1.21801, I was using this formula:

99 * (1.21801 - 1.21800) * 100 * 1000

So I assume with 50:1 margin it becomes:

99 * (1.21801 - 1.21800) * 100 * 500

I'm trying to understand why 50:1 means a margin deposit of 500, instead of just 50. Is something wrong there?
 
I'll have to take some time to do this. I'm still recovering from this cold. I found I do the most horrible math after taking Mucinex so I might step back for a day or two. I did check the pastes and will run them through Amibroker when I have the concentration back to soak it in.
 
I'm a little more sane today, but it wasn't like I could smash through the scripts in Amibroker yet. What I was wondering though from inspection is if there's a way to get the bid/ask spread represented in Amibroker's backtester. I figured I'd look this up, but this thread itself, of all things, was the third result. The top two didn't seem to apply. I was thinking of taking it to their mailing list at this point.
 
Back
Top