Machine learning in trading: theory, models, practice and algo-trading - page 1558

 
Vladimir Perervenko:

It's not so easy to look through someone else's code. We only look at the custom_tester() function and only the highlighted part.

What is the error in calculating the result? You calculate the result at each iteration adding result += testpr[i] - lastpr to the previous value. This is the difference between the Close of the current bar and the previous one. Ideally, it would be better to use Close - Open, but it does not matter. The important thing is that having received a signal at the close of the current bar, you calculate the signal premium as diff(Close) of the same bar. This is incorrect. The signal premium of the current bar is diff(Close) of the next bar. To correctly calculate the result, you must shift p = model.predict_proba(X) to the right by one bar. I will show further calculations on R as it is easier for me.

In the first line, convert the predictions to nominal (1,-1), shift to the right by one bar, remove NA, get a vector of signals. In the second line cumulatively summarize the product of the signals vector and diff(Close) vector, having previously aligned it with the signals vector in length. Then we get the correct result.

Good luck

The current price is saved when opening a position. In the cycle, if the signal does not change, we continue to move the price forward, keeping the open trade.

If the signal changes on the next bar, reverse the trade (lastdeal) and subtract from the current price the opening price of the trade, the difference = profit or loss, add to total accumulated amount of balance

For buying we deduct opening price from the current price, for selling - vice versa. I think there is no error there.

Since the signal is taken for the current bar, there is no need to shift

1 - sale, 0 - buy. Notation. The tester is very simple

The code could probably be shortened, I did not bother with it

 
Maxim Dmitrievsky:

when opening a trade the current price is retained. In the cycle, if the signal did not change, we continue to move the price forward, keeping the open trade.

If the signal changes on the next bar, reverse the trade (lastdeal) and subtract from the current price the opening price of the trade, the difference = profit or loss, add to total accumulated amount on balance

For buying we deduct opening price from the current price, for selling - vice versa. I think there is no error there.

Since the signal is taken for the current bar, there is no need to shift

1 - sale, 0 - buy. Notation. The tester is very simple

Perhaps the code could be shortened, I did not bother with it.

This is another approach. With this version seems to be really right. I take back my remark.

Good luck

 

If you're interested in returnees, there's some information in the cammats

https://smart-lab.ru/blog/569692.php#comments

Тестирование модели на машинном обучении. Часть четвертая.
Тестирование модели на машинном обучении. Часть четвертая.
  • smart-lab.ru
Тестирование модели на машинном обучении. Часть четвертая.
 
Maxim Dmitrievsky:

If you're interested in returnees, there's some information in the cammats

https://smart-lab.ru/blog/569692.php#comments

the name alone puts you in awe :-)

 
Man, I'm stuck as usual. Who would have thought that making an array unique in Java would be such a pain in the ass. :-(
 
Grigoriy Chaunin:

A new version of the library for connecting Python to MT5 has been posted. I remind the link https://github.com/RandomKori/Py36MT5 But there are problems. In Visual Studio the test project works as it should, but in MT there are some unclear problems. Now the library normally works with the directory where the Python script is located. I don't know how to debug it with MT. MT is protected from the debugger. Maybe someone knows how to debug?

Hello,

advise how to connect the library.

The script can be located in any directory? The code is hardwired to "C:\local\Scripts\"

When placing the dll in the "MQL5\Libraries" folder the library is included, but all other libraries, like "python36.dll, kernell32.dll etc." are not included.

In the Path folder paths to python prescribed.

How to connect pymt.dll correctly?

 
 
 
Maxim Dmitrievsky:

There is a clear overtraining on the face of it. You could see that he acts today the same as yesterday. So the 200 years of experience that they allegedly get in the process of training is not what is needed alas :-(

 
Mihail Marchukajtes:

There is a clear overtraining on the face of it. You could see that he acts today the same as yesterday. So the 200 years of experience that they allegedly get in the process of training is not what is needed alas :-(

Yep, zero intelligence
Reason: