Topic: Formula for R Squared?
Hi guys,
So I’m building the EA Studio trade copier and I need the formula for R squared that either EA Studio or MT4 Tracker uses?
Would anyone have that formula please?
Create and Test Forex Strategies
You are not logged in. Please login or register.
Forex Software → Technical Matters → Formula for R Squared?
Hi guys,
So I’m building the EA Studio trade copier and I need the formula for R squared that either EA Studio or MT4 Tracker uses?
Would anyone have that formula please?
maybe this will help you
https://gist.github.com/PopovMP/9068c8b4d394c0ebe3555cdc7e67d8f6
or check this thread https://forexsb.com/forum/topic/7645/balance-line-stability-development/page/2/
Thanks guys much appreciated
Here is the actual R-Squared code:
Hi Popov, is this the same R squared formula that is used in MT4 Tracker?
I cannot say because I don't have access to the MT4 Tracker source code.
Hi guys m, I’m wondering if anyone would be able to convert the r squared formula that we use in ea Studio to mql4 format to put in the trade copier to assess each strategy trading a fixed lot size. Ie my idea is to have all strategies trading 0.01 lot on the demo and then send strategies over to the live account that have a r squared above X.
I’m just having some trouble trying to get the calculation correct for mql4
Here is pseudo-code, that may be easier to understand:
int fromBar = the bar from where you start the calculation;
double minBalance = find the minimal balance for the period;
double sumX = 0;
double sumY = 0;
double sumXX = 0;
double sumYY = 0;
double sumXY = 0;
int count = 0;
for (int i = 0; i <= count_of_orders; i++) {
if (Close a position) {
int x = oreder[0].bar - fromBar + 1;
double y = oreder[0].balance - minBalance + 1;
sumX += x;
sumY += y;
sumXX += x * x;
sumYY += y * y;
sumXY += x * y;
count++;
}
}
if (count < 2) {
return 0;
}
double r = (count * sumXY - sumX * sumY) / Math.sqrt(count * sumXX - sumX * sumX) / Math.sqrt(count * sumYY - sumY * sumY);
double r5 = Math.pow(r, 5);
return 100 * r5;
Thanks Popov! Your a legend! I’ll give it a go and let you know how it ends up working.
Forex Software → Technical Matters → Formula for R Squared?
Powered by PunBB, supported by Informer Technologies, Inc.