Maximal lot size
Results 1 to 1 of 1
 0 Attachment(s)    

Thread: Maximal lot size

  1. #1
    Junior Member
    Join Date
    May 2009

    Default Maximal lot size

    ok to refine the whole thing:

    each broker have set an AccountStopoutMode and an AccountStopoutLevel.

    my broker (IBFX) uses AccountStopoutMode 0. that means "calculation of percentage ratio between margin and equity".

    my ea does not many trades and if the ea is trading, i want to do this with the biggest possible lotSize between minimum and maximum lotSize given by my broker.

    i have a fixed stopLoss and a fixed TakeProfit on my trades.

    so now thats the point.

    if i open a trade a need to know what the maximum lotSize could be without triggering a stopout.

    i started now maybe 10 times to create a function to get this but with no success, so thats also the reason why i dont can post some code.

    i found several functions for money management and also this here:

    double calculateLotSize(int c)
    double stopLoss = ((MarketInfo(currencies[c], MODE_STOPLEVEL) + MarketInfo(currencies[c], MODE_SPREAD))*3) * MarketInfo(currencies[c], MODE_POINT);
    double takeProfit = ((MarketInfo(currencies[c], MODE_STOPLEVEL) + MarketInfo(currencies[c], MODE_SPREAD))*2) * MarketInfo(currencies[c], MODE_POINT);

    double minLot = MarketInfo(currencies[c],MODE_MINLOT);
    double maxLot = MarketInfo(currencies[c],MODE_MAXLOT);

    double OneLotMargin = MarketInfo(currencies[c],MODE_MARGINREQUIRED);
    double MarginAmount = AccountBalance()/5;
    double lotMM = MarginAmount/OneLotMargin;
    double LotStep = MarketInfo(currencies[c],MODE_LOTSTEP);
    lotMM = NormalizeDouble(lotMM/LotStep,0)*LotStep;

    if(lotMM < minLot) {
    lotMM = minLot;
    if(lotMM > maxLot) {
    lotMM = maxLot;


    but i dont think this will do it in any way.

    the approach should more be like this:

    free margin - stopModeLevel - max possible loss of my running trades = value of available margin

    value of available margin => value of available margin for my new order

    and then calculating what lotSize would be possible for this new order

    i hope this would help to know what i want...

    best regards,

    Last edited by mk77ch; 05-29-2009 at 13:55.

Similar Threads

  1. Big or small lot size trade
    By Prowd1975 in forum Trading discussion
    Replies: 3
    Last Post: 08-13-2015, 03:04
    By rizalmoham in forum MQL programming
    Replies: 0
    Last Post: 04-06-2013, 05:48
  3. MasterMind3 Balance and lot size change.
    By Big Cheese in forum Ideas for expert advisors
    Replies: 8
    Last Post: 04-15-2011, 13:43
  4. Request For New EA Size Candle
    By Marco Tess in forum Ideas for expert advisors
    Replies: 1
    Last Post: 07-29-2010, 22:28
  5. How do i add an automatic lot size changer to my EA?
    By paulme33 in forum Ideas for expert advisors
    Replies: 3
    Last Post: 01-20-2010, 20:15

Tags for this Thread

broker, level, money, spread, stoploss, trading

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Maximal lot size