someone help, to calculate the amount of money on certain stoploss or take profit(position size calculator)

 
anybody who knows the mechanism or the maths involved in the background that help the MT5 platform be able to indentify the amount that is going to be lost on a certain stoploss

the other way to define this is how to know the amount of money that is going to be lost on a certain stoploss

Let me be clear, lets say a buy trade is opened on EURUSD: at 1.2346 sl at 1.2234 what is the amount of money that this stoploss is worth ? 
When you hover on the sL line on the terminal it shows you exactly what you are going to lose, I want to get that value too.

I believe the calculation has to involve lotsize, the contract size, tick value, tick size and not to mention leverage but I myself could not find the right combination of calculations to give me the accurate results I want. 
 
  1. Risk depends on your initial stop loss, lot size, and the value of the symbol. It does not depend on margin and leverage. No SL means you have infinite risk. Never risk more than a small percentage of your trading funds, certainly less than 2% per trade, 6% total.

    1. 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.

    2. AccountBalance * 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.)

    3. 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.
                MODE_TICKVALUE is not reliable on non-fx instruments with many brokers - MQL4 programming forum (2017)
                Is there an universal solution for Tick value? - Currency Pairs - General - MQL5 programming forum (2018)
                Lot value calculation off by a factor of 100 - MQL5 programming forum (2019)

    4. You must normalize lots properly and check against min and max.

    5. You must also check FreeMargin to avoid stop out

    6. For MT5, see 'Money Fixed Risk' - MQL5 Code Base (2017)

    Most pairs are worth about $10 per PIP. A $5 risk with a (very small) 5 PIP SL is $5/$10/5 or 0.1 Lots maximum.

  2. Search for a GUI/Trade Assistant EA like mine (for MT4): 'Money Manager Graphic Tool' indicator by 'takycard' - Risk Management - Articles, Library comments - MQL5 programming forum - Page 6 #55 (2018) and modified for screen resolution #75 (2020.02.17)

 
Learn the maths behind trading. Leverage has NOTHING to do with risk.

It's only impacting your margin requirements.


Look for ENUM_SYMBOL_CALC_MODE


 
William Roeder #:

    thanks for the response, I am not sure if this is an automated message or not because I have seen it in several forums and I have tried your suggestions before but doesn't seem to get me to where I want especially on Indexes.

    AccountBalance * percent/100 = RISK = OrderLots * (|OrderOpenPrice - OrderStopLoss| * DeltaPerLot + CommissionPerLot) 

       double delta = m_symbol.TickValue()/m_symbol.TickSize();
       
       double Risk = Lots*(m_symbol.Ask()-(m_symbol.Ask()-SL))*delta+m_symbol.ContractSize();
       Comment("Risk ",Risk); //Returns 30 instead of 10(shown on the terminal) since the stoploss==500 

    I'm not quite sure though what do you mean by the term commisionperlot, I though that is a contract size

    Why is there NO Complete EA within the Code-Base?
    Why is there NO Complete EA within the Code-Base?
    • 2011.08.20
    • www.mql5.com
    IMO, there appears to be no Complete EA within the mql4.com's Code-base or Articles for that matter of fact...
     
    Let me try to get this straightened out.

    You have a balance. You take a certain percentage of that, which you are willing to risk per position. This is your risk amount in account currency.

    Now you go to the chart and check for an entry setup. Your strategy gives you let's say a 40 Point StopLoss.

    Now you calculate how much volume do you need to make the markets move of 40 points be equal to your risk value.

    This gives you the volume you will be using on your position.

    So you need:
    Account balance
    Risk percentage
    Stop loss in points
    Value per point in account balance (for 1.0 lots)

    Now it's simple math.

    Can you solve it?
     
    Dominik Egert #:
    Value per point in account balance (for 1.0 lots)

    You mean tick value? if yes the real puzzle is in here, I believe its not just about finding the mathematical operation(division,substitution... etc) for the values it is also about understanding why the operation is performed in that certain way,

    I appreciate the response, what is your thoughts on that?

     
    Ahh, what?!

    Where is your though process here?

    Tick value is the value in the profit currency of the underlying asset. Here Symbol.

    This needs to be "exchanged" with the quote between the profit currency and your account currency.

    The operation is performed in that certain way, because that's how currencies work.

    I don't understand your question, obviously.
     

    I figured it out after reading to several blogs on the web, so here is the thing;

    Using his account balance and the percentage amount he wants to risk, we can calculate the dollar amount risked.

    USD 5,000 x 1% (or 0.01) = USD 50

    Next, we divide the amount risked by the stop to find the value per pip.

    (USD 50)/(200 pips) = USD 0.25/pip

    Lastly, we multiply the value per pip by a known unit/pip value ratio of EUR/USD. In this case, with 10k units (or one mini lot), each pip move is worth USD 1.

    USD 0.25 per pip * [(10k units of EUR/USD)/(USD 1 per pip)] = 2,500 units of EUR/USD (This will be divided by 10K units so as to bring it to lotsize value that we want from the formula)

    Since I like dealing with points rather than pips (since I will be dealing with tick values and tick sizes later on) I changed the approach to points by dividing 

    (USD 50)/(200 points) = USD 0.25/point

    from this formula: 

    double CalculateLotsizeOnRisk(double StoplossInPoints)
     {
       double PointsValue = RiskBalance/(StoplossInPoints/tick_size);
    
       return((PointsValue*(10000/tick_value))/10000);
     }
    //+------------------------------------------------------------------+
    //|                                                                  |
    //+------------------------------------------------------------------+

    formed from here 

    USD 0.25 per pip * [(10k units of EUR/USD)/(USD 1 per pip)] = 2,500 units of EUR/USD

    I applied my mathematical knowledge on deriving the formula to obtain the stoploss which is something I initially wanted and finally I came up with this formula 

    RiskBalance = m_account.Balance()*RiskPercent/100;
    
    double CalculateStopLossOnRisk(double Lotsize)
     {
       return ((10000*RiskBalance*tick_size)/(10000*tick_value*Lotsize));
     } 
    //+------------------------------------------------------------------+
    //|                                                                  |
    //+------------------------------------------------------------------+

    The formula gives me the stoploss value based on my risk settings, and it has worked well in all pairs but still I'm open to any thoughts and suggestion on it.

    Keep in mind that the described way works if you deposit currency is not the same as the base currency of a symbol(s) you are dealing with otherwise consider reading this

    EUR 5,000 * 1% (or 0.01) = EUR 50

    Now we have to convert this to USD because the value of a currency pair is calculated by the counter currency. Let’s say the current exchange rate for 1 EUR is $1.5000 (EUR/USD = 1.5000).

    All we have to do to find the value in USD is invert the current exchange rate for EUR/USD and multiply by the amount of euros we wish to risk.

    (USD 1.5000/EUR 1.0000) * EUR 50 = approx. USD 75.00

    Next, divide your risk in USD by your stop loss in pips:

    (USD 75.00)/(200 pips) = $0.375 a pip move.

    The rest follows

     
    Omega J Msigwa #:

    I figured it out after reading to several blogs on the web, so here is the thing;

    Since I like dealing with points rather than pips (since I will be dealing with tick values and tick sizes later on) I changed the approach to points by dividing 

    from this formula: 

    formed from here 

    I applied my mathematical knowledge on deriving the formula to obtain the stoploss which is something I initially wanted and finally I came up with this formula 

    The formula gives me the stoploss value based on my risk settings, and it has worked well in all pairs but still I'm open to any thoughts and suggestion on it.

    Keep in mind that the described way works if you deposit currency is not the same as the base currency of a symbol(s) you are dealing with otherwise consider reading this

    The rest follows

    The stoploss is not something to calculate, it's a base data which should come from you trading analysis, as William wrote " You place the stop where it needs to be ".

    Then you calculate your lotsize according to your risk.

    Of course you are not forced to do it this way, but then you are not trading, you are gambling.

     
    Alain Verleyen #:

    The stoploss is not something to calculate, it's a base data which should come from you trading analysis, as William wrote " You place the stop where it needs to be ".

    Then you calculate your lotsize according to your risk.

    Of course you are not forced to do it this way, but then you are not trading, you are gambling.

    Thanks, I'm just trying to find possibilities on what risk settings can do with a stoploss

     
    One.

    There is one possible risk setting with a stop loss.

    Please share alternatives. I am curious.