Welcome Forex EA downloads & MT4/MT5 auto-trading resources — EAs, Gold EAs, quant tools and real-world automation.
Sign In Sign Up

PCA Synthetics - Recycling Old Versions - MetaTrader 5 Scripts - MT4/MT5 Resources

author EAcpu | 2 reads | 0 comments |

PCA Synthetics - Recycle Legacy - indicator for MetaTrader 5

PCA Synthetics - Recycle Legacy - indicator for MetaTrader 5

PCA Synthetics - Recycle Legacy - indicator for MetaTrader 5

PCA Synthetics - Recycle Legacy - indicator for MetaTrader 5

PCA Synthetics - Recycle Legacy - indicator for MetaTrader 5

Indicator that automatically selects the coefficients of each instrument in a pseudo-stationary portfolio that tends toward zero equilibrium.

This indicator requires the presence of the AlgLib library in the terminal's Include\Math folder.

Each instrument moves in its own direction, each direction being a separate dimension in the multidimensional array. By rotating the matrix, i.e. by multiplying each of its elements by a certain number, we try to find an axis with the smallest distance from all instruments, i.e. the smallest total variance. The number multiplied by each element in the matrix becomes the angle value that the moving instrument should turn so that it moves in the same direction as the other instruments. The angle value is the coefficient for each currency in the portfolio.

If the coefficient value is greater than 0, the currency is bought, if less than 0, the currency is sold. Therefore, the stationarity of the created composition can be maintained by recalculating the coefficients from time to time. Furthermore, instead of simply finding the axis along which the portfolio variance is minimized, PCA finds multiple axes. The number of instruments in a portfolio is the number of components (vectors). Each of them is called a principal component and determines the extent to which it contributes to the total change in portfolio movement.

If the chart is not drawn, look at what is printed in the Expert tab. Maybe there are some errors or synchronization with other charts is in progress. If there are no messages, click a different time range.

The resulting vector value is verified against one calculated in the R package, so the value itself is correct. But the sign of a particular coefficient may be wrong because РСА does not pay attention to signs. The "-" or "+" sign can only be determined empirically, i.e. by trial and error.

Issue #2 has been described with a picture here: http://stats.stackexchange.com/questions/34396/im-getting-jumpy-loadings-in-rollapply-pca-in-r-can-i-fix-it

The idea was adopted from here: https://www.mql5.com/en/code/9908

PCA Synthetics - Recycle Legacy - indicator for MetaTrader 5

PCA Synthetics - Recycle Legacy - indicator for MetaTrader 5

PCA Synthetics - Recycle Legacy - indicator for MetaTrader 5


Attachment download

📎 syntheticssource.mq5 (11.78 KB)

📎 resources.mqh (14.94 KB)

📎 matrices.mqh (15.47 KB)

📎 charts.mqh (3.79 KB)

Source: MQL5 #16997

Verification code Refresh