someone help, to calculate the amount of money on certain stoploss or take profit(position size calculator)
- SYMBOL_TRADE_TICK_VALUE_LOSS vs SYMBOL_TRADE_TICK_VALUE_PROFIT
- Calculate risk based lotsize
- Need help with coding using history values
-
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.
-
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.
-
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.)
-
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) -
You must normalize lots properly and check against min and max.
-
You must also check FreeMargin to avoid stop out
-
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.
-
-
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)
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
- 2011.08.20
- www.mql5.com
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?
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
from this formula:
double CalculateLotsizeOnRisk(double StoplossInPoints) { double PointsValue = RiskBalance/(StoplossInPoints/tick_size); return((PointsValue*(10000/tick_value))/10000); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+
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
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
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.
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
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use