/

 

: / , . . .

Metatrader. MQL4.

 

// +- . time_stat_valut12.csv

int cur_period, statfile;

double money[][7], porog = 0.79;

int plus[][7], minus[][7],rovno[][7];

double money_plus[][7], money_minus[][7];

string time_ar[];

string ValutFirst = "EURUSD"; // ,

string ValutSecond = "EURUSD"; //

string VV[14] = {"EURUSD","EURGBP","USDCAD","GBPUSD","USDCHF","AUDUSD","EURCAD","USDJPY","EURAUD","CHFSGD","EURNZD","USDSGD","USDSEC","EURCHF"}; // - , ,

string WeekDay[] = {"","","","","","",""};

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

double spread;

bool FULL_STORY = false;

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

int start()

{

int i, tt, dd, Hist;

statfile = FileOpen("statfileday.csv",FILE_CSV|FILE_WRITE, ';');

double delta;

for(int v=0;v<14;v++)

{

ValutFirst = VV[v];

Alert(ValutFirst, " ", v);

spread = MarketInfo(ValutFirst,MODE_SPREAD)*MathPow(10,(-1)*MarketInfo(ValutFirst,MODE_DIGITS));

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

{

cur_period = TimeFrame[j];

if(FULL_STORY == true)

{

Hist = iBars(ValutFirst, cur_period)-1;

}

else

{

Hist = 1500*(60/cur_period);

}

InitArray();

MakeTimeChains();

for (i=1;i<Hist;i++)

{

tt = GetTime(iTime(ValutFirst, cur_period,i));

dd = TimeDayOfWeek(iTime(ValutFirst, cur_period,i)); //

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

//if(delta > 0) {delta = delta - spread;}

//else if(delta < 0) {delta}

money[tt][dd] = money[tt][dd] + delta;

//Alert(time_ar[tt],";", money[tt][dd]);

if (delta > 0)

{

delta = delta - spread;

if(delta > 0)

{

plus[tt][dd]++;

money_plus[tt][dd] = money_plus[tt][dd] + delta;

}

else

{

rovno[tt][dd]++;

//money_minus[tt][dd] = money_minus[tt][dd] + delta;

}

}

else if (delta < 0)

{

delta = delta + spread;

if(delta < 0)

{

minus[tt][dd]++;

money_minus[tt][dd] = money_minus[tt][dd] + delta;

}

else

{

rovno[tt][dd]++;

//money_plus[tt][dd] = money_plus[tt][dd] + delta;

}

}

else

{

rovno[tt][dd]++;

}

}

//

for(int r=0;r<7;r++)

{

for(int w=0;w<1440;w++)

{

if (plus[w][r] != 0)

{

money_plus[w][r] = money_plus[w][r]/plus[w][r];

}

if (minus[w][r] != 0)

{

money_minus[w][r] = money_minus[w][r]/minus[w][r];

}

}

}

PishemVFile();

} //

} //

FileClose(statfile);

Alert("End");

return(0);

}

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

int GetTime(datetime inp)

{

int H = TimeHour(inp); //

int M = TimeMinute(inp); //

int ret = H*(60/cur_period) + M/cur_period;

return (ret);

}

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

void MakeTimeChains()

{

//

int H=0, M=0;

for(int i=1;i<=1440/cur_period;i++)

{

M = M + cur_period;

if(MathMod(M,60) == 0)

{

H++; M=0;

}

else

{

}

time_ar[i] = DoubleToStr(H,0) + ":" + DoubleToStr(M,0);

}

time_ar[0] = "00:00";

}

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

void PishemVFile()

{

string filename = "/timestatByDay/" + ValutFirst + DoubleToStr(cur_period,0)+".csv";

double sum1,sum2,sum3,sum4,sum5,pl1,pl2,pl3,pl4,pl5,mn1,mn2,mn3,mn4,mn5;

string ThisDay; //

//Alert(filename);

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

for(int i=0;i<1440/cur_period;i++)

{

ThisDay = "";

sum1 = (plus[i][1]+minus[i][1]+rovno[i][1]);

sum2 = (plus[i][2]+minus[i][2]+rovno[i][2]);

sum3 = (plus[i][3]+minus[i][3]+rovno[i][3]);

sum4 = (plus[i][4]+minus[i][4]+rovno[i][4]);

sum5 = (plus[i][5]+minus[i][5]+rovno[i][5]);

pl1=0;pl2=0;pl3=0;pl4=0;pl5=0;mn1=0;mn2=0;mn3=0;mn4=0;mn5=0;

if (sum1 != 0) {pl1 = plus[i][1]/sum1; mn1 = minus[i][1]/sum1;}

if (sum2 != 0) {pl2 = plus[i][2]/sum2; mn2 = minus[i][2]/sum2;}

if (sum3 != 0) {pl3 = plus[i][3]/sum3; mn3 = minus[i][3]/sum3;}

if (sum4 != 0) {pl4 = plus[i][4]/sum4; mn4 = minus[i][4]/sum4;}

if (sum5 != 0) {pl5 = plus[i][5]/sum5; mn5 = minus[i][5]/sum5;}

if (pl1 > porog) {ThisDay = "1 ;" + DoubleToStr(money_plus[i][1],5) + " ;";} if (mn1 > porog) {ThisDay = "-1 ;" + DoubleToStr(money_minus[i][1]*(-1),5) + " ;";}

if(pl1 > porog || mn1 > porog) {FileWrite(statfile, ValutFirst, cur_period, time_ar[i], sum1, ThisDay, spread);}

if (pl2 > porog) {ThisDay = "2 ;" + DoubleToStr(money_plus[i][2],5) + " ;";} if (mn2 > porog) {ThisDay = "-2 ;" + DoubleToStr(money_minus[i][2]*(-1),5) + " ;";}

if(pl2 > porog || mn2 > porog) {FileWrite(statfile, ValutFirst, cur_period, time_ar[i], sum1, ThisDay, spread);}

if (pl3 > porog) {ThisDay = "3 ;" + DoubleToStr(money_plus[i][3],5) + " ;";} if (mn3 > porog) {ThisDay = "-3 ;" + DoubleToStr(money_minus[i][3]*(-1),5) + " ;";}

if(pl3 > porog || mn3 > porog) {FileWrite(statfile, ValutFirst, cur_period, time_ar[i], sum1, ThisDay, spread);}

if (pl4 > porog) {ThisDay = "4 ;" + DoubleToStr(money_plus[i][4],5) + " ;";} if (mn4 > porog) {ThisDay = "-4 ;" + DoubleToStr(money_minus[i][4]*(-1),5) + " ;";}

if(pl4 > porog || mn4 > porog) {FileWrite(statfile, ValutFirst, cur_period, time_ar[i], sum1, ThisDay, spread);}

if (pl5 > porog) {ThisDay = "5 ;" + DoubleToStr(money_plus[i][5],5) + " ;";} if (mn5 > porog) {ThisDay = "-5 ;" + DoubleToStr(money_minus[i][5]*(-1),5) + " ;";}

if(pl5 > porog || mn5 > porog) {FileWrite(statfile, ValutFirst, cur_period, time_ar[i], sum1, ThisDay, spread);}

//FileWrite(handle, i, time_ar[i], sum1, pl1, mn1, ";",sum2, pl2, mn2, ";", sum3, pl3, mn3, ";", sum4, pl4, mn4, ";", sum5, pl5, mn5);

//if((pl1 > porog || pl2 > porog || pl3 > porog || pl4 > porog || pl5 > porog) || (mn1 > porog || mn2 > porog || mn3 > porog || mn4 > porog || mn5 > porog))

//{

// FileWrite(statfile, ValutFirst, cur_period, time_ar[i], ThisDay, spread);

//}

}

FileClose(handle);

//FileClose(statfile);

}

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

void InitArray()

{

 

ArrayResize(money, 1440/cur_period); //

ArrayResize(time_ar, 1440/cur_period); //

ArrayResize(plus, 1440/cur_period);

ArrayResize(minus, 1440/cur_period);

ArrayResize(rovno, 1440/cur_period);

ArrayResize(money_plus, 1440/cur_period);

ArrayResize(money_minus, 1440/cur_period);

ArrayInitialize(money, 0);

ArrayInitialize(plus, 0);

ArrayInitialize(minus, 0);

ArrayInitialize(rovno, 0);

ArrayInitialize(money_plus, 0);

ArrayInitialize(money_minus, 0);

 

}

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

:
" ":

:
:
Profit/Loss :
MACD:
:

()




@Mail.ru

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


http://apsheronsk.bozo.ru - !