- 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.10.10
Lot value calculation off by a factor of 100 - MQL5 programming forum 2019.07.19 - 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 or 0.1 Lots maximum.
I have a problem understanding why this calculation gives back a wrong result.
I thought the tick value should be the amount a tick is worth (in the accounts currency), but instead it's 100 times more.
What is it that I don't understand? Or is it just the Broker giving back the wrong tick value? (I tried it on two different Brokers)
To understand it better I printed the relevant varibles with the following command:
The Output is:
While the calculation itself is correct, the relativeSL should be about 0.00773 to fit to the 7.773 USD shown in the moneyToRisk.
[edit: how can I move this thread to the EA section? Just realised that I'm in the general section]
And where is the lot size in your calculation ?
The calculation are correct for 1 standard lot. If ticksize is 0.00001 that gives well around 1 USD for tickvalue. So for 7.773 USD to risk, it's
a move of 0.00007773, rounded to 0.00008.
William Roeder:
Lot value calculation off by a factor of 100 - MQL5 programming forum 2019.07.19
Thank you for your fast response. I guess it's really a problem of getting the wrong tickvalue from the broker.
I actually just try to make a simple EA that automatically sets SL based on a predefined balance(or equity)-percentage for manually opened positions. So OrderLots and OrderOpenPrice are predefined and spread is irrelevant since the order is already active.
And I just have the impression that I should study the DeltaPerLot tomorrow to understand this part better. :)
And where is the lot size in your calculation ?
Oh my gosh! You're right! That's it!
A huge thank you for your observation!! You just saved my day!! :D
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I have a problem understanding why this calculation gives back a wrong result.
relativeSL = NormalizeDouble(moneyToRisk/tickvalue*ticksize, digits);
I thought the tick value should be the amount a tick is worth (in the accounts currency), but instead it's 100 times more.
What is it that I don't understand? Or is it just the Broker giving back the wrong tick value? (I tried it on two different Brokers)
To understand it better I printed the relevant varibles with the following command:
The Output is:
While the calculation itself is correct, the relativeSL should be about 0.00773 to fit to the 7.773 USD shown in the moneyToRisk.
[edit: how can I move this thread to the EA section? Just realised that I'm in the general section]