//+------------------------------------------------------------------+ //| LF5_EURJPY_2.mq4 | //+------------------------------------------------------------------+ extern double Lots_1=0.01; extern double Lots_2=0.02; extern double Lots_3=0.04; extern double Lots_4=0.15; extern double Lots_5=0.26; extern double Lots_6=0.59; extern int r=2; double Lots_7=1; double Lots_8=1; double Lots_9=1; double Lots_10=1; double Lots_11=1; double Lots_12=1; extern double Lots_MAX=1; extern double END=-500; double END2; double profit_1=11; double profit_ALL[12]; double Profit_2u=10; double Profit_3u=18; double Profit_4u=18; double Profit_5u=6; double Profit_6u=9; double Profit_7u=2; double Profit_8u=2; double Profit_9u=2; double Profit_10u=2; double Profit_11u=2; double Profit_12u=2; double open=-36; double z=4; double open_i[11]; double L=2; double Lot[12]; double Lot_M[12]; bool START_S=true; bool START_B=true; bool START_S2=true; bool START_B2=true; bool START_S3=true; bool START_B3=true; bool START_S4=true; bool START_B4=true; bool START_S5=true; bool START_B5=true; double Lot45[12]; double Lot_M45[12]; int ticket_s[12]; int ticket_b[12]; int b=0; int s=0; int magic_1b=11311; int magic_b=11312; int magic_1s=21311; int magic_s=21312; double Profit_1s; double OP_1s; double Point_1s; double Profit_1b; double OP_1b; double Point_1b; double Profit_s; double Profit_b; double sprofit_x; double bprofit_x; double PS; double PB; int magic_1b2=12311; int magic_b2=12312; int magic_1s2=22311; int magic_s2=22312; int ticket_s2[12]; int ticket_b2[12]; int b2=0; int s2=0; double Profit_1s2; double OP_1s2; double Point_1s2; double Profit_1b2; double OP_1b2; double Point_1b2; double Profit_s2; double Profit_b2; double sprofit_x2; double bprofit_x2; double PS2; double PB2; int ticket_s3[12]; int ticket_b3[12]; int b3=0; int s3=0; int magic_1b3=13311; int magic_b3=13312; int magic_1s3=23311; int magic_s3=23312; double Profit_1s3; double OP_1s3; double Point_1s3; double Profit_1b3; double OP_1b3; double Point_1b3; double Profit_s3; double Profit_b3; double sprofit_x3; double bprofit_x3; double PS3; double PB3; int ticket_s4[12]; int ticket_b4[12]; int b4=0; int s4=0; int magic_1b4=14311; int magic_b4=14312; int magic_1s4=24311; int magic_s4=24312; double Profit_1s4; double OP_1s4; double Point_1s4; double Profit_1b4; double OP_1b4; double Point_1b4; double Profit_s4; double Profit_b4; double sprofit_x4; double bprofit_x4; double PS4; double PB4; int ticket_s5[12]; int ticket_b5[12]; int b5=0; int s5=0; int magic_1b5=15311; int magic_b5=15312; int magic_1s5=25311; int magic_s5=25312; double Profit_1s5; double OP_1s5; double Point_1s5; double Profit_1b5; double OP_1b5; double Point_1b5; double Profit_s5; double Profit_b5; double sprofit_x5; double bprofit_x5; double PS5; double PB5; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- END2=END*L; open_i[1] = open; open_i[2] = open; open_i[3] = (open_i[2]*(-1))+z; open_i[4] = (open_i[3]*(-1))-z; open_i[5] = (open_i[4]*(-1))+z; open_i[6] = (open_i[5]*(-1))-z; open_i[7] = (open_i[6]*(-1))+z; open_i[8] = (open_i[7]*(-1))-z; open_i[9] = (open_i[8]*(-1))+z; open_i[10]= (open_i[9]*(-1))-z; open_i[11]= (open_i[10]*(-1))+z; Lot[1] = Lots_1; Lot[2] = Lots_2; Lot[3] = Lots_3; Lot[4] = Lots_4; Lot[5] = Lots_5; Lot[6] = Lots_6; Lot[7] = Lots_7; Lot[8] = Lots_8; Lot[9] = Lots_9; Lot[10] = Lots_10; Lot[11] = Lots_11; Lot[12] = Lots_10; Lot_M[0] = 1; Lot_M[1] = Lots_1; Lot_M[3] = (Lots_1+Lots_3 -Lots_2)*10; Lot_M[5] = (Lots_1+Lots_3+Lots_5 -Lots_2+Lots_4)*10; Lot_M[7] = (Lots_1+Lots_3+Lots_5+Lots_7 -Lots_2+Lots_4+Lots_6)*10; Lot_M[9] = (Lots_1+Lots_3+Lots_5+Lots_7+Lots_9 -Lots_2+Lots_4+Lots_6+Lots_8)*10; Lot_M[11]= (Lots_1+Lots_3+Lots_5+Lots_7+Lots_9+Lots_11-Lots_2+Lots_4+Lots_6+Lots_8+Lots_10)*10; Lot_M[2] = (Lots_2 -Lots_1)*10; Lot_M[4] = (Lots_2+Lots_4 -Lots_1+Lots_3)*10; Lot_M[6] = (Lots_2+Lots_4+Lots_6 -Lots_1+Lots_3+Lots_5)*10; Lot_M[8] = (Lots_2+Lots_4+Lots_6+Lots_8 -Lots_1+Lots_3+Lots_5+Lots_7)*10; Lot_M[10]= (Lots_2+Lots_4+Lots_6+Lots_8+Lots_10 -Lots_1+Lots_3+Lots_5+Lots_7+Lots_9)*10; Lot_M[12]= (Lots_2+Lots_4+Lots_6+Lots_8+Lots_10+Lots_12-Lots_1+Lots_3+Lots_5+Lots_7+Lots_9+Lots_11)*10; Lot45[1] =NormalizeDouble(( Lots_1*L),r); if(Lot45[1]<=0) Lot45[1] = Lots_1; if(Lot45[1]>Lots_MAX) Lot45[1] = Lots_MAX; Lot45[2] =NormalizeDouble(( Lots_2*L),r); if(Lot45[2]<=0) Lot45[2] = Lot45[1]; if(Lot45[2]>Lots_MAX) Lot45[2] = Lots_MAX; Lot45[3] =NormalizeDouble(( Lots_3*L),r); if(Lot45[3]<=0) Lot45[3] = Lot45[1]; if(Lot45[3]>Lots_MAX) Lot45[3] = Lots_MAX; Lot45[4] =NormalizeDouble(( Lots_4*L),r); if(Lot45[4]<=0) Lot45[4] = Lot45[1]; if(Lot45[4]>Lots_MAX) Lot45[4] = Lots_MAX; Lot45[5] =NormalizeDouble(( Lots_5*L),r); if(Lot45[5]<=0) Lot45[5] = Lot45[1]; if(Lot45[5]>Lots_MAX) Lot45[5] = Lots_MAX; Lot45[6] =NormalizeDouble(( Lots_6*L),r); if(Lot45[6]<=0) Lot45[6] = Lot45[1]; if(Lot45[6]>Lots_MAX) Lot45[6] = Lots_MAX; Lot45[7] =NormalizeDouble(( Lots_7*L),r); if(Lot45[7]<=0) Lot45[7] = Lot45[1]; if(Lot45[7]>Lots_MAX) Lot45[7] = Lots_MAX; Lot45[8] =NormalizeDouble(( Lots_8*L),r); if(Lot45[8]<=0) Lot45[8] = Lot45[1]; if(Lot45[8]>Lots_MAX) Lot45[8] = Lots_MAX; Lot45[9] =NormalizeDouble(( Lots_9*L),r); if(Lot45[9]<=0) Lot45[9] = Lot45[1]; if(Lot45[9]>Lots_MAX) Lot45[9] = Lots_MAX; Lot45[10] =NormalizeDouble(( Lots_10*L),r); if(Lot45[10]<=0) Lot45[10] = Lot45[1]; if(Lot45[10]>Lots_MAX) Lot45[10] = Lots_MAX; Lot45[11] =NormalizeDouble(( Lots_11*L),r); if(Lot45[11]<=0) Lot45[11] = Lot45[1]; if(Lot45[11]>Lots_MAX) Lot45[11] = Lots_MAX; Lot45[12] =NormalizeDouble(( Lots_12*L),r); if(Lot45[12]<=0) Lot45[12] = Lot45[1]; if(Lot45[12]>Lots_MAX) Lot45[12] = Lots_MAX; Lot_M45[0] = 1; Lot_M45[1] = Lot45[1]; Lot_M45[3] = (Lot45[1]+Lot45[3] -Lot45[2])*10; Lot_M45[5] = (Lot45[1]+Lot45[3]+Lot45[5] -Lot45[2]+Lot45[4])*10; Lot_M45[7] = (Lot45[1]+Lot45[3]+Lot45[5]+Lot45[7] -Lot45[2]+Lot45[4]+Lot45[6])*10; Lot_M45[9] = (Lot45[1]+Lot45[3]+Lot45[5]+Lot45[7]+Lot45[9] -Lot45[2]+Lot45[4]+Lot45[6]+Lot45[8])*10; Lot_M45[11]= (Lot45[1]+Lot45[3]+Lot45[5]+Lot45[7]+Lot45[9]+Lot45[11]-Lot45[2]+Lot45[4]+Lot45[6]+Lot45[8]+Lot45[10])*10; Lot_M45[2] = (Lot45[2] -Lot45[1])*10; Lot_M45[4] = (Lot45[2]+Lot45[4] -Lot45[1]+Lot45[3])*10; Lot_M45[6] = (Lot45[2]+Lot45[4]+Lot45[6] -Lot45[1]+Lot45[3]+Lot45[5])*10; Lot_M45[8] = (Lot45[2]+Lot45[4]+Lot45[6]+Lot45[8] -Lot45[1]+Lot45[3]+Lot45[5]+Lot45[7])*10; Lot_M45[10]= (Lot45[2]+Lot45[4]+Lot45[6]+Lot45[8]+Lot45[10] -Lot45[1]+Lot45[3]+Lot45[5]+Lot45[7]+Lot45[9])*10; Lot_M45[12]= (Lot45[2]+Lot45[4]+Lot45[6]+Lot45[8]+Lot45[10]+Lot45[12]-Lot45[1]+Lot45[3]+Lot45[5]+Lot45[7]+Lot45[9]+Lot45[11])*10; profit_ALL[1]=12; profit_ALL[2]=Profit_2u; profit_ALL[3]=Profit_3u; profit_ALL[4]=Profit_4u; profit_ALL[5]=Profit_5u; profit_ALL[6]=Profit_6u; profit_ALL[7]=Profit_7u; profit_ALL[8]=Profit_8u; profit_ALL[9]=Profit_9u; profit_ALL[10]=Profit_10u; profit_ALL[11]=Profit_11u; profit_ALL[12]=Profit_12u; //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { s=0; b=0; Profit_s=0; Profit_b=0; s2=0; b2=0; Profit_s2=0; Profit_b2=0; s3=0; b3=0; Profit_s3=0; Profit_b3=0; s4=0; b4=0; Profit_s4=0; Profit_b4=0; s5=0; b5=0; Profit_s5=0; Profit_b5=0; for(int pos=OrdersTotal()-1;pos>=0;pos--) { if(OrderSelect(pos,SELECT_BY_POS,MODE_TRADES)==true) { if((OrderMagicNumber()==magic_1s)||(OrderMagicNumber()==magic_s)) { s=s+1; sprofit_x =OrderProfit( ); Profit_s =Profit_s+sprofit_x; } if((OrderMagicNumber()==magic_1b)||(OrderMagicNumber()==magic_b)) { b=b+1; bprofit_x =OrderProfit( ); Profit_b =Profit_b+bprofit_x; } if((OrderMagicNumber()==magic_1s2)||(OrderMagicNumber()==magic_s2)) { s2=s2+1; sprofit_x2 =OrderProfit( ); Profit_s2 =Profit_s2+sprofit_x2; } if((OrderMagicNumber()==magic_1b2)||(OrderMagicNumber()==magic_b2)) { b2=b2+1; bprofit_x2 =OrderProfit( ); Profit_b2 =Profit_b2+bprofit_x2; } if((OrderMagicNumber()==magic_1s3)||(OrderMagicNumber()==magic_s3)) { s3=s3+1; sprofit_x3 =OrderProfit( ); Profit_s3 =Profit_s3+sprofit_x3; } if((OrderMagicNumber()==magic_1b3)||(OrderMagicNumber()==magic_b3)) { b3=b3+1; bprofit_x3 =OrderProfit( ); Profit_b3 =Profit_b3+bprofit_x3; } if((OrderMagicNumber()==magic_1s4)||(OrderMagicNumber()==magic_s4)) { s4=s4+1; sprofit_x4 =OrderProfit( ); Profit_s4 =Profit_s4+sprofit_x4; } if((OrderMagicNumber()==magic_1b4)||(OrderMagicNumber()==magic_b4)) { b4=b4+1; bprofit_x4 =OrderProfit( ); Profit_b4 =Profit_b4+bprofit_x4; } if((OrderMagicNumber()==magic_1s5)||(OrderMagicNumber()==magic_s5)) { s5=s5+1; sprofit_x5 =OrderProfit( ); Profit_s5 =Profit_s5+sprofit_x5; } if((OrderMagicNumber()==magic_1b5)||(OrderMagicNumber()==magic_b5)) { b5=b5+1; bprofit_x5 =OrderProfit( ); Profit_b5 =Profit_b5+bprofit_x5; } } } //------- SELL ----------------------------------------------------------------------------------------------------------------------------------------------- if(START_S==true && s==0)ticket_s[1]=OrderSend(Symbol(),OP_SELL,Lots_1,NormalizeDouble(Bid,Digits),NULL,0,0,NULL,magic_1s,NULL,Yellow); for( pos=OrdersTotal()-1;pos>=0;pos--) { if(OrderSelect(pos,SELECT_BY_POS,MODE_TRADES)==true && OrderMagicNumber()==magic_1s && OrderType()==1 && OrderSymbol()==Symbol()&& OrderLots()==Lots_1) { Profit_1s=OrderProfit(); OP_1s= OrderOpenPrice(); Point_1s=(OP_1s-Ask)*100; if(Point_1s>profit_1 && s==1) { OrderClose(OrderTicket(),OrderLots(),Ask,NULL,Green); } } } if((s==1)||(s==3)||(s==5)||(s==7)||(s==9)||(s==11)) { if(Point_1sopen_i[s+1])ticket_s[1+s]=OrderSend(Symbol(),OP_SELL,Lot[s+1],NormalizeDouble(Bid,Digits),NULL,0,0,NULL,magic_s,NULL,Yellow); } PS=Profit_s/Lot_M[s]; if(s>1) { for(pos=OrdersTotal()-1;pos>=0;pos--) { if((PS>profit_ALL[s])||(END>Profit_s)) { if((OrderSelect(pos,SELECT_BY_POS,MODE_TRADES)==true && OrderMagicNumber()==magic_s && OrderType()==1 && OrderSymbol()==Symbol())||(OrderSelect(pos,SELECT_BY_POS,MODE_TRADES)==true && OrderMagicNumber()==magic_1s && OrderType()==1 && OrderSymbol()==Symbol())) { OrderClose(OrderTicket(),OrderLots(),Ask,NULL,Green); } if(OrderSelect(pos,SELECT_BY_POS,MODE_TRADES)==true && OrderMagicNumber()==magic_s && OrderType()==0 && OrderSymbol()==Symbol()) { OrderClose(OrderTicket(),OrderLots(),Bid,NULL,Green); } } } } //-------BUY ----------------------------------------------------------------------------------------------------------------------------------------------- if(START_B==true && b==0)ticket_b[1]=OrderSend(Symbol(),OP_BUY,Lots_1,NormalizeDouble(Ask,Digits),NULL,0,0,NULL,magic_1b,NULL,clrRed); for( pos=OrdersTotal()-1;pos>=0;pos--) { if(OrderSelect(pos,SELECT_BY_POS,MODE_TRADES)==true && OrderMagicNumber()==magic_1b && OrderType()==0 && OrderSymbol()==Symbol()&& OrderLots()==Lots_1) { Profit_1b=OrderProfit(); OP_1b= OrderOpenPrice(); Point_1b=(Bid-OP_1b)*100; if(Point_1b>profit_1 && b==1) { OrderClose(OrderTicket(),OrderLots(),Bid,NULL,Green); } } } if((b==1)||(b==3)||(b==5)||(b==7)||(b==9)||(b==11)) { if(Point_1bopen_i[b+1])ticket_b[1+b]=OrderSend(Symbol(),OP_BUY,Lot[b+1],NormalizeDouble(Ask,Digits),NULL,0,0,NULL,magic_b,NULL,clrRed); } PB=Profit_b/Lot_M[b]; if(b>1) { for(pos=OrdersTotal()-1;pos>=0;pos--) { if((PB>profit_ALL[b])||(END>Profit_b)) { if((OrderSelect(pos,SELECT_BY_POS,MODE_TRADES)==true && OrderMagicNumber()==magic_b && OrderType()==0 && OrderSymbol()==Symbol())||(OrderSelect(pos,SELECT_BY_POS,MODE_TRADES)==true && OrderMagicNumber()==magic_1b && OrderType()==0 && OrderSymbol()==Symbol())) { OrderClose(OrderTicket(),OrderLots(),Bid,NULL,Green); } if(OrderSelect(pos,SELECT_BY_POS,MODE_TRADES)==true && OrderMagicNumber()==magic_b && OrderType()==1 && OrderSymbol()==Symbol()) { OrderClose(OrderTicket(),OrderLots(),Ask,NULL,Green); } } } } //----------------------------------------------------------------------------------------------------------------------------------------------------------- //------- 2 ------------------------------------------------------------------------------------------------------------------------------------------------ //----------------------------------------------------------------------------------------------------------------------------------------------------------- //------- SELL ----------------------------------------------------------------------------------------------------------------------------------------------- if(START_S2==true && s2==0 && s==3 && Point_1s>-2 && Point_1s<2)ticket_s2[1]=OrderSend(Symbol(),OP_SELL,Lots_1,NormalizeDouble(Bid,Digits),NULL,0,0,NULL,magic_1s2,NULL,Yellow); for( pos=OrdersTotal()-1;pos>=0;pos--) { if(OrderSelect(pos,SELECT_BY_POS,MODE_TRADES)==true && OrderMagicNumber()==magic_1s2 && OrderType()==1 && OrderSymbol()==Symbol()&& OrderLots()==Lots_1) { Profit_1s2=OrderProfit(); OP_1s2= OrderOpenPrice(); Point_1s2=(OP_1s2-Ask)*100; if(Point_1s2>profit_1 && s2==1) { OrderClose(OrderTicket(),OrderLots(),Ask,NULL,Green); } } } if((s2==1)||(s2==3)||(s2==5)||(s2==7)||(s2==9)||(s2==11)) { if(Point_1s2open_i[s2+1])ticket_s2[1+s2]=OrderSend(Symbol(),OP_SELL,Lot[s2+1],NormalizeDouble(Bid,Digits),NULL,0,0,NULL,magic_s2,NULL,Yellow); } PS2=Profit_s2/Lot_M[s2]; if(START_S2==true && s2>1) { for(pos=OrdersTotal()-1;pos>=0;pos--) { if((PS2>profit_ALL[s2])||(END>Profit_s2)) { if((OrderSelect(pos,SELECT_BY_POS,MODE_TRADES)==true && OrderMagicNumber()==magic_s2 && OrderType()==1 && OrderSymbol()==Symbol())||(OrderSelect(pos,SELECT_BY_POS,MODE_TRADES)==true && OrderMagicNumber()==magic_1s2 && OrderType()==1 && OrderSymbol()==Symbol())) { OrderClose(OrderTicket(),OrderLots(),Ask,NULL,Green); } if(OrderSelect(pos,SELECT_BY_POS,MODE_TRADES)==true && OrderMagicNumber()==magic_s2 && OrderType()==0 && OrderSymbol()==Symbol()) { OrderClose(OrderTicket(),OrderLots(),Bid,NULL,Green); } } } } //-------BUY ----------------------------------------------------------------------------------------------------------------------------------------------- if(START_B2==true && b2==0 && b==3 && Point_1b>-2 && Point_1b<2)ticket_b2[1]=OrderSend(Symbol(),OP_BUY,Lots_1,NormalizeDouble(Ask,Digits),NULL,0,0,NULL,magic_1b2,NULL,clrRed); for( pos=OrdersTotal()-1;pos>=0;pos--) { if(OrderSelect(pos,SELECT_BY_POS,MODE_TRADES)==true && OrderMagicNumber()==magic_1b2 && OrderType()==0 && OrderSymbol()==Symbol()&& OrderLots()==Lots_1) { Profit_1b2=OrderProfit(); OP_1b2= OrderOpenPrice(); Point_1b2=(Bid-OP_1b2)*100; if(Point_1b2>profit_1 && b2==1) { OrderClose(OrderTicket(),OrderLots(),Bid,NULL,Green); } } } if((b2==1)||(b2==3)||(b2==5)||(b2==7)||(b2==9)||(b2==11)) { if(Point_1b2open_i[b2+1])ticket_b2[1+b2]=OrderSend(Symbol(),OP_BUY,Lot[b2+1],NormalizeDouble(Ask,Digits),NULL,0,0,NULL,magic_b2,NULL,clrRed); } PB2=Profit_b2/Lot_M[b2]; if(START_B2==true && b2>1) { for(pos=OrdersTotal()-1;pos>=0;pos--) { if((PB2>profit_ALL[b2])||(END>Profit_b2)) { if((OrderSelect(pos,SELECT_BY_POS,MODE_TRADES)==true && OrderMagicNumber()==magic_b2 && OrderType()==0 && OrderSymbol()==Symbol())||(OrderSelect(pos,SELECT_BY_POS,MODE_TRADES)==true && OrderMagicNumber()==magic_1b2 && OrderType()==0 && OrderSymbol()==Symbol())) { OrderClose(OrderTicket(),OrderLots(),Bid,NULL,Green); } if(OrderSelect(pos,SELECT_BY_POS,MODE_TRADES)==true && OrderMagicNumber()==magic_b2 && OrderType()==1 && OrderSymbol()==Symbol()) { OrderClose(OrderTicket(),OrderLots(),Ask,NULL,Green); } } } } //----------------------------------------------------------------------------------------------------------------------------------------------------------- //------- 3 ------------------------------------------------------------------------------------------------------------------------------------------------ //----------------------------------------------------------------------------------------------------------------------------------------------------------- //------- SELL ----------------------------------------------------------------------------------------------------------------------------------------------- if(START_S3==true && s3==0 && s2==2 && Point_1s2>-2 && Point_1s2<2)ticket_s3[1]=OrderSend(Symbol(),OP_SELL,Lot45[1],NormalizeDouble(Bid,Digits),NULL,0,0,NULL,magic_1s3,NULL,Yellow); for( pos=OrdersTotal()-1;pos>=0;pos--) { if(OrderSelect(pos,SELECT_BY_POS,MODE_TRADES)==true && OrderMagicNumber()==magic_1s3 && OrderType()==1 && OrderSymbol()==Symbol()&& OrderLots()==Lot45[1]) { Profit_1s3=OrderProfit(); OP_1s3= OrderOpenPrice(); Point_1s3=(OP_1s3-Ask)*100; if(Point_1s3>profit_1 && s3==1) { OrderClose(OrderTicket(),OrderLots(),Ask,NULL,Green); } } } if((s3==1)||(s3==3)||(s3==5)||(s3==7)||(s3==9)||(s3==11)) { if(Point_1s3open_i[s3+1])ticket_s3[1+s3]=OrderSend(Symbol(),OP_SELL,Lot45[s3+1],NormalizeDouble(Bid,Digits),NULL,0,0,NULL,magic_s3,NULL,Yellow); } PS3=Profit_s3/Lot_M45[s3]; if(s3>1) { for(pos=OrdersTotal()-1;pos>=0;pos--) { if((PS3>profit_ALL[s3])||(END2>Profit_s3)) { if((OrderSelect(pos,SELECT_BY_POS,MODE_TRADES)==true && OrderMagicNumber()==magic_s3 && OrderType()==1 && OrderSymbol()==Symbol())||(OrderSelect(pos,SELECT_BY_POS,MODE_TRADES)==true && OrderMagicNumber()==magic_1s3 && OrderType()==1 && OrderSymbol()==Symbol())) { OrderClose(OrderTicket(),OrderLots(),Ask,NULL,Green); } if(OrderSelect(pos,SELECT_BY_POS,MODE_TRADES)==true && OrderMagicNumber()==magic_s3 && OrderType()==0 && OrderSymbol()==Symbol()) { OrderClose(OrderTicket(),OrderLots(),Bid,NULL,Green); } } } } //-------BUY ----------------------------------------------------------------------------------------------------------------------------------------------- if(START_B3==true && b3==0 && b2==2 && Point_1b2>-2 && Point_1b2<2)ticket_b3[1]=OrderSend(Symbol(),OP_BUY,Lot45[1],NormalizeDouble(Ask,Digits),NULL,0,0,NULL,magic_1b3,NULL,clrRed); for( pos=OrdersTotal()-1;pos>=0;pos--) { if(OrderSelect(pos,SELECT_BY_POS,MODE_TRADES)==true && OrderMagicNumber()==magic_1b3 && OrderType()==0 && OrderSymbol()==Symbol()&& OrderLots()==Lot45[1]) { Profit_1b3=OrderProfit(); OP_1b3= OrderOpenPrice(); Point_1b3=(Bid-OP_1b3)*100; if(Point_1b3>profit_1 && b3==1) { OrderClose(OrderTicket(),OrderLots(),Bid,NULL,Green); } } } if((b3==1)||(b3==3)||(b3==5)||(b3==7)||(b3==9)||(b3==11)) { if(Point_1b3open_i[b3+1])ticket_b3[1+b3]=OrderSend(Symbol(),OP_BUY,Lot45[b3+1],NormalizeDouble(Ask,Digits),NULL,0,0,NULL,magic_b3,NULL,clrRed); } PB3=Profit_b3/Lot_M45[b3]; if(b3>1) { for(pos=OrdersTotal()-1;pos>=0;pos--) { if((PB3>profit_ALL[b3])||(END2>Profit_b3)) { if((OrderSelect(pos,SELECT_BY_POS,MODE_TRADES)==true && OrderMagicNumber()==magic_b3 && OrderType()==0 && OrderSymbol()==Symbol())||(OrderSelect(pos,SELECT_BY_POS,MODE_TRADES)==true && OrderMagicNumber()==magic_1b3 && OrderType()==0 && OrderSymbol()==Symbol())) { OrderClose(OrderTicket(),OrderLots(),Bid,NULL,Green); } if(OrderSelect(pos,SELECT_BY_POS,MODE_TRADES)==true && OrderMagicNumber()==magic_b3 && OrderType()==1 && OrderSymbol()==Symbol()) { OrderClose(OrderTicket(),OrderLots(),Ask,NULL,Green); } } } } //----------------------------------------------------------------------------------------------------------------------------------------------------------- //------- 4 ------------------------------------------------------------------------------------------------------------------------------------------------ //----------------------------------------------------------------------------------------------------------------------------------------------------------- //------- SELL ----------------------------------------------------------------------------------------------------------------------------------------------- if(START_S4==true && s4==0 && s3==2 && Point_1s3>-2 && Point_1s3<2)ticket_s4[1]=OrderSend(Symbol(),OP_SELL,Lot45[1],NormalizeDouble(Bid,Digits),NULL,0,0,NULL,magic_1s4,NULL,Yellow); for( pos=OrdersTotal()-1;pos>=0;pos--) { if(OrderSelect(pos,SELECT_BY_POS,MODE_TRADES)==true && OrderMagicNumber()==magic_1s4 && OrderType()==1 && OrderSymbol()==Symbol()&& OrderLots()==Lot45[1]) { Profit_1s4=OrderProfit(); OP_1s4= OrderOpenPrice(); Point_1s4=(OP_1s4-Ask)*100; if(Point_1s4>profit_1 && s4==1) { OrderClose(OrderTicket(),OrderLots(),Ask,NULL,Green); } } } if((s4==1)||(s4==3)||(s4==5)||(s4==7)||(s4==9)||(s4==11)) { if(Point_1s4open_i[s4+1])ticket_s4[1+s4]=OrderSend(Symbol(),OP_SELL,Lot45[s4+1],NormalizeDouble(Bid,Digits),NULL,0,0,NULL,magic_s4,NULL,Yellow); } PS4=Profit_s4/Lot_M45[s4]; if(s4>1) { for(pos=OrdersTotal()-1;pos>=0;pos--) { if((PS4>profit_ALL[s4])||(END2>Profit_s4)) { if((OrderSelect(pos,SELECT_BY_POS,MODE_TRADES)==true && OrderMagicNumber()==magic_s4 && OrderType()==1 && OrderSymbol()==Symbol())||(OrderSelect(pos,SELECT_BY_POS,MODE_TRADES)==true && OrderMagicNumber()==magic_1s4 && OrderType()==1 && OrderSymbol()==Symbol())) { OrderClose(OrderTicket(),OrderLots(),Ask,NULL,Green); } if(OrderSelect(pos,SELECT_BY_POS,MODE_TRADES)==true && OrderMagicNumber()==magic_s4 && OrderType()==0 && OrderSymbol()==Symbol()) { OrderClose(OrderTicket(),OrderLots(),Bid,NULL,Green); } } } } //-------BUY ----------------------------------------------------------------------------------------------------------------------------------------------- if(START_B4==true && b4==0 && b3==2 && Point_1b3>-2 && Point_1b3<2)ticket_b4[1]=OrderSend(Symbol(),OP_BUY,Lot45[1],NormalizeDouble(Ask,Digits),NULL,0,0,NULL,magic_1b4,NULL,clrRed); for( pos=OrdersTotal()-1;pos>=0;pos--) { if(OrderSelect(pos,SELECT_BY_POS,MODE_TRADES)==true && OrderMagicNumber()==magic_1b4 && OrderType()==0 && OrderSymbol()==Symbol()&& OrderLots()==Lot45[1]) { Profit_1b4=OrderProfit(); OP_1b4= OrderOpenPrice(); Point_1b4=(Bid-OP_1b4)*100; if(Point_1b4>profit_1 && b4==1) { OrderClose(OrderTicket(),OrderLots(),Bid,NULL,Green); } } } if((b4==1)||(b4==3)||(b4==5)||(b4==7)||(b4==9)||(b4==11)) { if(Point_1b4open_i[b4+1])ticket_b4[1+b4]=OrderSend(Symbol(),OP_BUY,Lot45[b4+1],NormalizeDouble(Ask,Digits),NULL,0,0,NULL,magic_b4,NULL,clrRed); } PB4=Profit_b4/Lot_M45[b4]; if(b4>1) { for(pos=OrdersTotal()-1;pos>=0;pos--) { if((PB4>profit_ALL[b4])||(END2>Profit_b4)) { if((OrderSelect(pos,SELECT_BY_POS,MODE_TRADES)==true && OrderMagicNumber()==magic_b4 && OrderType()==0 && OrderSymbol()==Symbol())||(OrderSelect(pos,SELECT_BY_POS,MODE_TRADES)==true && OrderMagicNumber()==magic_1b4 && OrderType()==0 && OrderSymbol()==Symbol())) { OrderClose(OrderTicket(),OrderLots(),Bid,NULL,Green); } if(OrderSelect(pos,SELECT_BY_POS,MODE_TRADES)==true && OrderMagicNumber()==magic_b4 && OrderType()==1 && OrderSymbol()==Symbol()) { OrderClose(OrderTicket(),OrderLots(),Ask,NULL,Green); } } } } //----------------------------------------------------------------------------------------------------------------------------------------------------------- //------- 5 ------------------------------------------------------------------------------------------------------------------------------------------------ //----------------------------------------------------------------------------------------------------------------------------------------------------------- //------- SELL ----------------------------------------------------------------------------------------------------------------------------------------------- if(START_S5==true && s5==0 && s4==2 && Point_1s4>-2 && Point_1s4<2)ticket_s5[1]=OrderSend(Symbol(),OP_SELL,Lot45[1],NormalizeDouble(Bid,Digits),NULL,0,0,NULL,magic_1s5,NULL,Yellow); for( pos=OrdersTotal()-1;pos>=0;pos--) { if(OrderSelect(pos,SELECT_BY_POS,MODE_TRADES)==true && OrderMagicNumber()==magic_1s5 && OrderType()==1 && OrderSymbol()==Symbol()&& OrderLots()==Lot45[1]) { Profit_1s5=OrderProfit(); OP_1s5= OrderOpenPrice(); Point_1s5=(OP_1s5-Ask)*100; if(Point_1s5>profit_1 && s5==1) { OrderClose(OrderTicket(),OrderLots(),Ask,NULL,Green); } } } if((s5==1)||(s5==3)||(s5==5)||(s5==7)||(s5==9)||(s5==11)) { if(Point_1s5open_i[s5+1])ticket_s5[1+s5]=OrderSend(Symbol(),OP_SELL,Lot45[s5+1],NormalizeDouble(Bid,Digits),NULL,0,0,NULL,magic_s5,NULL,Yellow); } PS5=Profit_s5/Lot_M45[s5]; if(s5>1) { for(pos=OrdersTotal()-1;pos>=0;pos--) { if((PS5>profit_ALL[s5])||(END2>Profit_s5)) { if((OrderSelect(pos,SELECT_BY_POS,MODE_TRADES)==true && OrderMagicNumber()==magic_s5 && OrderType()==1 && OrderSymbol()==Symbol())||(OrderSelect(pos,SELECT_BY_POS,MODE_TRADES)==true && OrderMagicNumber()==magic_1s5 && OrderType()==1 && OrderSymbol()==Symbol())) { OrderClose(OrderTicket(),OrderLots(),Ask,NULL,Green); } if(OrderSelect(pos,SELECT_BY_POS,MODE_TRADES)==true && OrderMagicNumber()==magic_s5 && OrderType()==0 && OrderSymbol()==Symbol()) { OrderClose(OrderTicket(),OrderLots(),Bid,NULL,Green); } } } } //-------BUY ----------------------------------------------------------------------------------------------------------------------------------------------- if(START_B5==true && b5==0 && b4==2 && Point_1b4>-2 && Point_1b4<2)ticket_b5[1]=OrderSend(Symbol(),OP_BUY,Lot45[1],NormalizeDouble(Ask,Digits),NULL,0,0,NULL,magic_1b5,NULL,clrRed); for( pos=OrdersTotal()-1;pos>=0;pos--) { if(OrderSelect(pos,SELECT_BY_POS,MODE_TRADES)==true && OrderMagicNumber()==magic_1b5 && OrderType()==0 && OrderSymbol()==Symbol()&& OrderLots()==Lot45[1]) { Profit_1b5=OrderProfit(); OP_1b5= OrderOpenPrice(); Point_1b5=(Bid-OP_1b5)*100; if(Point_1b5>profit_1 && b5==1) { OrderClose(OrderTicket(),OrderLots(),Bid,NULL,Green); } } } if((b5==1)||(b5==3)||(b5==5)||(b5==7)||(b5==9)||(b5==11)) { if(Point_1b5open_i[b5+1])ticket_b5[1+b5]=OrderSend(Symbol(),OP_BUY,Lot45[b5+1],NormalizeDouble(Ask,Digits),NULL,0,0,NULL,magic_b5,NULL,clrRed); } PB5=Profit_b5/Lot_M45[b5]; if(b5>1) { for(pos=OrdersTotal()-1;pos>=0;pos--) { if((PB5>profit_ALL[b5])||(END2>Profit_b5)) { if((OrderSelect(pos,SELECT_BY_POS,MODE_TRADES)==true && OrderMagicNumber()==magic_b5 && OrderType()==0 && OrderSymbol()==Symbol())||(OrderSelect(pos,SELECT_BY_POS,MODE_TRADES)==true && OrderMagicNumber()==magic_1b5 && OrderType()==0 && OrderSymbol()==Symbol())) { OrderClose(OrderTicket(),OrderLots(),Bid,NULL,Green); } if(OrderSelect(pos,SELECT_BY_POS,MODE_TRADES)==true && OrderMagicNumber()==magic_b5 && OrderType()==1 && OrderSymbol()==Symbol()) { OrderClose(OrderTicket(),OrderLots(),Ask,NULL,Green); } } } } //----------------------------------------------------------------------------------------------------------------------------------------------------------- string O_s= "os"; string O_b= "ob"; string O_s2= "os2"; string O_b2= "ob2"; string O_s3= "os3"; string O_b3= "ob3"; string O_s4= "os4"; string O_b4= "ob4"; string O_s5= "os5"; string O_b5= "ob5"; ObjectSetText(O_s, "S1="+s+" ÏÐÎÔÈÒ="+Profit_s,14, "Courier New", clrRed); if (ObjectFind(O_s) == -1) { ObjectCreate(O_s, OBJ_LABEL, 0, 0, 0); ObjectSet(O_s, OBJPROP_CORNER, 4); ObjectSet(O_s, OBJPROP_XDISTANCE, 10); ObjectSet(O_s, OBJPROP_YDISTANCE, 10); } if (s2==0) { ObjectSetText(O_s2, " " ,14, "Courier New", clrRed); if (ObjectFind(O_s2) == -1) { ObjectCreate(O_s2, OBJ_LABEL, 0, 0, 0); ObjectSet(O_s2, OBJPROP_CORNER, 4); ObjectSet(O_s2, OBJPROP_XDISTANCE, 10); ObjectSet(O_s2, OBJPROP_YDISTANCE, 30); } } if (s2>0) { ObjectSetText(O_s2, "S2="+s2+" ÏÐÎÔÈÒ="+Profit_s2,14, "Courier New", clrRed); if (ObjectFind(O_s2) == -1) { ObjectCreate(O_s2, OBJ_LABEL, 0, 0, 0); ObjectSet(O_s2, OBJPROP_CORNER, 4); ObjectSet(O_s2, OBJPROP_XDISTANCE, 10); ObjectSet(O_s2, OBJPROP_YDISTANCE, 30); } } if (s3==0) { ObjectSetText(O_s3, " " ,14, "Courier New", clrRed); if (ObjectFind(O_s3) == -1) { ObjectCreate(O_s3, OBJ_LABEL, 0, 0, 0); ObjectSet(O_s3, OBJPROP_CORNER, 4); ObjectSet(O_s3, OBJPROP_XDISTANCE, 10); ObjectSet(O_s3, OBJPROP_YDISTANCE, 50); } } if (s3>0) { ObjectSetText(O_s3, "S3="+s3+" ÏÐÎÔÈÒ="+Profit_s3,14, "Courier New", clrRed); if (ObjectFind(O_s3) == -1) { ObjectCreate(O_s3, OBJ_LABEL, 0, 0, 0); ObjectSet(O_s3, OBJPROP_CORNER, 4); ObjectSet(O_s3, OBJPROP_XDISTANCE, 10); ObjectSet(O_s3, OBJPROP_YDISTANCE, 50); } } if (s4==0) { ObjectSetText(O_s4, " " ,14, "Courier New", clrRed); if (ObjectFind(O_s4) == -1) { ObjectCreate(O_s4, OBJ_LABEL, 0, 0, 0); ObjectSet(O_s4, OBJPROP_CORNER, 4); ObjectSet(O_s4, OBJPROP_XDISTANCE, 10); ObjectSet(O_s4, OBJPROP_YDISTANCE, 70); } } if (s4>0) { ObjectSetText(O_s4, "S4="+s4+" ÏÐÎÔÈÒ="+Profit_s4,14, "Courier New", clrRed); if (ObjectFind(O_s4) == -1) { ObjectCreate(O_s4, OBJ_LABEL, 0, 0, 0); ObjectSet(O_s4, OBJPROP_CORNER, 4); ObjectSet(O_s4, OBJPROP_XDISTANCE, 10); ObjectSet(O_s4, OBJPROP_YDISTANCE, 70); } } if (s5==0) { ObjectSetText(O_s5, " " ,14, "Courier New", clrRed); if (ObjectFind(O_s5) == -1) { ObjectCreate(O_s5, OBJ_LABEL, 0, 0, 0); ObjectSet(O_s5, OBJPROP_CORNER, 4); ObjectSet(O_s5, OBJPROP_XDISTANCE, 10); ObjectSet(O_s5, OBJPROP_YDISTANCE, 90); } } if (s5>0) { ObjectSetText(O_s5, "S5="+s5+" ÏÐÎÔÈÒ="+Profit_s5,14, "Courier New", clrRed); if (ObjectFind(O_s5) == -1) { ObjectCreate(O_s5, OBJ_LABEL, 0, 0, 0); ObjectSet(O_s5, OBJPROP_CORNER, 4); ObjectSet(O_s5, OBJPROP_XDISTANCE, 10); ObjectSet(O_s5, OBJPROP_YDISTANCE, 90); } } ObjectSetText(O_b, "B1="+b+" ÏÐÎÔÈÒ="+Profit_b,14, "Courier New", clrYellow); if (ObjectFind(O_b) == -1) { ObjectCreate(O_b, OBJ_LABEL, 0, 0, 0); ObjectSet(O_b, OBJPROP_CORNER, 4); ObjectSet(O_b, OBJPROP_XDISTANCE, 250); ObjectSet(O_b, OBJPROP_YDISTANCE, 10); } if (b2==0) { ObjectSetText(O_b2, " " ,14, "Courier New", clrYellow); if (ObjectFind(O_b2) == -1) { ObjectCreate(O_b2, OBJ_LABEL, 0, 0, 0); ObjectSet(O_b2, OBJPROP_CORNER, 4); ObjectSet(O_b2, OBJPROP_XDISTANCE, 250); ObjectSet(O_b2, OBJPROP_YDISTANCE, 30); } } if (b2>0) { ObjectSetText(O_b2, "B2="+b2+" ÏÐÎÔÈÒ="+Profit_b2,14, "Courier New", clrYellow); if (ObjectFind(O_b2) == -1) { ObjectCreate(O_b2, OBJ_LABEL, 0, 0, 0); ObjectSet(O_b2, OBJPROP_CORNER, 4); ObjectSet(O_b2, OBJPROP_XDISTANCE, 250); ObjectSet(O_b2, OBJPROP_YDISTANCE, 30); } } if (b3==0) { ObjectSetText(O_b3, " " ,14, "Courier New", clrYellow); if (ObjectFind(O_b3) == -1) { ObjectCreate(O_b3, OBJ_LABEL, 0, 0, 0); ObjectSet(O_b3, OBJPROP_CORNER, 4); ObjectSet(O_b3, OBJPROP_XDISTANCE, 250); ObjectSet(O_b3, OBJPROP_YDISTANCE, 50); } } if (b3>0) { ObjectSetText(O_b3, "B3="+b3+" ÏÐÎÔÈÒ="+Profit_b3,14, "Courier New", clrYellow); if (ObjectFind(O_b3) == -1) { ObjectCreate(O_b3, OBJ_LABEL, 0, 0, 0); ObjectSet(O_b3, OBJPROP_CORNER, 4); ObjectSet(O_b3, OBJPROP_XDISTANCE, 250); ObjectSet(O_b3, OBJPROP_YDISTANCE, 50); } } if (b4==0) { ObjectSetText(O_b4, " " ,14, "Courier New", clrYellow); if (ObjectFind(O_b4) == -1) { ObjectCreate(O_b4, OBJ_LABEL, 0, 0, 0); ObjectSet(O_b4, OBJPROP_CORNER, 4); ObjectSet(O_b4, OBJPROP_XDISTANCE, 250); ObjectSet(O_b4, OBJPROP_YDISTANCE, 70); } } if (b4>0) { ObjectSetText(O_b4, "B4="+b4+" ÏÐÎÔÈÒ="+Profit_b4,14, "Courier New", clrYellow); if (ObjectFind(O_b4) == -1) { ObjectCreate(O_b4, OBJ_LABEL, 0, 0, 0); ObjectSet(O_b4, OBJPROP_CORNER, 4); ObjectSet(O_b4, OBJPROP_XDISTANCE, 250); ObjectSet(O_b4, OBJPROP_YDISTANCE, 70); } } if (b5==0) { ObjectSetText(O_b5, " " ,14, "Courier New", clrYellow); if (ObjectFind(O_b5) == -1) { ObjectCreate(O_b5, OBJ_LABEL, 0, 0, 0); ObjectSet(O_b5, OBJPROP_CORNER, 4); ObjectSet(O_b5, OBJPROP_XDISTANCE, 250); ObjectSet(O_b5, OBJPROP_YDISTANCE, 90); } } if (b5>0) { ObjectSetText(O_b5, "B5="+b5+" ÏÐÎÔÈÒ="+Profit_b5,14, "Courier New", clrYellow); if (ObjectFind(O_b5) == -1) { ObjectCreate(O_b5, OBJ_LABEL, 0, 0, 0); ObjectSet(O_b5, OBJPROP_CORNER, 4); ObjectSet(O_b5, OBJPROP_XDISTANCE, 250); ObjectSet(O_b5, OBJPROP_YDISTANCE, 90); } } } //+------------------------------------------------------------------+