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
present a piece of code to get the correct t-distribution figure because the one I have is not working.
p.s. no correlation figure will reach 940. It is just an illustration to show that the function is working.
I won't need to use the entire range of the student's t-distribution, since I am only interested in probability values of 10,5,1 percent. I plan on rejecting the null hypothesis at a critical level 5 percent for only positive t-scores. I can remake the student's t-distribution function into a more specialized one to account for only the figures I need. This should reduce the complexity:
I know this seems very "artificial" but I think this will be much faster and easier. The values the above function has were simply copied from a real t-table. This just restricts us to using a critical value of 10 or lower along with a required sample size of 100.
The hardest part is completed so what's left to be done is to get a function to :
1) estimate true population parameters, such as population mean. I think the integration function above can do this for us.
2) calculate sample parameters, such as sample mean. Sample size must be exactly 100. We then calculate t-score from sample.
3) conduct a hypothesis test on the estimated population parameters at critical values of 10 or 5 or 1. I will use 5% from the student's tdistribution, so if I get 10% or more I must accept the null hypothesis i.e. the estimated population parameters is invalid. If I get 5% or less then the alternate hypothesis is true i.e. the estimated population parameters are valid.
Can you explain why you use a Student's t-test?
Intuitively, given the last n close prices of two currency pairs, for correlation I'd simply use Pearson's coefficient R, whereas for cointegration I'd use the Engle-Granger test, i.e. a unit root test of the residuals of linear regression.
I'm not saying that your approach is by any means incorrect; probably I just don't understand where you're going with that.
"Can you explain why you use a Student's t-test?"
"Intuitively, given the last n close prices of two currency pairs, for correlation I'd simply use Pearson's coefficient R, whereas for cointegration I'd use the Engle-Granger test, i.e. a unit root test of the residuals of linear regression.
I'm not saying that your approach is by any means incorrect; probably I just don't understand where you're going with that."
Since we don't have all possible correlation figures(population), we will have to estimate it from sample. And if we are going to estimate population parameters from a sample then a t-test is the best tool for this, in my opinion.
Calculating the correlation value(Pearson R) in this direct way is not very reliable, as you will find a drastic difference in figures each time.
Since no one knows what the "true" correlation value(Pearson R) of two currency pairs are then we need a proper way of estimating this value. It is my interpretation that the Law of large Numbers as well as the Central Limit theory applies to ALL numbers in this universe.
Central Limit theory essentially states that for a sufficiently large sample size, the probability of a random variable will converge to a central figure i.e. the true probability figure of a random variable.
The Law of Large Numbers is essentially states that when you take a sufficiently large sample size of any random variable(in this case a correlation value) the resulting distribution will form a nearly symmetrical bell shape regardless of the underlying distribution, and the top of the bell is in the center.i.e you will get a normal distribution.
Here is the usage:
Good bye
Hi hello sir please guide/help me i wanna earn money for my financial assistance but i dont give up for this trading. Try and try.
Please checkout youtube for videos on trading multiple time frames. Once you learn that you will be alright
Since no one knows what the "true" correlation value(Pearson R) of two currency pairs are then we need a proper way of estimating this value. It is my interpretation that the Law of large Numbers as well as the Central Limit theory applies to ALL numbers in this universe.
Central Limit theory essentially states that for a sufficiently large sample size, the probability of a random variable will converge to a central figure i.e. the true probability figure of a random variable.
The Law of Large Numbers is essentially states that when you take a sufficiently large sample size of any random variable(in this case a correlation value) the resulting distribution will form a nearly symmetrical bell shape regardless of the underlying distribution, and the top of the bell is in the center.i.e you will get a normal distribution.
Here is the usage:
Good bye
Regarding "true" correlation I see that in your example code you're already using the formula for the empirical sample correlation (which per se isn't "true", but the best we can get). You might argue that by the law of large numbers the sample average ultimately near equals the expected value, however the law of large numbers strictly speaking isn't valid for fat tail distributions like in trading. However... I guess we don't need perfection to make a trade.
Although I suggested using Pearson's correlation myself, I admit that this method comes with a weakness: it's designed to be used only for evaluation of the relationship between two samples that are assumed to be linearly(!) dependent, which most likely is far from true for any relations in the complex world of price time series.
I see that you have profound knowledge about statistics and maths, so I'll be careful with recommendations ;-) . Personally, what I can think of as an another alternative is Spearman's rank correlation coefficient rho. This can be used similarly to Pearson R, but is designed to be used for non-linear monotonic dependence, which in trading probably is much closer to the truth than linearity.
Spearman's correlation is fairly easy to put into code, e.g. for the correlation betw. array X[] and Y[]:
1. for each element of X[] obtain a rank value (e.g. via pairwise comparison method inside a while-loop until ranking completed) and store the ranks in an array like int X_rank[]
2. the same for Y[] --> Y_rank[]
3. double numerator=0;
for (int n=0;n<elements;n++) {numerator+=6*pow(X_rank[n]-Y_rank[n],2);}
double rho=1-numerator/(elements*(pow(elements,2)-1));
And: you can also derive a t-score from Spearman's rho: t_score = rho*sqrt((elements-2)/(1-pow(rho,2)))
Hi Jean Francois Le Bas. This is what I am getting when I execute "UseAlglib.mq4 ":
Please tell what you did to make it work.
you don't need a pointer to call a function in Alglib
just use the class name : Classname::function()