Errors, bugs, questions - page 2319

 
Hello! Can you tell me how to fix an error with incorrect price display? It's throwing off all the indiators.eurusd
 
Slava:

Symbol settings, not graphics.

In market overview, select "symbol specification" from the symbol context menu

 
Igor Semyonov:

Thank you.

Please show the terminal logs at the time of the problem from the start

 
Slava:

Thank you.

Please show the terminal logs at the time of the problem from the start

I have sent the log file via private message.

 
Igor Semyonov:

I've sent the log file by private message.

Yes, thank you.

The logs are all clear.

Tell me, is the situation you described continuing?

 

Volume without DoubleToString(Volume, 2). The screenshot is EURUSD.

 
Slava:

Yes, thank you.

All is clear from the logs.

Tell me, does the situation you described continue?

After restarting the terminal, everything is fine so far.

 

Forum on trading, automated trading systems and trading strategy testing

Bugs, bugs, questions

pantural, 2018.11.01 16:03

Hello dear MT developers, I would like to report a bug in the algorithm for calculating the Sharpe Ratio. In the appendix report by Mr.Aleksey Vyazmikin where SR=0.29 but according to my calculations it is about 3.7-3.8 (depending on whether zero PnL) suggest that the error in the absence of a scaling factor in the standard deviation (sqrt(length)) because the average return does not depend on the length of the series, it converges, and the RMS increases as sqrt(length)

C++

double SharpRatio(vector<double> pnl)

{

double avret = 0;

for (int i = 0; i < pnl.size(); ++i) avret += pnl[i];

avret /= pnl.size();


double var = 0;

for (int i = 0; i < pnl.size(); ++i) var += pow(pnl[i] - avret, 2);

var = sqrt(var / pnl.size()) / sqrt(pnl.size());


return  avret / var;

}

Let's take two identical TCs. We start them simultaneously. One day later they both show the pnl array. The first one was stopped, the second one didn't. After another day, the second one has shown us exactly the same pnl.

That is, the first one has pnl[] and the second one has pnl[]+pnl[]. That is, the second day's trade was identical to the first day's trade.


Then according to the suggested formula the second TS's Sharpe Ratio will be sqrt(2) (root of two) less than the first one's one. But they traded identically!

 
fxsaber:

Take two identical TCs. Run them at the same time. After 24 hours they both showed an array of pnl. The first one was stopped, the second one was not. Another day later the second one showed exactly the same pnl.

That is, the first one has pnl[] and the second one has pnl[]+pnl[]. That is, the second day's trade was identical to the first day's trade.


Then according to the suggested formula the second TS's Sharpe Ratio will be sqrt(2) (root of two) less than the first one's one. But they traded identically!

How does the joke go? "They should be killed while they're small" .

Well, let's look at the example from the file attached to . Because in theory it all looks scary until you feel it with your hands.

There are 144 trades in that file, the Sharpe value of which is 0.29 (the site shows it with an accuracy of 2 decimal places, and that's ok - no one needs 5 decimal places, in this case 2 decimal places is enough for good measure to compare two strategies).

Sharpe is calculated as K/STD ratio, where:

  • K - average growth coefficient for the trading history
  • STD is the standard deviation of gains over the trading history

Suppose we have twice as many trades that were copies of previous trades. It means that now we have 288 trades = 144*2. At the same time K will not change. So, we can change Sharpe only by changing STD.

Initial STD=MathSqrt(X2/(n-1)), where:

  • X2 is the sum of the squares of the deviations from the mean X_aver
  • n - number of teads == 144

That is Sharpe=MathSqrt(X2/(144-1)) = MathSqrt(X2/143)

We have doubled the number of trades, so for a twice larger history the new Sharpe is calculated like this

SharpeNew=MathSqrt(X2_new/(2*144-1))

Where X2_new=2*X2. Therefore SharpeNew/Sharpe ratio = MathSqrt(X2/(144-1)) / MathSqrt(X2_new/(2*144-1)) =

MathSqrt(X2/(144-1))  / MathSqrt(2* X2/(2*144-1)) =  MathSqrt(X2/(143))  / MathSqrt(2* X2/(283))= MathSqrt(X2*283/(2*143*X2))= MathSqrt(283/286)= 0.994741 

Even if I mixed up the denominator with the numerator, SharpeNew will be in the range 0.292919- 0.296025. That is, the difference will be somewhere on the third digit.

But not by 10-20 times. Check for yourself where I have made a mistake.

 
Rashid Umarov:

What's the joke? "They should be killed while they're small."

You misunderstand me.

Forum on trading, automated trading systems and strategy testing

Bugs, bugs, questions

fxsaber, 2018.11.06 13:23

Then according to the proposed formula, the Sharpe ratio of the second TS would be sqrt(2) (root of two) less than the first one. But they traded identically!


I meant the quoted formula from C++.


And in the formula used in MT, of course, one would not be subtracted. Then the proposed example, no matter how many intervals of 144, Sharp would always be the same.

Reason: