Margin math

Discussion in 'Forex' started by Rocko Bonaparte, Sep 30, 2012.

  1. 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.
     
    #21     Oct 12, 2012
  2. 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.
     
    #22     Oct 14, 2012
  3. apfx

    apfx

    leverage = 50 ;
    pointvalue = 10000; // lots of 10,000 units
    margindeposit = close * pointvalue / leverage;


     
    #23     Oct 14, 2012
  4. 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.
     
    #24     Oct 17, 2012
  5. 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.
     
    #25     Oct 17, 2012