You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Therefore lSL is how many points to SL
Point = 0.00001 (on 5-digit quotes)
dLotStep = 0.01
The formula (lSL*dLotCost*dLotStep))*dLotStep is wrong
It should be something like ( lSL*dLotCost*Point))*dLotStep
You don't have to make anything up. The lot size is different for each brokerage company and you have to adjust it to the right size. Points have nothing to do with it
You don't have to invent anything. The lot size is different in each brokerage company and we have to bring it to the right size. The points have nothing to do with it.
In our case, lSL is the drawdown size in points of quotes but not in points of the lot.I.e. points have nothing to do with it.
So, in the calculation formula we should multiply (what is in brackets) by Point, not by dLotStep.
Another thing is that this is already done at the expense of dLotCost (along with conversion to deposit currency)...
I.e. we're first in the
Get an integer and then recalculate back to the correct units of the lot by multiplying by dLotStep ?
There is also an option with a deposit of 3 quid to trade EURUSD and put 30% on the losing side... but this is out of a series of perversions
In terms of the problem lSL is the size of the drawdown in points of quotes, not in points of the lot.I.e. points have nothing to do with it.
So, in the calculation formula we should multiply (what is in brackets) by Point, not by dLotStep.
Another thing is that this is already done at the expense of dLotCost (along with conversion to deposit currency)...
I.e. we first in
get an integer, and then recalculate back to the correct units of the lot by multiplying by dLotStep ?
Yes
The formula is still wrong (for a block of iSL>0).
TICKVALUE gives the price for TICKSIZE.
And lSL is given in POINT points.
POINT does not always coincide with TICKSIZE (see 3-digit pair XAUUSD at Alpari).
So you must convert lSL from POINT to TICKSIZE.
Otherwise, we will obtain a 10 times overestimated lot (that's what I observed on the XAUUSD pair until I added recalculation).
if (lSL>0){
lSL= (int)(MarketInfo(lSymbol,MODE_TICKSIZE) / MarketInfo(lSymbol,MODE_POINT) )* lSL; // TICKSIZE/POINT will give an integer (1 or 10), we can use int type lSL
// here is what it was.
PS: for TC optimized for many passes (>10mln) all unchangeable parameters of symbol(TICKSIZE, POINT, TICKVALUE, LOTSTEP, MINLOT, MAXLOT etc.) should be assigned to variables in functioninit() and use these variables in calculations.
Including putting value of TickSize/Point into a variable.
The formula is still wrong (for a block of iSL>0).
TICKVALUE gives the price for TICKSIZE.
And lSL is given in POINT points.
POINT does not always coincide with TICKSIZE (see 3-digit pair XAUUSD at Alpari).
So you must convert lSL from POINT to TICKSIZE.
Otherwise, we will obtain a 10 times overestimated lot (that's what I observed on the XAUUSD pair until I added recalculation).
if (lSL>0){
lSL= (int)(MarketInfo(lSymbol,MODE_TICKSIZE) / MarketInfo(lSymbol,MODE_POINT) )* lSL; // TICKSIZE/POINT will give an integer (1 or 10), we can use int type lSL
// here is what it was.
PS: for TS which optimize many passes (>10mln) all unchangeable parameters of symbol(TICKSIZE, POINT, TICKVALUE, LOTSTEP, MINLOT, MAXLOT etc.) must be assigned to variables in functioninit() and use variables in calculations.
Including putting value of TickSize/Point into a variable.
Thank you
Thanks
The topicstarter sent his respects on the first page and never came back.
A few years ago this issue was discussed on a forum somewhere. I will retell it from memory, but without formulas.
Suppose we trade the AUDCHF pair. It was taken quite arbitrarily in order to explain how profit or loss is formed on a position. Approximately the same topic was brought up at https://www.mql5.com/ru/forum/150912
If we trade a single lot of 100000 AUD, then ( on a five digits) every pip makes 1 CHF (pair denominator) profit or loss (it depends on which way we have gone and where the price is going).
Accordingly, at any given time, we know how much CHF we have gained/lost. The gain/loss is converted to the currency of the deposit, using the USDCHF exchange rate at the moment, if the deposit currency is USD, or EURCHF, if the deposit currency is EUR. By analogy, for all pairs and deposit currencies.
This is the answer: we cannot always estimate the exact right lot size. MarketInfo() with request parameter MODE_TICKVALUE can be a guide.
Hence the answer: we cannot always estimate the exact right lot size. MarketInfo() with MODE_TICKVALUE request parameter can be a guide.
That's how it's been accounted for a long time. At least in Vinin's nice post (with wrong lot calculation for mismatched TICKSIZE c POINT) and Martingeil's old post (with correct lot calculation, but no possibility to set drawdown ==0).
The main thing is that the correct value of TICKVALUE should arrive from the brokerage company (or calculated correctly on the client, if it is calculated in MT).
When this theme started, there was no TICKVALUE .
And with its advent, everything got simplified and this topic languished for a while.
PS: soon I will post my version - a hybrid of Vinin's version (it has simpler formula and iSL==0) and Martingeil's (control of insufficient funds even for min. lot).
Features: 1) calculation of balance from AccountFreeMargin(), not from AccountBalance().
2) And (for shifters) it is taken into account that the balance will decrease by a certain amount when an open trade closes on SL.
If there is not enough money even for min. balance - it will show lot volume -134 (error 134 - not enough money to open a trade)
In this regard, the question to Vinin (and other experienced comrades): is this code colored by itself or you do it yourself? I tried setting the snippet style "code", but it didn't colour it. Or is it only coloured after submitting the post?
A question for Vinin (and other experienced comrades): does the code colour itself, or do you colour it yourself? I tried to set the snippet style "code", but it's not coloured. Or is it only coloured after submitting the post?
finalised my idea (for platforms with stop-out percentage)... sharing the code... constructive criticism accepted