Calculating Lotsize Accurately

 

Ok, I admit it, I'm a newbie to MQL4. That said I've been an IT developer for 40 years now and trading generally for as long as I can remember.

This has been asked before, I know, but unless I'm not searching this forum correctly, I've not found an adequate answer.

I trade using three different brokers and I calculate stops and lot size correctly in Forex for all three, without check which broker I'm using. Thats not the Issue.

When I trade CFDs/Commodities/Indices/Precious Metals I'm struggling. 

I'm using SymbolInfoInteger(Symbol(),SYMBOL_TRADE_CALC_MODE to differentiate the different categories of Instruments but what I'm finding, over the three brokers, the various market variables differ for the same Symbol. Brokers do differ I hear you say, but they do not correlate in the same ratio.  So a formula for 1 broker does not work for the other. I'm talking here of using the following variables.

Mode_tickvalue

ModeTicksize

Mode_Lotsize

Point

Digits

I've come to the conclusion that deriving a generic calculation for Lotsize on this basis is not feasible, unless I've missed something.

So, alternatively, what I want to do is derive a formula on the "real world" basis by checking the effect on P&L of price movements, in oder to see  what effect a "Stop Loss size" movement (in Points) has on 1 LOT. That way I can more accurately calculate what my lot size should be

My question is - How to do without relying on the above variables ?




 

Hello

why you haven't open a job and hire a programmer yet?



https://www.mql5.com/en/job/new

 
  1. Why did you post your MT4 question in the Root / MT5 General section instead of the MQL4 section, (bottom of the Root page?)
              General rules and best pratices of the Forum. - General - MQL5 programming forum

  2. SYMBOL_TRADE_CALC_MODE isn't even documented in MT4

    SYMBOL_TRADE_CALC_MODE

    Contract price calculation mode

    int


              Symbol Properties - Environment State - Standard Constants, Enumerations and Structures - MQL4 Reference

  3. Risk depends on your initial stop loss, lot size, and the value of the pair.
    • You place the stop where it needs to be - where the reason for the trade is no longer valid. E.g. trading a support bounce the stop goes below the support.
    • Account Balance * percent/100 = RISK = OrderLots * (|OrderOpenPrice - OrderStopLoss| * DeltaPerLot + CommissionPerLot) (Note OOP-OSL includes the SPREAD, and DeltaPerLot is usually around $10/pip but it takes account of the exchange rates of the pair vs. your account currency.)
    • Do NOT use TickValue by itself - DeltaPerLot and verify that MODE_TICKVALUE is returning a value in your deposit currency, as promised by the documentation, or whether it is returning a value in the instrument's base currency (EUR, in this case).
                MODE_TICKVALUE is not reliable on non-fx instruments with many brokers.
    • You must normalize lots properly and check against min and max.
    • You must also check FreeMargin to avoid stop out
    Most pairs are worth about $10 per PIP. A $5 risk with a (very small) 5 PIP SL is $5/$10/5=0.1 Lots maximum.
 
whroeder1:
  1. Why did you post your MT4 question in the Root / MT5 General section instead of the MQL4 section, (bottom of the Root page?)
              General rules and best pratices of the Forum. - General - MQL5 programming forum

  2. SYMBOL_TRADE_CALC_MODE isn't even documented in MT4

  3. Risk depends on your initial stop loss, lot size, and the value of the pair.
    • You place the stop where it needs to be - where the reason for the trade is no longer valid. E.g. trading a support bounce the stop goes below the support.
    • Account Balance * percent/100 = RISK = OrderLots * (|OrderOpenPrice - OrderStopLoss| * DeltaPerLot + CommissionPerLot) (Note OOP-OSL includes the SPREAD, and DeltaPerLot is usually around $10/pip but it takes account of the exchange rates of the pair vs. your account currency.)
    • Do NOT use TickValue by itself - DeltaPerLot and verify that MODE_TICKVALUE is returning a value in your deposit currency, as promised by the documentation, or whether it is returning a value in the instrument's base currency (EUR, in this case).
                MODE_TICKVALUE is not reliable on non-fx instruments with many brokers.
    • You must normalize lots properly and check against min and max.
    • You must also check FreeMargin to avoid stop out
    Most pairs are worth about $10 per PIP. A $5 risk with a (very small) 5 PIP SL is $5/$10/5=0.1 Lots maximum.

Thanks whroeder1,  


For each of you points

1. Newbie and, hmm, not able to move it. :-( . 

2. I'm using it in SymbolInfoInteger(Symbol(),SYMBOL_TRADE_CALC_MODE)).

3. I'm using this formula pretty much but what I'm asking about is answered in the statement "MODE_TICKVALUE is not reliable on non-fx instruments with many brokers". Have reverted to reading/writing my own file in with the values.


Thanks for your help.

BTW, any tips on better searching within this forum, so that I can just search in the relevant sections ?

Reason: