Lot size calculation - Page 2
Page 2 of 843 FirstFirst 123 LastLast
Results 11 to 20 of 28

Thread: Lot size calculation

  1. #11
    I love to go into a market using the: Top [1] 1 pip as my buy stop and the Low Cost [1] - 3 pips as my stop loss.

    So I've my StopLoss in pips.


    Any Ideas on how to properly apply this to the code I have been workin on it and have not been able to acquire the suitable

    result.


    Thankyou for any help.

  2. #12
    StopLoss = ( (High[1] Point) - (Low[1]-(3*Point) ) ) / Stage;

    Place this snip of code only at the start of the start purpose. Only after start and the { for the purpose.

  3. #13
    I've added a code, but will be getting the lot size amounts that are too significant.


    Example: GBP/USD lots Ought to Be 0.0219 lots

    The code returns 2.19 lots


    when running the amounts on a spread sheet, the result is.0219 lots

    In metaquotes the outcome is 2.19 lots


    This is the code that I have so far, do you see what I did incorrectly??




    Int start()

    //--
    double PercentToRisk =.25;
    double Risk = PercentToRisk/100;
    //

    double StopLoss = ( (High[1] (5*Point)) - (Low[1]-(3*Point) ) ) / Point;

    double Lots = NormalizeDouble(AccountBalance()*Risk/StopLoss/(MarketInfo(Symbol(), MODE_TICKVALUE)),2);

    //The algorithm is Lots = AccountBalance or Equity * Percent To Risk / Stoploss in pips / Pipvalue

    MessageBox(Lots= (Lots));
    MessageBox(Risk= should be (Risk)); //does not seem to be correct
    MessageBox(StopLoss or H minus L (StopLoss)); //is correct
    //--
    return(0);

    // ------------------------------------------------------------------
    https://www.forexforum.co.za/attachm...1030250991.mq4

  4. #14
    What's the proportion of risk you are trying to use? Is it 25% or is it?

    You have 0.25 and you then take that value and divide by 100, which makes it 0.0025.

    My formulation says if you are trying to use 25%, then which will be

    AccountBalance * 0.25 / Stoploss in pips / pip value.

    Example
    Balance = 10,000
    Risk = 5%
    Stoploss = 50 pips
    Pipvalue = $10 per pip

    So

    $10,000 * 0.05 = 500
    next 500 / 50 = 10
    next 10 / 10 = 0.10 lots

    So that is it? 0.25% or 25% among the calcs you have is wrong.

    Could record the account balance and the High and low which are part of the clac, so we can see what it is you are trying to do this?

    Also, please note that the calc would differ if you are using a micro or mini account about the MT4 and then calculating a standard account on glow.

    To learn, creat a message box of the marketinfo component that gets the pipvlaue computed.

    2.19 micro lots = 0.0219 standard lots

    A standard pipvalue of GBPUSD = 10.00
    A miniature = $ 1.00
    a micro = $ 0.10
    https://www.forexforum.co.za/attachm...1246886842.mq4

  5. #15
    Thank you for you help

    The proportion of risk I am trying to work with is 1/4 of 1 percentage, my egy gets me in a little at a time and builds a position, I have discovered this works well with my setup and entry.


    My account size is roughly 1,000 USD as a micro, I added 1000.00 into the code for testing rather than AccounBalance()

    Risk of 1/4 of 1 percent should be 2.50 USD

    The numbers of the high and low I am using to test the outcome are out of GBP/USD Daily

    Chart High of 1.9500 5 pips and reduced for 1.9403 - 3 pips

    I am thinking from the data in your reply that I want to account for the fact that I am investing in a mini account in the code.


    Thankyou again.

  6. #16
    Try 0.01 lot dimensions for a 1000$ account along with a 30 pip stop loss

  7. #17
    Can we all have a excellent trading week.

    This is the code I have so far for use one a mini account if anyone needs it, I'm working on inserting the code for the spread.

    Love.

    I look forward to the day I will give more backagain.




    Corrected mistake added Lots, rather than buy cease in ordrsend
    https://www.forexforum.co.za/attachm...3499621899.mq4

  8. #18
    I am certain that persistence will pay off.

    The formula for the lot size does return the right amount to the message box, however it will not execute.

    Once I pass the lot size to the ship pending function it does something funky to it so the order isn't accepted.

    I have been working on isolating the issue and have found that if I enter
    NormalizedDouble(.38,2) into the ship pending function it transforms it to 38 contracts in my demo account which is set a benchmark.

    Any inpute could be useful.

    Thankyou for your own for the encouragement spread code tip.


    Thanx, Well get there

  9. #19
    The above code works well for USD pairs, but doesn't appear to work for cross pairs.
    2008.05.18 23:28:06 2006.11.01 04:00 BurstEA3 GBPJPY,H4: invalid lots quantity for OrderSend function

    Lottery = NormalizeDouble(AccountBalance()*(RiskPercent/100)/StopLoss/(MarketInfo(Symbol(), MODE_TICKVALUE)),2);

  10. #20
    Thankyou

    I have a Direct from First book on Metaquotes forum, to use

    MarketInfo() MODE_LOTSTEP to the code.


    Your article leads me to believe I'm on the right track.


    As I reasearch it seems I'm not the only one to attempt to code this.


    It'd be nice to have it solved for everybody.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
This website uses cookies
We use cookies to store session information to facilitate remembering your login information, to allow you to save website preferences, to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners.