void TralOverlap()
{
switch(overlap)
{
case 1:
case 2:
case 3:
case 4: {ColOver0=clrDeepSkyBlue; ColOver1=clrAqua; Typetral="Трал частичн. перекрытия!";} break;
case 5:
case 6:
case 7:
case 8: {ColOver0=clrGold; ColOver1=clrYellow; Typetral="Трал основн. перекрытия!";} break;
case 9:
case 10:
default: break;
}
switch(overlap)
{
case 10:
case 8:
case 6:
case 4:
case 2:
{
if(!flag)
{
PrOver=NormalizeDouble(Ask,Digits);
flag=true;
if(Info)
{
DrawLine("IOverTP",PrOver,ColOver0,1);
}
}
else if(flag && !flag1 && Ask<PrOver-OverTralStart*Point)
{
flag1=true;
if(Info)
{
DrawLine("IOverTP",PrOver,ColOver1,1);
}
}
else if(flag1)
{
if(Ask<PrOver-(OverTralStart+OverTralSize)*Point)
{
PrOver=Ask+OverTralStart*Point;
if(Info)
{
DrawLine("IOverTP",PrOver,ColOver1,1);
}
}
else if(Ask>=PrOver)
{
if(Info)
{
DeleteSelObj("IOverTP");
DeleteSelObj("ItxtOver");
}
switch(overlap)
{
case 2:
{
int t=0;
if(Cprofit1!=0)
{
for(int i=0; i<ArraySize(Clot); i++)
{
double k=0.0;
k=Cprofit[i]/Cprofit1;
if(Cprofit[i]<0.0 && Clot[i]>k*Lprofit1*Clot[i]/-Cprofit[i])
Clot[i]=MathFloor(k*Lprofit1*Clot[i]/-Cprofit[i]/Step)*Step;
if(Clot[i]>=minLot)
{
if(CloseOrder(Cpos[i],-1,Clot[i])) t++;
}
}
if(t>0) {for(int i=0; i<ArraySize(Llot); i++) CloseOrder(Lpos[i]); flag=false;}
}
}
break;
case 4:
{
m=0;
if(Cprofit1!=0)
{
for( int i=0; i<ArraySize(Clot); i++)
{
double k=0.0;
k=Cprofit[i]/Cprofit1;
if(Cprofit[i]<0.0 && Clot[i]>k*Lprofit1*Clot[i]/-Cprofit[i])
Clot[i]=MathFloor(k*Lprofit1*Clot[i]/-Cprofit[i]/Step)*Step;
if(Clot[i]>=minLot)
{
if(CloseOrder(Cpos[i],OP_SELL,Clot[i])) m++;
}
}
if(m>0) {for( int i=0; i<ArraySize(Llot); i++) CloseOrder(Lpos[i],OP_SELL); flag=false;}
}
}
break;
case 6:
{
if(CloseOrder(Cpos[0]))
{
for( int i=0; i<ArraySize(Llot); i++) CloseOrder(Lpos[i]); flag=false;
}
}
break;
case 8:
{
if(CloseOrder(Cpos[0],OP_SELL,Clot[0]))
{
for(int i=0; i<ArraySize(Llot); i++) CloseOrder(Lpos[i],OP_SELL,Llot[i]); flag=false;
}
}
break;
}
if(!flag)
{
flag1 =false;
PrOver =0.0;
overlap=0;
}
}
}
}
break;
case 9:
case 7:
case 5:
case 3:
case 1:
{
if(!flag)
{
PrOver=NormalizeDouble(Bid,Digits);
flag=true;
if(Info)
{
DrawLine("IOverTP",PrOver,ColOver0,1);
}
}// запоминаем уровень один раз
else if(flag && !flag1 && Bid>PrOver+OverTralStart*Point)
{
flag1=true;
if(Info)
{
DrawLine("IOverTP",PrOver,ColOver1,1);
}
}
else if(flag1)
{
if(Bid>PrOver+(OverTralStart+OverTralSize)*Point)
{
PrOver=Bid-OverTralStart*Point;
if(Info)
{
DrawLine("IOverTP",PrOver,ColOver1,1);
}
}
else if(Bid<=PrOver)
{
if(Info)
{
DeleteSelObj("IOverTP");
DeleteSelObj("ItxtOver");
}
switch(overlap)
{
case 1:
{
int t=0;
if(Cprofit1!=0)
{
for( int i=0; i<ArraySize(Clot); i++)
{
double k=0.0;
k=Cprofit[i]/Cprofit1;
if(Cprofit[i]<0.0 && Clot[i]>k*Lprofit1*Clot[i]/-Cprofit[i])
Clot[i]=MathFloor(k*Lprofit1*Clot[i]/-Cprofit[i]/Step)*Step;
if(Clot[i]>=minLot)
{
if(CloseOrder(Cpos[i],-1,Clot[i])) t++;
}
}
if(t>0) {for(int i=0; i<ArraySize(Llot); i++) CloseOrder(Lpos[i]); flag=false;}
}
}
break;
case 3:
{
m=0;
if(Cprofit1!=0)
{
for( int i=0; i<ArraySize(Clot); i++)
{
double k=0.0;
k=Cprofit[i]/Cprofit1;
if(Cprofit[i]<0.0 && Clot[i]>k*Lprofit1*Clot[i]/-Cprofit[i])
Clot[i]=MathFloor(k*Lprofit1*Clot[i]/-Cprofit[i]/Step)*Step;
if(Clot[i]>=minLot)
{
if(CloseOrder(Cpos[i],OP_BUY,Clot[i])) m++;
}
}
if(m>0) {for( int i=0; i<ArraySize(Llot); i++) CloseOrder(Lpos[i],OP_BUY); flag=false;}
}
}
break;
case 5:
{
if(CloseOrder(Cpos[0]))
{
for( int i=0; i<ArraySize(Llot); i++) CloseOrder(Lpos[i]); flag=false;
}
}
break;
case 7:
{
if(CloseOrder(Cpos[0],OP_BUY,Clot[0]))
{
for( int i=0; i<ArraySize(Llot); i++) CloseOrder(Lpos[i],OP_BUY,Llot[i]); flag=false;
}
}
break;
}
if(!flag)
{
flag1 =false;
PrOver =0.0;
overlap=0;
}
}
}
}
break;
}
}