Formula for calculating StopLoss Level, TakeProfit Level and PL

 

Dears,

Good day to you all)


considering EURUSD for all the below.

I need to know the formula for calculating the SL and TP for Sell and Buy Trades, like what inputs to get the SL and TP levels ? (edit: i am not asking about how to choose the SL and TP levels, i want to know how to calculate the level knowing the price and amount of pips i want to win and risk)

Also, how to calculate the profit and loss if an SL or TP to be hit ? and if i would close a trade at any point ?


Thanks in advance ♥

 

I can help you with the second question:

(LotVolume * StandardLotsize * (SellPrice-BuyPrice)) / ExchangeRate

LotVolume is the size of your position in lots, StandardLotsize is the standard contract size, which is usually 100.000 in the currency markets (other examples: 100 for gold, 5000 for silver). ExchangeRate means the conversion from profit currency to account currency. If e.g. your account is in USD and you're trading the GBPJPY then you need to divide by the USDJPY exchange rate. If profit currency and account currency are the same, e.g. your account is USD and you trade AUDUSD then you don't need to correct for the exchange rate (because the exchange rate for "USDUSD" is 1.0).

I wrote SellPrice and BuyPrice instead of entry/exit price because this makes it correct for both long and short trades.

For the first question: sorry, entire books have been written about how to get out of a trade; please read some basic trading literature and find your own technique.


Chris.

 
Chris70:

I can help you with the second question:

(LotVolume * StandardLotsize * (SellPrice-BuyPrice)) / ExchangeRate

LotVolume is the size of your position in lots, StandardLotsize is the standard contract size, which is usually 100.000 in the currency markets (other examples: 100 for gold, 5000 for silver). ExchangeRate means the conversion from profit currency to account currency. If e.g. your account is in USD and you're trading the GBPJPY then you need to divide by the USDJPY exchange rate. If profit currency and account currency are the same, e.g. your account is USD and you trade AUDUSD then you don't need to correct for the exchange rate (because the exchange rate for "USDUSD" is 1.0).

I wrote SellPrice and BuyPrice instead of entry/exit price because this makes it correct for both long and short trades.

For the first question: sorry, entire books have been written about how to get out of a trade; please read some basic trading literature and find your own technique.


Chris.

Hi Chris, Thanks alot, but for the first question i am not asking about how to choose the exit. i want to know the SL and TP levels knowing that i need N pips for TP and M pips for SL. say like N = 50 and M = 20

 
  1. quantumninja:vbut for the first question i am not asking about how to choose the exit. i want to know the SL and TP levels knowing that i need N pips for TP and M pips for SL. say like N = 50 and M = 20

    The SL and TP are the exit.

    You buy at the Ask and sell at the Bid. So for buy orders you pay the spread on open. For sell orders you pay the spread on close.

    1. Your buy order's TP/SL (or Sell Stop's/Sell Limit's entry) are triggered when the Bid reaches it. Not the Ask. SL=Bid-n*pips, TP=Bid+m*pips
    2. Your sell order's TP/SL (or Buy Stop's/Buy Limit's entry) will be triggered when the Ask reaches it. To trigger at a specific Bid price, add the average spread.
                MODE_SPREAD (Paul) - MQL4 programming forum - Page 3 #25
    3. The charts show Bid prices only. Turn on the Ask line to see how big the spread is (Tools → Options (Control-O) → charts → Show ask line.)

  2. Never risk more than a small percentage of your account, certainly less than 2% per trade, 6% total.
    1. In code (MT4): Risk depends on your initial stop loss, lot size, and the value of the pair. It does not depend on margin and leverage.
      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.10.10
                  Is there an universal solution for Tick value? - Currency Pairs - General - MQL5 programming forum 2018.02.11
                  Lot value calculation off by a factor of 100 - MQL5 programming forum 2019.07.19
      4. You must normalize lots properly and check against min and max.
      5. 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 or 0.1 Lots maximum.

    2. Use a GUI/Trade Assistant EA like mine (for MT 4): 'Money Manager Graphic Tool' indicator by 'takycard' - Risk Management - Articles, Library comments - MQL5 programming forum - Page 6 #55
 


Hi Chris,

I am just wondering, about the formula for EURUSD, (LotVolume * StandardLotsize * (SellPrice-BuyPrice)) / ExchangeRate

As my account currency is USD, LotVolume is 1.0 as one lot, StandardLotSize is 100,000, SellPrice 1.11707, BuyPrice 1.11907

so i should exclude the ExchangeRate because account currency USD ? , also i think you need to take the absolute (SellPrice-BuyPrice) ?

 
quantumninja:

1. yes, correct, if you trade EURUSD and your account is USD you don't need to convert to account currency

2. no, if you take the absolute, your result can never be negative, which it needs to be to indicate a loss

for your example:

1.0 lots * 100.000 USD/lot * (sell(bid) 1.11707 - buy(ask) 1.11907) / 1.0 = -200 USD (loss)

 
Thanks alot ^_^
 
William Roeder

Hi William,

Thanks alot, but i want to confirm, the pips in the equation is 0.0001‬ ? which is 10^-4 ?

 
quantumninja: i want to confirm, the pips in the equation is 0.0001‬ ? which is 10^-4 ?

Yes, for non-JPY pairs.

Reason: