//◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘ // ||||||||||||||||||||||||||||||||||| // || || // || Highlow EA - Mod || // || 22.10.2017 || // || || // ||||||||||||||||||||||||||||||||||| //◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘ enum iTrades { Both_Sides = 0, Only_Long = 1, Only_Short = 2, Stop_Work = 4 }; enum iOn_Off { Off = 0, On = 1 }; //◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘ string General_Settings = "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" ; iTrades Trades = 0 ; int MagicNumber = 540863443 ; string Lot_MM = "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" ; double Fix_Lot = 0.01 ; iOn_Off Auto_Lot = 1 ; int Currency = 0 ; string Main_Settings = "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" ; int MfT_b = 0 ; int CCF_b = 0 ; double POF_b = 0 ; int MfT_s = 0 ; int CCF_s = 0 ; double POF_s = 0 ; string SL_Settings = "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" ; int AR_CountBars_sl_b = 0 ; int AR_Percent_sl_b = 0 ; int AR_CountBars_sl_s = 0 ; int AR_Percent_sl_s = 0 ; string TS_Settings = "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" ; double T_Start_b = 0 ; double T_Step_b = 0 ; double T_Start_s = 0 ; double T_Step_s = 0 ; string Moving_EMA = "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" ; int EMA_Period_b = 0 ; int EMA_Period_s = 0 ; //◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘ datetime T=0,N=0;bool W=0,A=0;static int c=1;void OnInit(){T=iTime(Symbol(),PERIOD_D1,0); //◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘ if(Symbol()=="EURUSD") {MfT_b = 3 ; CCF_b = 0 ; POF_b = -0.7 ; AR_CountBars_sl_b = 32 ; AR_Percent_sl_b = 177 ; T_Start_b = 19.6 ; T_Step_b = 3.8 ; EMA_Period_b = 23 ; MfT_s = 1 ; CCF_s = 2 ; POF_s = -0.1 ; AR_CountBars_sl_s = 16 ; AR_Percent_sl_s = 187 ; T_Start_s = 9 ; T_Step_s = 9.8 ; EMA_Period_s = 3 ; Currency = 110; MagicNumber = 197569740;} if(Symbol()=="USDJPY") {MfT_b = 1 ; CCF_b = 2 ; POF_b = -0.3 ; AR_CountBars_sl_b = 36 ; AR_Percent_sl_b = 173 ; T_Start_b = 21.8 ; T_Step_b = 18.8 ; EMA_Period_b = 100 ; MfT_s = 1 ; CCF_s = 2 ; POF_s = 0.8 ; AR_CountBars_sl_s = 30 ; AR_Percent_sl_s = 68 ; T_Start_s = 6 ; T_Step_s = 2.2 ; EMA_Period_s = 0 ; Currency = 110; MagicNumber = 275600854;} if(Symbol()=="CADCHF") {MfT_b = 2 ; CCF_b = 0 ; POF_b = -1.4 ; AR_CountBars_sl_b = 48 ; AR_Percent_sl_b = 93 ; T_Start_b = 18.2 ; T_Step_b = 2.8 ; EMA_Period_b = 7 ; MfT_s = 3 ; CCF_s = 0 ; POF_s = 0.1 ; AR_CountBars_sl_s = 4 ; AR_Percent_sl_s = 156 ; T_Start_s = 8.4 ; T_Step_s = 22 ; EMA_Period_s = 18 ; Currency = 130; MagicNumber = 397563865;} if(Symbol()=="GBPUSD") {MfT_b = 1 ; CCF_b = 0 ; POF_b = 0 ; AR_CountBars_sl_b = 42 ; AR_Percent_sl_b = 62 ; T_Start_b = 2.2 ; T_Step_b = 15.6 ; EMA_Period_b = 72 ; MfT_s = 1 ; CCF_s = 2 ; POF_s = 0 ; AR_CountBars_sl_s = 6 ; AR_Percent_sl_s = 38 ; T_Start_s = 16.2 ; T_Step_s = 22 ; EMA_Period_s = 0 ; Currency = 120; MagicNumber = 471205553;} //◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘ if(Digits==3||Digits==5){POF_b*=10;POF_s*=10;T_Start_b*=10;T_Step_b*=10;T_Start_s*=10;T_Step_s*=10;}} void OnTick() { if(Bars<=AR_CountBars_sl_b)bool xb=0;else xb=1; if(Bars<=AR_CountBars_sl_s)bool xs=0;else xs=1; double EMA_b=iMA(Symbol(),PERIOD_D1,EMA_Period_b,0,MODE_EMA,PRICE_CLOSE,0); double EMA_s=iMA(Symbol(),PERIOD_D1,EMA_Period_s,0,MODE_EMA,PRICE_CLOSE,0); if(iTime(Symbol(),PERIOD_D1,0)>T)W=1; if(N!=iTime(Symbol(),PERIOD_D1,0)) {N=iTime(Symbol(),PERIOD_D1,0);if(COO()==0)A=0;} int E_b=0,E_s=0; if(Bid>=iHigh(Symbol(),PERIOD_D1,1)+POF_b*Point)E_b=1; if(Bid<=iLow (Symbol(),PERIOD_D1,1)-POF_b*Point)E_b=2; if(Bid>=iHigh(Symbol(),PERIOD_D1,1)+POF_s*Point)E_s=1; if(Bid<=iLow (Symbol(),PERIOD_D1,1)-POF_s*Point)E_s=2; int PC=0,BwC=0,SwC=0; if(iClose(Symbol(),PERIOD_D1,1)>iOpen(Symbol(),PERIOD_D1,1))PC=1; if(iClose(Symbol(),PERIOD_D1,1)iClose(Symbol(),PERIOD_D1,2)&&iOpen(Symbol(),PERIOD_D1,1)iClose(Symbol(),PERIOD_D1,1))GRM=2; if (COO()==0&&W==1&&A==0&&Trades!=4){ if(xb==1&&Trades!=2){ if(MfT_b==1&&E_b==1&&BwC==1&&EMA_Period_b==0 ){SendBuy();A=1;} if(MfT_b==2&&E_b==2&&BwC==1&&EMA_Period_b==0 ){SendBuy();A=1;} if(MfT_b==3&&E_b==1&&GRM==1&&EMA_Period_b==0 ){SendBuy();A=1;} if(MfT_b==1&&E_b==1&&BwC==1&&EMA_Period_b!=0&&Bid>EMA_b){SendBuy();A=1;} if(MfT_b==2&&E_b==2&&BwC==1&&EMA_Period_b!=0&&Bid>EMA_b){SendBuy();A=1;} if(MfT_b==3&&E_b==1&&GRM==1&&EMA_Period_b!=0&&Bid>EMA_b){SendBuy();A=1;}} if(xs==1&&Trades!=1){ if(MfT_s==1&&E_s==2&&SwC==1&&EMA_Period_s==0 ){SendSell();A=1;} if(MfT_s==2&&E_s==1&&SwC==1&&EMA_Period_s==0 ){SendSell();A=1;} if(MfT_s==3&&E_s==2&&GRM==2&&EMA_Period_s==0 ){SendSell();A=1;} if(MfT_s==1&&E_s==2&&SwC==1&&EMA_Period_s!=0&&BidMarketInfo(Symbol(),MODE_MAXLOT))l=MarketInfo(Symbol(),MODE_MAXLOT);return (l);} int COO() {int f=0;for(int s=OrdersTotal()-1;s>=0;s--){if(OrderSelect(s,SELECT_BY_POS,MODE_TRADES)) {if(OrderSymbol()==Symbol()&&OrderMagicNumber()==MagicNumber)f++;}}return(f);} void Trailing_b() {for(int i=OrdersTotal()-1;i>=0;i--){if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)){if(OrderSymbol()==Symbol()) {if(OrderType()==OP_BUY&&OrderMagicNumber()==MagicNumber){if(Bid-OrderOpenPrice()>T_Start_b*Point) {if(OrderStopLoss()=0;i--){if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)){if(OrderSymbol()==Symbol()) {if(OrderType()==OP_SELL&&OrderMagicNumber()==MagicNumber){if(OrderOpenPrice()-Ask>T_Start_s*Point) {if(OrderStopLoss()>Ask+(T_Start_s+T_Step_s)*Point||OrderStopLoss()==0) {bool ts=OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(Ask+T_Start_s*Point,Digits),0,0);}}}}}}} int AR_HighLow_sl_b() {int i;double hl=0;for(i=Bars;i>0;i--){if(AR_CountBars_sl_b>=i){hl+=MathAbs(High[i]-Low[i])/Point;}} double a=NormalizeDouble(hl/AR_CountBars_sl_b,0);double b=NormalizeDouble((a/100)*AR_Percent_sl_b,0);return(b);} int AR_HighLow_sl_s() {int i;double hl=0;for(i=Bars;i>0;i--){if(AR_CountBars_sl_s>=i){hl+=MathAbs(High[i]-Low[i])/Point;}} double a=NormalizeDouble(hl/AR_CountBars_sl_s,0);double b=NormalizeDouble((a/100)*AR_Percent_sl_s,0);return(b);} //◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘ /* Старые функции расчёта лота, включая режим парлай. extern string Arrange_Settings = "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" ; extern iOn_Off Parlay = 0 ; extern double Buster = 0 ; extern int Max_Orders = 0 ; extern string Lot_MM = "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" ; extern iOn_Off Auto_Lot_b = 0 ; extern iOn_Off Auto_Lot_s = 0 ; extern double Risk = 0 ; extern double Fix_Lot = 0.01 ; double Lot_b() {double l;if(Auto_Lot_b==0)l=Fix_Lot;if(Auto_Lot_b==1)l=NormalizeDouble((AccountEquity()/100*Risk)/AR_HighLow_sl_b(),2); if(Parlay==1){if(OrderSelect(OrderTiket(),SELECT_BY_TICKET)&&OrderProfit()>=0) {if(c=Max_Orders+1&&Auto_Lot_b==0){l=Fix_Lot;c=1;} if(c>=Max_Orders+1&&Auto_Lot_b==1){l=NormalizeDouble((AccountEquity()/100*Risk)/AR_HighLow_sl_b(),2);c=1;}} if(OrderSelect(OrderTiket(),SELECT_BY_TICKET)&&OrderProfit()<0){if(Auto_Lot_b==0){l=Fix_Lot;c=1;}if(Auto_Lot_b==1) {l=NormalizeDouble((AccountEquity()/100*Risk)/AR_HighLow_sl_b(),2);c=1;}}} if(lMarketInfo(Symbol(),MODE_MAXLOT))l=MarketInfo(Symbol(),MODE_MAXLOT);return (l);} double Lot_s() {double l;if(Auto_Lot_s==0)l=Fix_Lot;if(Auto_Lot_s==1)l=NormalizeDouble((AccountEquity()/100*Risk)/AR_HighLow_sl_s(),2); if(Parlay==1){if(OrderSelect(OrderTiket(),SELECT_BY_TICKET)&&OrderProfit()>=0) {if(c=Max_Orders+1&&Auto_Lot_s==0){l=Fix_Lot;c=1;} if(c>=Max_Orders+1&&Auto_Lot_s==1){l=NormalizeDouble((AccountEquity()/100*Risk)/AR_HighLow_sl_s(),2);c=1;}} if(OrderSelect(OrderTiket(),SELECT_BY_TICKET)&&OrderProfit()<0){if(Auto_Lot_s==0){l=Fix_Lot;c=1;} if(Auto_Lot_s==1){l=NormalizeDouble((AccountEquity()/100*Risk)/AR_HighLow_sl_s(),2);c=1;}}} if(lMarketInfo(Symbol(),MODE_MAXLOT))l=MarketInfo(Symbol(),MODE_MAXLOT);return(l);} int OrderTiket() {int a=0; datetime b=0; for(int i=OrdersHistoryTotal()-1;i>=0;i--) {if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)) {if(OrderSymbol()==Symbol()&&(OrderMagicNumber()==MagicNumber)&&OrderCloseTime()>b) {a=OrderTicket();b=OrderCloseTime();}}}return(a);} */ //◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘◘