: .

Metatrader. MQL4.

 

extern int His = 60000;

extern int Inp_count = 0; //

extern int Out_count = 0; //

int Inp[][30]; //

int Out[][129]; // /// 2^7!!

double Kross[][129]; //

double KrossMoney[][129]; //

int Count[]; //

int temp[30]; // Close-Open

int temp5[30]; // 5

int PlusMinus[]; // . , , ,

int inp_size_min = 3;

int inp_size = 3; //

int out_size = 2; //

int inp_max_size = 9; //

int out_max_size = 5;

int handle1; //

int chainfile; //

double porog = 0.61; // %

int sentiment = 10; // (!)

int sens = 0; // ,

double Money = 0; // KrossMoney

string ValutFirst = "EURUSD"; // ,

string ValutSecond = "EURUSD"; //

string VV[8] = {"EURUSD","EURGBP","USDCAD","GBPUSD","USDCHF","AUDUSD","EURCAD","USDJPY"}; // - , ,

int StatPeriod = 5;

int TimeFrame[4] = {60, 30, 15, 5, 1};

int smoo = 0; //

 

int start()

{

int x,y;

handle1 = FileOpen("profiler.csv", FILE_CSV|FILE_WRITE,';');

chainfile = FileOpen("chain.csv", FILE_CSV|FILE_WRITE, '\t');

FileWrite(chainfile, sens); //

for(int qq=3;qq<6;qq++) //

{

smoo = qq;

// -

for (int tt=0;tt<8;tt++)

{

// -

ValutFirst = VV[tt];

for (int ff=0;ff<8;ff++)

{

ValutSecond = VV[ff];

// -

for (int uu=0;uu<5;uu++)

{

StatPeriod = TimeFrame[uu];

for(int zz=inp_size_min;zz<=inp_max_size;zz++) //

{

inp_size = zz;

sentiment = inp_size-sens;

for(int kk=2;kk<=out_max_size;kk++)

{

out_size = kk;

InitMassives();

Alert(ValutFirst,";",ValutSecond,";",StatPeriod,";",zz,"x",kk);

for(int i = iBars(ValutFirst,StatPeriod);i>inp_size+out_size;i--)

{

MakeTMP(i);

x = SearchInputMassive();

y = SearchOutputMassive();

Kross[x][y] = Kross[x][y] + 1;

KrossMoney[x][y] = KrossMoney[x][y] + Money;

Count[x]++;

}

PlotKrossInFile();

}

} //

} //

} //

} //

}

FileClose(handle1);

FileClose(chainfile);

Alert("");

return(0);

}

//+------------------------------------------------------------------+

void InitMassives()

{

int i,j;

ArrayResize(Inp, MathPow(2,inp_size));

ArrayResize(Out, MathPow(2,out_size));

ArrayResize(Kross, MathPow(2,inp_size));

ArrayResize(Count,MathPow(2, inp_size));

ArrayResize(KrossMoney, MathPow(2,inp_size));

ArrayInitialize(Kross,0);

ArrayInitialize(KrossMoney,0);

ArrayInitialize(Inp,1);

ArrayInitialize(Out,1);

ArrayInitialize(Count,0);

ArrayInitialize(temp,0);

ArrayInitialize(temp5,0);

Inp_count=0; Out_count=0;

}

//+------------------------------------------------------------------+

int SearchInputMassive()

{

int ss = 0; // , +1

for (int i=0;i<=Inp_count;i++)

{

ss = 0;

for(int j=0;j<inp_size;j++)

{

if (Inp[i][j] == temp[j]) {ss++;}

if (ss == sentiment) {return (i);}

}

}

Inp_count++; // ,

//Alert(Inp_count, " // ",temp[0],temp[1],temp[2],temp[3]);

i = Inp_count; //

for(j=0;j<inp_size;j++)

{

Inp[i][j] = temp[j]; // Inp

}

return (i);

}

//+------------------------------------------------------------------+

int SearchOutputMassive()

{

int ss = 0; // ++

for(int i=0;i<=Out_count;i++)

{

ss = 0;

for(int j=0;j<out_size;j++)

{

if(Out[i][j] == temp5[j]) {ss++;}

}

if(ss == out_size) {return (i);}

}

//Alert(Out_count);

Out_count++; // ,

i = Out_count; //

for(j=0;j<out_size;j++)

{

Out[i][j] = temp5[j]; // Inp

}

return (i);

}

//+------------------------------------------------------------------+

int MakeTMP(int num)

{

ArrayInitialize(temp,0);

ArrayInitialize(temp5,0);

int ss = 0;

double delta=0;

Money=0;

//

for(int i=num;i>num-inp_size;i--)

{

delta = iClose(ValutFirst,StatPeriod,i) - iOpen(ValutFirst,StatPeriod,i);

if (delta > 0) {temp[ss] = 1;}

else {temp[ss] = -1;}

ss++;

}

//

ss = 0;

for(i=num-inp_size-smoo;i>num-inp_size-out_size-smoo;i--)

{

delta = iClose(ValutSecond,StatPeriod,i) - iOpen(ValutSecond,StatPeriod,i);

if (delta > 0) {temp5[ss] = 1;}

else {temp5[ss] = -1;}

Money = Money + delta;

ss++;

}

//Alert(temp[0],temp[1],temp[2],temp[3],temp[4]);

//Alert(num,"*",Close[num],Open[num]);

return (0);

}

//+------------------------------------------------------------------+

void PlotKrossInFile()

{

Alert("Input_count=", Inp_count);

Alert("Output_count=", Out_count);

string legend = OutLegend(); // ,

int i,j,z,zet;

double cc = 0, tmp, tmp_money, tmp2;

double Out_Procent[3] = {0,0,0}; // , +, =,- / 1 !!!

double Out_Sum[3]; // ,

string str1,str2,str3, str4, str5, str6, str7;

string filename = "/Stat/" + ValutFirst + "_" + ValutSecond + "_M"+ DoubleToStr(StatPeriod,0) +"_"+DoubleToStr(inp_size,0) + "x" + DoubleToStr(out_size,0) + "-" +DoubleToStr(smoo,0) +".csv";

int handle = FileOpen(filename, FILE_CSV|FILE_WRITE, ';');

// FileWrite(handle, "xxx", legend);

for(i=0;i<=Inp_count;i++)

{

str1 = ""; str2 = ""; z = 0; str6 = "";

for(j=0;j<=Out_count;j++)

{

zet = 0;

if(Kross[i][j] > 0) //if(Kross[i][j] != 0)

{

for (z=0;z<inp_size;z++) {str1 = str1 + DoubleToStr(Inp[i][z],0) + ":" ;} //

for (z=0;z<out_size;z++) {str6 = str6 + DoubleToStr(Out[j][z],0)+ ":";}

str7 = "";

for (z=0;z<=Out_count;z++) //

{

if (Count[i] != 0)

{

tmp = Kross[i][z]/Count[i];

tmp_money = KrossMoney[i][z]/Count[i]; // -

str2 = str2 + ";" + DoubleToStr(tmp,2);

}

else

{

tmp = 0; tmp_money=0;

str2 = str2 + ";" + "0";

}

//if (tmp > porog) {zet = 1;} // ,

// , , ,

if (PlusMinus[z] == -1) //

{

Out_Procent[0] = Out_Procent[0] + tmp;

Out_Sum[0]=Out_Sum[0]+tmp_money;

}

else if (PlusMinus[z] == 0) //

{

Out_Procent[1] = Out_Procent[1] + tmp;

Out_Sum[1]=Out_Sum[1]+tmp_money;

}

else if (PlusMinus[z] == 1) //

{

Out_Procent[2] = Out_Procent[2] + tmp;

Out_Sum[2]=Out_Sum[2]+tmp_money;

}

str7 = str7 + PlusMinus[z];

}

if ((Out_Procent[0]>porog) || (Out_Procent[2]>porog)) {zet=1;}

//FileWrite(handle, Count[i], "%", str1, "*", str2);

//FileWrite(handle, Count[i]); //-

str4 = DoubleToStr(Out_Procent[0],2) + ";" + DoubleToStr(Out_Procent[1],2) + ";" + DoubleToStr(Out_Procent[2],2);

str5 = DoubleToStr(Out_Sum[0]*1000,2) + ";" + DoubleToStr(Out_Sum[1]*1000,2) + ";" + DoubleToStr(Out_Sum[2]*1000,2);

//FileWrite(handle, TR(Count[i]),";",TR(str6),";", TR(str2), ";",TR(str1), ";",TR(str4),";",TR(str5));

FileWrite(handle, TR(Count[i]),TR(str6), TR(str2), TR(str1), TR(str4) ,TR(str5));

ArrayInitialize(Out_Procent,0); ArrayInitialize(Out_Sum,0);//

if(zet == 1 && Count[i]>100) // 10,

{

str3 = DoubleToStr(inp_size,0) + "x" + DoubleToStr(out_size,0);

FileWrite(handle1, TR(Count[i]), TR(iBars(ValutFirst,StatPeriod)), TR(filename), TR(ValutFirst), TR(ValutSecond), TR(str3), TR(str1), TR(str4), smoo);

//

FileWrite(chainfile, ValutFirst);

FileWrite(chainfile, ValutSecond);

FileWrite(chainfile, StatPeriod);

FileWrite(chainfile, str4);

FileWrite(chainfile,Count[i]);

FileWrite(chainfile, iBars(ValutFirst,StatPeriod));

FileWrite(chainfile, str1, " *",str6);

FileWrite(chainfile, smoo);

}

break;

}

}

}

FileClose(handle);

}

//+------------------------------------------------------------------+

string OutLegend()

{

// , ,

ArrayResize(PlusMinus, Out_count);

ArrayInitialize(PlusMinus, -2);

string str = "";

int sea;

for(int i=0;i<=Out_count;i++)

{

sea = 0;

for(int j=0;j<out_size;j++)

{

if(Out[i][j] == 1) {sea++;}

else {sea--;}

}

if (sea > 0) {str = str + "1: "; PlusMinus[i]=1;} // , 1

else if (sea == 0) {str = str + "0: "; PlusMinus[i]=0;}

else {str = str + "-1: "; PlusMinus[i]=-1;}

//Alert(PlusMinus[i]);

}

//Alert("**************");

//Sleep(20);

return (str);

}

//+--------------------------------------------------------------------+

string TR(string txt) // Trim

{

return (StringTrimLeft(StringTrimRight(txt)));

}

 

:
" ":

:
:
Profit/Loss :
MACD:
:

()





@Mail.ru

 
 
:
VBA -2014
, E-mail: apsheronka@mail.ru
,


http://apsheronsk.bozo.ru - !


`