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
Good slogan, it was interesting, thanks to the author. Formulas and examples make it much faster to get into it than code implementation.
I didn't get to the author's previous articles. I will have to read them. Thanks again.
Thanks for the article.
I understand that the lot size will be strongly influenced by the series of profitable and losing trades obtained on the history and used to calculate the lot. So, it is interesting to see the results by randomly taking the outcome of the trades. I assume that the results of the pass metrics will be very different.
Thank you for the article.
I understand that the lot size will be strongly influenced by the series of profitable and losing trades obtained on the history and used to calculate the lot. So, it is interesting to see the results by randomly taking the outcome of the trades. I assume that the results of the pass metrics will be very different.
In scripts, the result of trades is generated randomly. At the same time, the script itself does not know what probability is initially set when calculating the lot. The worst thing that can happen is several consecutive losing trades, especially at the end of a series. The easiest way is to take not the whole deposit, but a percentage of it... when calculating. Let's say 5-10%, then the balance curve will be more stable - there will be no big losses, but the profits will also decrease.
In scripts, the result of trades is generated randomly. At the same time, the script itself does not know what probability is initially set when calculating the lot. The worst thing that can happen is several consecutive losing trades, especially at the end of a series. The easiest way is to take not the whole deposit, but a percentage of it... when calculating. Let's say 5-10%, then the balance curve will be more stable - there will be no big losses, but the profits will also decrease.
I am writing about the final part of the article:
Let's see together how risk can affect trading. For testing we will use a simple Expert Advisor on the intersection of two moving averages. The testing of the EA took place with the following parameters:
And, again, it is important to examine the window for calculating historical successes/failures, including how it changes. You will not take the proportion for 10 years after, say, the selection of a strategy in the strategy tester.
Well done author, bookmark the article.
That's an interesting approach. But a question arose: does moral expectation have the same physical meaning as mathematical expectation? There are two interpretations of mathematical expectation in the article - through sum (e.g. 11 ducats at the beginning of the article), and through points (in the formula p*TP - (1-p)*SL). There is no explanation about moral expectation, but judging by the basic formula - moral expectation is the sum, because it corresponds to the deposit.
Then the next question. I would like to consider, IMHO, a demanded problem, which is absent in the article. A deposit is given, a desired moral expectation is given as a fraction of the deposit (Mr = Fraction * Deposit) and a lot. For different values of the probability of winning, plot the SL/TP curves. Apparently, for probability 0.5 the task is not defined.
I have tried to do it offhand, probably with mistakes. Everywhere either strange numbers or NaNs are flying out of the region of the root definition.
Here, for example, from the side from SL to calculate TP:
Output:
That's an interesting approach. But a question arose: does moral expectation have the same physical meaning as mathematical expectation? There are two interpretations of mathematical expectation in the article - through sum (e.g. 11 ducats at the beginning of the article), and through points (in the formula p*TP - (1-p)*SL). There is no explanation about moral expectation, but judging by the basic formula - moral expectation is the sum, because it corresponds to the deposit.
Then the next question. I would like to consider, IMHO, a demanded problem, which is absent in the article. A deposit is given, a desired moral expectation is given as a fraction of the deposit (Mr = Fraction * Deposit) and a lot. For different values of the probability of winning, plot the SL/TP curves. Apparently, the problem is not defined for probability 0.5.
I have tried to do it offhand, probably with mistakes. Everywhere either strange numbers or NaNs come up - it goes beyond the area of root definition.
For example, to calculate TP from the SL side:
Output:
string const double y1 = (1 + MoralExpectationPercent) * Amount * MathPow(Amount - slp, WinProbability - 1);
WinProbability - 1 is always a negative value... and it should be strictly non-negative
this is more correct
That's an interesting approach. But a question arose: does moral expectation have the same physical meaning as mathematical expectation? There are two interpretations of mathematical expectation in the article - through sum (e.g. 11 ducats at the beginning of the article), and through points (in the formula p*TP - (1-p)*SL). There is no explanation about moral expectation, but judging by the basic formula - moral expectation is the sum, because it corresponds to the deposit.
Then the next question. I would like to consider, IMHO, a demanded problem, which is absent in the article. A deposit is given, a desired moral expectation is given as a fraction of the deposit (Mr = Fraction * Deposit) and a lot. For different values of the probability of winning, plot the SL/TP curves. Apparently, the problem is not defined for probability 0.5.
I have tried to do it offhand, probably with mistakes. Everywhere either strange numbers or NaNs come up - it goes beyond the area of root definition.
For example, to calculate TP from the SL side:
Output:
The second error is that we cannot assign any moral expectation.....
The moral expectation is always less than the mathematical expectation. They approach each other as the deposit grows. Therefore, the problem is reduced strictly to the following conditions: if the mathematical expectation is positive, get a positive moral expectation
string const double y1 = (1 + MoralExpectationPercent) * Amount * MathPow(Amount - slp, WinProbability - 1);
WinProbability - 1 is always negative... and it must be strictly non-negative
this is more correct
I seem to have followed the strict mathematical transformations - I don't see where the error is? For now, let's leave the meaning of the value itself behind brackets and just look at the formula as an abstraction.
The original one, with the substituted part of F deposit D instead of the original Mr: F * D = (D + L * TP * PV)^p * (D - L * SL *PV)^(1-p) - D
We were getting moral expectation numbers in the several tens, why can't we denote any number as % of the deposit? We can.
Next we get:
(1+F)*D = (...)^p * (...)^(1-p)
(1+F)*D / (...)^(1-p) = (...)^p
Note that 1 / x^y -> x^-y, so we can get rid of the fraction, although it is not crucial for the computer to count, but the formula without the fraction is easier to read.
(1+F)*D * (...)^(p-1) = (...)^p
[ (1+F)*D * ( D - L * SL *PV )^(p-1) ] ^ (1/p) = ( D + L * TP * PV )
I have what is in square brackets in the variable y1 in my code.
Your version of the code has an incomplete formula.
I seem to have followed strict mathematical transformations - I don't see where the error is? For now, let's leave the meaning of the value itself out of brackets and just look at the formula as an abstraction.
The original one, with the substituted part of F deposit D instead of the original Mr: F * D = (D + L * TP * PV)^p * (D - L * SL *PV)^(1-p) - D
We were getting moral expectation numbers in the several tens, why can't we denote any number as % of the deposit? We can.
Next we get:
(1+F)*D = (...)^p * (...)^(1-p)
(1+F)*D / (...)^(1-p) = (...)^p
Note that 1 / x^y -> x^-y, so you can get rid of the fraction, although it is not crucial for the computer to count, but the formula without the fraction is easier to read.
(1+F)*D * (...)^(p-1) = (...)^p
[ (1+F)*D * ( D - L * SL *PV )^(p-1) ] ^ (1/p) = ( D + L * TP * PV )
I have what is in square brackets in my code in the variable y1.
Your version of the code has an incomplete formula.
If we assign some desired moral expectation to the transaction, then we (from the property moral expectation is less than mathematical expectation) get this inequality:
p* L * TP * PV - (1-p) *L * SL *PV > F*D
i.e., instead of finding the value of TP at which the moral expectation becomes positive, we start looking for the value of TP such that the mathematical expectation becomes greater than a given value.