//------------------------------------------------------------------//
if(iTime(NULL,TF,0)>prev_time&&Prognoz_Valut==false&&PositionsTotal()==0)
{
OSHIBKA_ETALON_1=1000000000;OSHIBKA_ETALON_2=1000000000;RAZNOST_ETALON=0;RAZNOST_ETALON2=100000;
Symbol1="";Symbol2="";Symbol3="";Symbol4="";sym1="";sym2="";sym3="";sym4="";
LOT1=0;LOT2=0;LOT3=0;LOT4=0;LOT111=0;LOT222=0;LOT333=0;LOT444=0;
ArrayInitialize(MaXIMUM1,-10000);
ArrayInitialize(MiNIMUM1,10000);
ArrayInitialize(MaXIMUM2,-10000);
ArrayInitialize(MiNIMUM2,10000);
w=0;
//Alert("++ РАСЧИТАЕМ НОВЫЙ СИНТЕТИК ++");
for( w=3875; w>0; w--)
{
Symbol1=StringSubstr(SYMBOL_MASS[w],0,6);
Symbol2=StringSubstr(SYMBOL_MASS[w],7,6);
Symbol3=StringSubstr(SYMBOL_MASS[w],14,6);
Symbol4=StringSubstr(SYMBOL_MASS[w],21,6);
//Print(Symbol1+" "+Symbol2+" "+Symbol3+" "+Symbol4);
//------------------------------------------------------------------//
if(StringFind(Symbol1,"JPY")<0) punkt1=1; else punkt1=100;
if(StringFind(Symbol2,"JPY")<0) punkt2=1; else punkt2=100;
if(StringFind(Symbol3,"JPY")<0) punkt3=1; else punkt3=100;
if(StringFind(Symbol4,"JPY")<0) punkt4=1; else punkt4=100;
LOT1=NormalizeDouble(lot*(1*punkt1/MarketInfo(Symbol1,MODE_BID)),2);
LOT2=NormalizeDouble(lot*(1*punkt2/MarketInfo(Symbol2,MODE_BID)),2);
LOT3=NormalizeDouble(lot*(1*punkt3/MarketInfo(Symbol3,MODE_BID)),2);
LOT4=NormalizeDouble(lot*(1*punkt4/MarketInfo(Symbol4,MODE_BID)),2);
double pun11=0,pun12=0,pun13=0,pun14=0;
if(StringFind(Symbol1,"JPY",0)<0) pun11=100000; else pun11=1000;
if(StringFind(Symbol1,"JPY",0)<0) pun12=100000; else pun12=1000;
if(StringFind(Symbol1,"JPY",0)<0) pun13=100000; else pun13=1000;
if(StringFind(Symbol1,"JPY",0)<0) pun14=100000; else pun14=1000;
double Eqwyty1=10*LOT1*MarketInfo(Symbol1,MODE_TICKVALUE);
double Eqwyty2=10*LOT2*MarketInfo(Symbol2,MODE_TICKVALUE);
double Eqwyty3=10*LOT3*MarketInfo(Symbol3,MODE_TICKVALUE);
double Eqwyty4=10*LOT4*MarketInfo(Symbol4,MODE_TICKVALUE);
double SUM_EQWY=Eqwyty1+Eqwyty2+Eqwyty3+Eqwyty4;
//Alert("+++ ПУНКТ ПРИБЫЛИ = "+(string)SUM_EQWY);
//-------------------------------------------------------------------------------------------------//
for(int variant=0;variant<8;variant++)
{
if(variant==0){LOT111=LOT1;LOT222=LOT2;LOT333=LOT3;LOT444=LOT4;OP1="BUY";OP2="BUY";OP3="BUY";OP4="BUY";}
if(variant==1){LOT111=LOT1;LOT222=LOT2;LOT333=LOT3;LOT444=(-1)*LOT4;OP1="BUY";OP2="BUY";OP3="BUY";OP4="SELL";}
if(variant==2){LOT111=LOT1;LOT222=LOT2;LOT333=(-1)*LOT3;LOT444=LOT4;OP1="BUY";OP2="BUY";OP3="SELL";OP4="BUY";}
if(variant==3){LOT111=LOT1;LOT222=LOT2;LOT333=(-1)*LOT3;LOT444=(-1)*LOT4;OP1="BUY";OP2="BUY";OP3="SELL";OP4="SELL";}
if(variant==4){LOT111=LOT1;LOT222=(-1)*LOT2;LOT333=LOT3;LOT444=LOT4;OP1="BUY";OP2="SELL";OP3="BUY";OP4="BUY";}
if(variant==5){LOT111=LOT1;LOT222=(-1)*LOT2;LOT333=LOT3;LOT444=(-1)*LOT4;OP1="BUY";OP2="SELL";OP3="BUY";OP4="SELL";}
if(variant==6){LOT111=LOT1;LOT222=(-1)*LOT2;LOT333=(-1)*LOT3;LOT444=LOT4;OP1="BUY";OP2="SELL";OP3="SELL";OP4="BUY";}
if(variant==7){LOT111=LOT1;LOT222=(-1)*LOT2;LOT333=(-1)*LOT3;LOT444=(-1)*LOT4;OP1="BUY";OP2="SELL";OP3="SELL";OP4="SELL";}
SUMMA_MNK_1=0;SUMMA_MNK_2=0;
TREND_DOWN=false;KORR_UP=false;TREND_UP=false;KORR_DOWN=false;FLAAT=false;
RAZNOST1=0;RAZNOST2=0;
TREND_UP_1=0;TREND_DOWN_1=0;NO_TREND_1=1;
//----------------ПЕРВЫЙ УЧАСТОК-----------
double INDyK5=Equity_4I_Pairs(Symbol1,Symbol2,Symbol3,Symbol4,ST2,TF,ST1,LOT111,LOT222,LOT333,LOT444);
double INDyK6=Equity_4I_Pairs(Symbol1,Symbol2,Symbol3,Symbol4,ST2,TF,ST,LOT111,LOT222,LOT333,LOT444);
if((INDyK5>(SUM_EQWY*(ST2-ST1)*TREND) && (INDyK5-INDyK6)<=(INDyK5/Trend_Flat)) ||
(INDyK5<(SUM_EQWY*(ST2-ST1)*TREND*(-1)) && (INDyK5-INDyK6)<=(INDyK5/Trend_Flat)))
{
//------------- IF RAZNOST1 == 0 ----------
if(RAZNOST1==0)
{
//Alert("=== ОПРЕДЕЛЯЕМ ПЕРВЫЙ УЧАСТОК ===");
for(int xx=ST2;xx>=ST1;xx--)
{
double INDyK1=Equity_4I_Pairs(Symbol1,Symbol2,Symbol3,Symbol4,ST2,TF,(xx),LOT111,LOT222,LOT333,LOT444);
//Alert("=== ИНДЮК № "+(string)(ST2-xx)+" === "+(string)INDyK1);
if(INDyK1>MaXIMUM1[variant][w]) { MaXIMUM1[variant][w]=INDyK1; }
if(INDyK1<MiNIMUM1[variant][w]) { MiNIMUM1[variant][w]=INDyK1; }
if(INDyK1>SUM_EQWY*(ST2-xx)*TREND)
{
TREND_UP_1++;
}
if(INDyK1<(-1)*SUM_EQWY*(ST2-xx)*TREND)
{
TREND_DOWN_1++;
}
if(INDyK1<SUM_EQWY*(ST2-xx)*TREND && INDyK1>(-1)*SUM_EQWY*(ST2-xx)*TREND)
{
NO_TREND_1++;
}
if(xx==ST1)
{
RAZNOST1=MaXIMUM1[variant][w]-MiNIMUM1[variant][w];
if(TREND_UP_1>TREND_DOWN_1 && (TREND_UP_1/NO_TREND_1)>=TREND_NAL){TREND_UP=true;}
if(TREND_UP_1<TREND_DOWN_1 && (TREND_DOWN_1/NO_TREND_1)>=TREND_NAL){TREND_DOWN=true;}
}
}
}
//------------- IF RAZNOST2 == 0 ----------
if(RAZNOST2==0)
{
//Alert("=== ОПРЕДЕЛЯЕМ ВТОРОЙ УЧАСТОК ===");
for(int xx=ST1;xx>=ST;xx--)
{
double INDyK2=Equity_4I_Pairs(Symbol1,Symbol2,Symbol3,Symbol4,ST1,TF,(xx),LOT111,LOT222,LOT333,LOT444);
double INDyK22=Equity_4I_Pairs(Symbol1,Symbol2,Symbol3,Symbol4,ST2,TF,(xx),LOT111,LOT222,LOT333,LOT444);
if(INDyK22>MaXIMUM2[variant][w]) { MaXIMUM2[variant][w]=INDyK22; }
if(INDyK22<MiNIMUM2[variant][w]) { MiNIMUM2[variant][w]=INDyK22; }
if(xx==ST)
{
RAZNOST2=MaXIMUM2[variant][w]-MiNIMUM2[variant][w];
}
}
}
//------------- ВЫЧИСЛЯЕМ ОШИБКУ ПЕРВОГО УЧАСТКА -------------------
for(int xx=ST2;xx>=ST1;xx--)
{
double INDyK1=Equity_4I_Pairs(Symbol1,Symbol2,Symbol3,Symbol4,ST2,TF,(xx),LOT111,LOT222,LOT333,LOT444);
double MNK_INDyK=INDyK1-(SUM_EQWY*(ST2-xx)*TREND);
SUMMA_MNK_1=SUMMA_MNK_1+(MNK_INDyK*MNK_INDyK);
if(xx==ST1){SUMMA_MNK_1=SUMMA_MNK_1/(ST2-ST1);}
}
//------------- ВЫЧИСЛЯЕМ ОШИБКУ ВТОРОГО УЧАСТКА -------------------
for(int xxx=ST1;xxx>=ST;xxx--)
{
double INDyK2=Equity_4I_Pairs(Symbol1,Symbol2,Symbol3,Symbol4,ST1,TF,(xxx),LOT111,LOT222,LOT333,LOT444);
double MNK_INDyK2=INDyK2;
SUMMA_MNK_2=SUMMA_MNK_2+(MNK_INDyK2*MNK_INDyK2);
if(xxx==ST){SUMMA_MNK_2=SUMMA_MNK_2/(ST1-ST);}
}
if(TREND_UP==true && SUMMA_MNK_1<OSHIBKA_ETALON_1 && SUMMA_MNK_2<OSHIBKA_ETALON_2 && RAZNOST2<RAZNOST_ETALON2
&& MathAbs(RAZNOST2) < MathAbs(RAZNOST1/Trend_Flat)&& RAZNOST1 > RAZNOST_ETALON)
{
PROFIT=RAZNOST2*TAKE_PROFIT;
STOP_LOSS=RAZNOST2;
RAZNOST_ETALON=RAZNOST1;
RAZNOST_ETALON2=RAZNOST2;
MINIMUM_UP=MiNIMUM2[variant][w];
MAXIMUM_UP=MaXIMUM2[variant][w];
OSHIBKA_ETALON_1=SUMMA_MNK_1;
OSHIBKA_ETALON_2=SUMMA_MNK_2;
sym1=Symbol1;sym2=Symbol2;sym3=Symbol3;sym4=Symbol4;
Operation1=OP1;Operation2=OP2;Operation3=OP3;Operation4=OP4;
lot11=LOT111;lot22=LOT222;lot33=LOT333;lot44=LOT444;
Alert("МАКСИМУМ 1= "+(string)MaXIMUM1[variant][w]+" МИНИМУМ 1= "+(string)MiNIMUM1[variant][w]);
Alert("МАКСИМУМ 2 = "+(string)MaXIMUM2[variant][w]+" МИНИМУМ 2 = "+(string)MiNIMUM2[variant][w]);
Alert(" OSHIBKA = "+(string)OSHIBKA_ETALON_1);
Alert(" OSHIBKA_2 = "+(string)OSHIBKA_ETALON_2);
Alert(" RAZNOST = "+(string)RAZNOST1);
Alert(" RAZNOST_2 = "+(string)RAZNOST2);
Alert("+++ TREND UP +++");
Alert(sym1+"= "+Operation1+" "+sym2+"= "+Operation2+" "+sym3+"= "+Operation3+" "+sym4+"= "+Operation4);
Prognoz_Valut=true;
Lot_Raschet=true;
SIGNAL_UP=true;
SIGNAL_DOWN=false;
MINIMUM_DOWN=0;MAXIMUM_DOWN=0;
TREND_DOWN=false;KORR_UP=false;TREND_UP=false;KORR_DOWN=false;
}
if(TREND_DOWN==true && SUMMA_MNK_1<OSHIBKA_ETALON_1 && SUMMA_MNK_2<OSHIBKA_ETALON_2 && RAZNOST2<RAZNOST_ETALON2
&& MathAbs(RAZNOST2) < MathAbs(RAZNOST1/Trend_Flat) && RAZNOST1 > RAZNOST_ETALON)
{
PROFIT=RAZNOST2*TAKE_PROFIT;
STOP_LOSS=RAZNOST2;
RAZNOST_ETALON=RAZNOST1;
RAZNOST_ETALON2=RAZNOST2;
MINIMUM_DOWN=MiNIMUM2[variant][w];
MAXIMUM_DOWN=MaXIMUM2[variant][w];
OSHIBKA_ETALON_1=SUMMA_MNK_1;
OSHIBKA_ETALON_2=SUMMA_MNK_2;
sym1=Symbol1;sym2=Symbol2;sym3=Symbol3;sym4=Symbol4;
Operation1=OP1;Operation2=OP2;Operation3=OP3;Operation4=OP4;
lot11=LOT111;lot22=LOT222;lot33=LOT333;lot44=LOT444;
Alert("МАКСИМУМ 1= "+(string)MaXIMUM1[variant][w]+" МИНИМУМ 1= "+(string)MiNIMUM1[variant][w]);
Alert("МАКСИМУМ 2 = "+(string)MaXIMUM2[variant][w]+" МИНИМУМ 2 = "+(string)MiNIMUM2[variant][w]);
Alert(" OSHIBKA = "+(string)OSHIBKA_ETALON_1);
Alert(" OSHIBKA_2 = "+(string)OSHIBKA_ETALON_2);
Alert(" RAZNOST = "+(string)RAZNOST1);
Alert(" RAZNOST_2 = "+(string)RAZNOST2);
Alert("+++ TREND DOWN +++" );
Alert(sym1+"= "+Operation1+" "+sym2+"= "+Operation2+" "+sym3+"= "+Operation3+" "+sym4+"= "+Operation4);
Prognoz_Valut=true;
Lot_Raschet=true;
SIGNAL_DOWN=true;
SIGNAL_UP=false;
MINIMUM_UP=0;MAXIMUM_UP=0;
TREND_DOWN=false;KORR_UP=false;TREND_UP=false;KORR_DOWN=false;
}
}
}
}
prev_time=iTime(NULL,TF,0);
}