Once again, arbitrage, pair trading. - page 19

 
Aleksei Beliakov:

Thank you! I'll have a look.

You're welcome, there's also a version based on increments instead of bare prices, but it doesn't make much sense

 

By the way, through this indicator I discovered some oddity of the mt5 terminal. When copying quotes of several symbols, very often the f-i returns -1, and at different moments, it's unclear what it's related to. I have to keep trying to copy in the loop until they are copied. I have to keep trying to copy from the loop until they are copied. I will send it to servicedesk.

 
Maxim Dmitrievsky:

By the way, through this indicator I discovered some oddity of the mt5 terminal. When copying quotes of several symbols, very often the f-i returns -1, and at different moments, it's unclear what it's related to. I have to keep trying to copy in the loop until they are copied. I have to keep trying to copy from the loop until they are copied. I will send it to servicedesk.

Maybe the data is not ready. You need to get them a bit. It is written in the help.
 
Maxim Dmitrievsky:

By the way, through this indicator I discovered some oddity of the mt5 terminal. When copying quotes of several symbols, very often the f-i returns -1, and at different moments, it's unclear what it's related to. I have to keep trying to copy in the loop until they are copied. I have to keep trying to copy from the loop until they are copied. I will send it to the Service Desk.


in general, everything works asynchronously in indicators

here is a thread where it is discussed

https://www.mql5.com/en/forum/168437

if i got it right))

[MQL5 BUG] [SOLVED]Indicators are not properly instantiated when called/created from an Indicator of different working time-frame.
[MQL5 BUG] [SOLVED]Indicators are not properly instantiated when called/created from an Indicator of different working time-frame.
  • 2017.01.30
  • www.mql5.com
UPDATE: See the workaround below CopyBuffer() throws an error of 4806 (Indicator data not accessible) when calling an indicator with a different Ti...
 

It is strange that such a problem does not occur in the tester, while it occurs in the real world

I do not understand what streams have to do with it, if prices for different symbols are copied sequentially

 
Maxim Dmitrievsky:

It is strange that such a problem does not occur in the tester, but in real life it occurs

I do not understand what streams have to do with it, if prices are copied sequentially


in the Expert Advisor, it requests prices and waits for them to arrive

not in the indicator

you should look at the topic I posted there where they explained it straightforwardly
 
Aleksei Beliakov:

Well, in the Expert Advisor it asks for prices and waits for them to arrive

Not in the indicator.

Look at the thread I gave them. They've got it all figured out.

Yeah, I'm reading it. Thanks.

 

Well actually yes, that's how it works:

Support Team2017.12.22 13:13

In order for an indicator to be able to copy quotes from someone else's symbol-periods, those same symbol-periods need to be loaded into the terminal.

Ideally, when the relevant charts are open.

If the charts are not open, then on the initialization of the indicator, arrange access to the necessary symbols-periods and then regularly access these symbols-periods. After a few minutes of no access the data of another symbol-period will be unloaded

i.e. re-initialisation of symbol access itself is quite slow

 

Suggested implementation of using linear regression, has anyone tried it?

http://www.thealgoengineer.com/2014/online_linear_regression_kalman_filter/

Online Linear Regression using a Kalman Filter
Online Linear Regression using a Kalman Filter
  • www.thealgoengineer.com
13 Aug 2014 • 5 min. read • Comments Linear regression is useful for many financial applications such as finding the hedge ratio between two assests in a pair trade. In a perfect world, the realtionship between assests would remain constant along with the slope and intercet of a linear regression. Unfortutanely this is usually the exception...
 
Hi all!
I am trying to trade on the strategy of pair trading (arbitrage, correlation of two pairs).
The strategy is approximately as follows:
Find two well correlated pairs.
Find the moment of big price divergence. Buy one pair and sell the other.
Short for the one that went up. For the one that went down - a long.
Lots are calculated so as to get a lock. Prices of two pairs are different.
There is not a big risk of losing the account in case of sharp price fluctuations.
Then when pairs have returned to the normal correlation, closing of two orders by the total profit.

I am writing an Expert Advisor for auto trading.
The correlation indicator gives the value of the correlation (approximately 1...-0.2). I set the threshold of permission to trade.
Two orders will be opened. Lots are set in proportion to the prices of pairs that would create a lock.
When the sum of profits of two pairs reaches the specified positive value, two orders are closed.
Again, the Expert Advisor waits for a signal from the indicator to start trading.

I want to add an autotracking of price. I can also try to close orders when the correlation returns to the specified value.

I have faced a problem. I am looking for an algorithm for determining the trade direction.
What characteristics may determine which pair has gone up or down?
So far I am determining visually by combining charts.
It is very important to determine which pairs are up/down.
Do you have any experience, any answers?
Reason: