FREENOTE
Sign up
Login
New paste
Home
Trending
Archive
English
English
Sign up
Login
New Paste
Browse
//+------------------------------------------------------------------+ //| ROBOT2.mq4 | //| TienHoang | //| lycachiba@gmail.com | //+------------------------------------------------------------------+ #property copyright "TienHoang---lycachiba@gmail.com" #property link "lycachiba@gmail.com" #property version "1.00" #property strict //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ input double Gapthep = 1; //Gap Lenh input int Truotgia = 10; // Truot Gia input int SpreadToida = 10; // Spread Toi Đa Đe Mo Lenh input bool MAM15 = True; //Mo Lenh chart M15 Theo MA int MAM151 = 7 ; int MAM152 = 14 ; int MAM153 = 56 ; input bool MAH1 = True; //Mo Lenh chart H1 Theo MA int MAH11 = 7 ; int MAH12 = 14 ; int MAH13 = 56 ; input bool MAH4 = True; //Mo Lenh chart H4 Theo MA int MAH41 = 7 ; int MAH42 = 14 ; int MAH43 = 86 ; input bool MACDM15 = False; //Mo Lenh chart M15 Theo MACD input bool MACDH1 = False; //Mo Lenh chart H1 Theo MACD input bool MACDH4 = False; //Mo Lenh chart H4 Theo MACD int Stop_Loss = 0; // Stop Loss (pips) int Take_Profit = 0; // Take Profit (pips) double khoiLuong; // lot int Magic_Number; int Magic_Number15 = 15; // Magic Number M15 int Magic_Number60 = 60; // Magic Number H1 int Magic_Number240 = 240; // Magic Number H4 string Com; string Com_M15 = (string)Symbol()+ " M15"; string Com_H1 = (string)Symbol()+ " H1"; string Com_H4 = (string)Symbol()+ " H4"; string Com_M151 = "+1 "+ (string)Symbol()+ " M15"; string Com_H11 = "+1 "+ (string)Symbol()+ " H1"; string Com_H41 = "+1 "+ (string)Symbol()+ " H4"; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { double Taikhoan = NormalizeDouble(accountBalance(),1); double Taikhoan2 = NormalizeDouble(accountEquity(),1); double lot = Lotsize(Symbol()); int solenh = Demsolenh(Symbol()); int solenh1 = DemsolenhM15(Symbol()); int solenh2 = DemsolenhH1(Symbol()); int solenh3 = DemsolenhH4(Symbol()); int solenh11 = DemsolenhM151(Symbol()); int solenh21 = DemsolenhH11(Symbol()); int solenh31 = DemsolenhH41(Symbol()); double lenhcuoiM15 = lenhcuoicungM15(Symbol()); double lenhcuoiH1 = lenhcuoicungH1(Symbol()); double lenhcuoiH4 = lenhcuoicungH4(Symbol()); int ticketm15 = OrderticketM15(Symbol()); int ticketm151 = OrderticketM151(Symbol()); int ticketh1 = OrderticketH1(Symbol()); int ticketh11 = OrderticketH11(Symbol()); int ticketh4 = OrderticketH4(Symbol()); int ticketh41 = OrderticketH41(Symbol()); double lotm15 = OrderlotM15(Symbol()); double lotm151 = OrderlotM151(Symbol()); double loth1 = OrderlotH1(Symbol()); double loth11 = OrderlotH11(Symbol()); double loth4 = OrderlotH4(Symbol()); double loth41 = OrderlotH41(Symbol()); // if(Taikhoan <1500){Alert("Tai khoan qua nho, rui ro cao");} Comment(" TAI KHOAN VON" + " = "+ (string)Taikhoan + "\n" + " TAI KHOAN HIEN TAI" + " = "+ (string)Taikhoan2 + "\n" + " LOT" + " = " +(string)lot + "\n" + " TONG SO LENH" + " = " +(string)solenh + "\n" + " SO LENH M15" + " = " +(string)solenh1 + "\n" + " SO LENH H1" + " = " +(string)solenh2+ "\n" + " SO LENH H4" + " = " +(string)solenh3+ "\n" + " SO LENH BU LO M15" + " = " +(string)solenh11 + "\n" + " SO LENH BU LO H1" + " = " +(string)solenh21+ "\n" + " SO LENH BU LO H4" + " = " +(string)solenh31+ "\n" + " LENH CUOI M15" + " = " +(string)lenhcuoiM15 + "\n" + " LENH CUOI H1" + " = " +(string)lenhcuoiH1+ "\n" + " LENH CUOI H4" + " = " +(string)lenhcuoiH4 + "\n" + " TICKET M15" + " = " +(string)ticketm15+ "\n" + " LOT M15" + " = " +(string)lotm15+ "\n" + " TICKET M151" + " = " +(string)ticketm151+ "\n" + " LOT M151" + " = " +(string)lotm151+ "\n" + " TICKET H1" + " = " +(string)ticketh1+ "\n" + " LOT H1" + " = " +(string)loth1+ "\n" + " TICKET H11" + " = " +(string)ticketh11+ "\n" + " LOT H11" + " = " +(string)loth11+ "\n" + " TICKET H4" + " = " +(string)ticketh4+ "\n" + " LOT H4" + " = " +(string)loth4+ "\n" + " TICKET H41" + " = " +(string)ticketh41+ "\n" + " LOT H41" + " = " +(string)loth41); //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ // OpenPositionM15(OP_BUY); // ClosePositionM15(OP_BUY); for(int a=0; a<=1; a++) { //+------------------------------------------------------------------+ //| M15 | //+------------------------------------------------------------------+ OpenM15(); OpenM151(); CloseM15(); CloseM151(); //+------------------------------------------------------------------+ //| H1 | //+------------------------------------------------------------------+ OpenH1(); OpenH11(); CloseH1(); CloseH11(); //+------------------------------------------------------------------+ //| H4 | //+------------------------------------------------------------------+ OpenH4(); OpenH41(); CloseH4(); CloseH41(); } Sleep(10000); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ double accountBalance() { double a=0; for(int i=0;i<1;i++) { a = AccountBalance(); } Sleep(1000); return(a); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ double accountEquity() { double b=0; for(int i=0;i<1;i++) { b = AccountEquity(); } Sleep(1000); return(b); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OpenM15() { for(int i=0;i<1;i++) { double MA1M151 = iMA(NULL,15,MAM151,0,MODE_SMA,PRICE_CLOSE,1); double MA2M151 = iMA(NULL,15,MAM151,0,MODE_SMA,PRICE_CLOSE,2); double MA3M151 = iMA(NULL,15,MAM151,0,MODE_SMA,PRICE_CLOSE,3); double MA1M152 = iMA(NULL,15,MAM152,0,MODE_SMA,PRICE_CLOSE,1); double MA2M152 = iMA(NULL,15,MAM152,0,MODE_SMA,PRICE_CLOSE,2); double MA3M152 = iMA(NULL,15,MAM152,0,MODE_SMA,PRICE_CLOSE,3); double MA1M153 = iMA(NULL,15,MAM153,0,MODE_SMA,PRICE_CLOSE,1); double MA2M153 = iMA(NULL,15,MAM153,0,MODE_SMA,PRICE_CLOSE,2); double MA3M153 = iMA(NULL,15,MAM153,0,MODE_SMA,PRICE_CLOSE,3); //======= double MACD1M15 = iMACD(NULL,15,12,26,9,PRICE_CLOSE,MODE_MAIN,1); double MACD2M15 = iMACD(NULL,15,12,26,9,PRICE_CLOSE,MODE_MAIN,2); double MACD3M15 = iMACD(NULL,15,12,26,9,PRICE_CLOSE,MODE_MAIN,3); double MACD1H1 = iMACD(NULL,60,12,26,9,PRICE_CLOSE,MODE_MAIN,1); double MACD2H1 = iMACD(NULL,60,12,26,9,PRICE_CLOSE,MODE_MAIN,2); double MACD3H1 = iMACD(NULL,60,12,26,9,PRICE_CLOSE,MODE_MAIN,3); bool MAM15tang = (MA1M151>MA1M153&&MA1M152>MA1M153); bool MAM15catlen = (MA1M151>MA1M152&&MA2M151<MA2M152); bool MAM15giam = (MA1M151<MA1M153&&MA1M152<MA1M153); bool MAM15catxuong = (MA1M151<MA1M152&&MA2M151>MA2M152); bool MACDH1lon = (MACD1H1>0); bool MACDM15catlen = (MACD1M15>0&&MACD2M15<0); bool MACDH1nho = (MACD1H1<0); bool MACDM15catxuong = (MACD1M15<0&&MACD2M15>0); if(MAM15 != False && MACDM15 != False) {continue;} if(MAM15 == False && MACDM15 == False) {continue;} if(MAM15 != False && MACDM15 == False) { if(MAM15tang != False && MAM15catlen != False) {OpenPositionM15(OP_BUY);} if(MAM15giam != False && MAM15catxuong != False) {OpenPositionM15(OP_SELL);} } else if(MACDM15 != False && MAM15 == False) { if(MACDH1lon != False && MACDM15catlen != False) {OpenPositionM15(OP_BUY);} if(MACDH1nho != False && MACDM15catxuong != False) {OpenPositionM15(OP_SELL);} } } Sleep(1000); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OpenM151() { for(int i=0;i<1;i++) { double MA1M151 = iMA(NULL,15,MAM151,0,MODE_SMA,PRICE_CLOSE,1); double MA2M151 = iMA(NULL,15,MAM151,0,MODE_SMA,PRICE_CLOSE,2); double MA3M151 = iMA(NULL,15,MAM151,0,MODE_SMA,PRICE_CLOSE,3); double MA1M152 = iMA(NULL,15,MAM152,0,MODE_SMA,PRICE_CLOSE,1); double MA2M152 = iMA(NULL,15,MAM152,0,MODE_SMA,PRICE_CLOSE,2); double MA3M152 = iMA(NULL,15,MAM152,0,MODE_SMA,PRICE_CLOSE,3); double MA1M153 = iMA(NULL,15,MAM153,0,MODE_SMA,PRICE_CLOSE,1); double MA2M153 = iMA(NULL,15,MAM153,0,MODE_SMA,PRICE_CLOSE,2); double MA3M153 = iMA(NULL,15,MAM153,0,MODE_SMA,PRICE_CLOSE,3); //========== double MACD1M15 = iMACD(NULL,15,12,26,9,PRICE_CLOSE,MODE_MAIN,1); double MACD2M15 = iMACD(NULL,15,12,26,9,PRICE_CLOSE,MODE_MAIN,2); double MACD3M15 = iMACD(NULL,15,12,26,9,PRICE_CLOSE,MODE_MAIN,3); double MACD1H1 = iMACD(NULL,60,12,26,9,PRICE_CLOSE,MODE_MAIN,1); double MACD2H1 = iMACD(NULL,60,12,26,9,PRICE_CLOSE,MODE_MAIN,2); double MACD3H1 = iMACD(NULL,60,12,26,9,PRICE_CLOSE,MODE_MAIN,3); bool MAM15tang = (MA1M151>MA1M153&&MA1M152>MA1M153); bool MAM15catlen = (MA1M151>MA1M152&&MA2M151<MA2M152); bool MAM15giam = (MA1M151<MA1M153&&MA1M152<MA1M153); bool MAM15catxuong = (MA1M151<MA1M152&&MA2M151>MA2M152); bool MACDH1lon = (MACD1H1>0); bool MACDM15catlen = (MACD1M15>0&&MACD2M15<0); bool MACDH1nho = (MACD1H1<0); bool MACDM15catxuong = (MACD1M15<0&&MACD2M15>0); if(MAM15 != False && MACDM15 != False) {continue;} if(MAM15 == False && MACDM15 == False) {continue;} if(MAM15 != False && MACDM15 == False) { if(MAM15tang != False && MAM15catlen != False) {OpenPositionM151(OP_BUY);} if(MAM15giam != False && MAM15catxuong != False) {OpenPositionM151(OP_SELL);} } else if(MACDM15 != False && MAM15 == False) { if(MACDH1lon != False && MACDM15catlen != False) {OpenPositionM151(OP_BUY);} if(MACDH1nho != False && MACDM15catxuong != False) {OpenPositionM151(OP_SELL);} } } Sleep(1000); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OpenH1() { for(int i=0;i<1;i++) { double MA1H11 = iMA(NULL,60,MAH11,0,MODE_SMA,PRICE_CLOSE,1); double MA2H11= iMA(NULL,60,MAH11,0,MODE_SMA,PRICE_CLOSE,2); double MA3H11 = iMA(NULL,60,MAH11,0,MODE_SMA,PRICE_CLOSE,3); double MA1H12 = iMA(NULL,60,MAH12,0,MODE_SMA,PRICE_CLOSE,1); double MA2H12 = iMA(NULL,60,MAH12,0,MODE_SMA,PRICE_CLOSE,2); double MA3H12 = iMA(NULL,60,MAH12,0,MODE_SMA,PRICE_CLOSE,3); double MA1H13 = iMA(NULL,60,MAH13,0,MODE_SMA,PRICE_CLOSE,1); double MA2H13 = iMA(NULL,60,MAH13,0,MODE_SMA,PRICE_CLOSE,2); double MA3H13 = iMA(NULL,60,MAH13,0,MODE_SMA,PRICE_CLOSE,3); //======== double MACD1H1 = iMACD(NULL,60,12,26,9,PRICE_CLOSE,MODE_MAIN,1); double MACD2H1 = iMACD(NULL,60,12,26,9,PRICE_CLOSE,MODE_MAIN,2); double MACD3H1 = iMACD(NULL,60,12,26,9,PRICE_CLOSE,MODE_MAIN,3); double MACD1H4 = iMACD(NULL,240,12,26,9,PRICE_CLOSE,MODE_MAIN,1); double MACD2H4 = iMACD(NULL,240,12,26,9,PRICE_CLOSE,MODE_MAIN,2); double MACD3H4 = iMACD(NULL,240,12,26,9,PRICE_CLOSE,MODE_MAIN,3); bool MAH1tang = (MA1H11>MA1H13&&MA1H12>MA1H13); bool MAH1catlen = (MA1H11>MA1H12&&MA2H11<MA2H12); bool MAH1giam = (MA1H11<MA1H13&&MA1H12<MA1H13); bool MAH1catxuong = (MA1H11<MA1H12&&MA2H11>MA2H12); bool MACDH4lon = (MACD1H4>0); bool MACDH1catlen = (MACD1H1>0&&MACD2H1<0); bool MACDH4nho = (MACD1H4<0); bool MACDH1catxuong = (MACD1H1<0&&MACD2H1>0); if(MAH1 != False && MACDH1 != False) {continue;} if(MAH1 == False && MACDH1 == False) {continue;} if(MAH1 != False && MACDH1 == False) { if(MAH1tang != False && MAH1catlen != False) {OpenPositionH1(OP_BUY);} if(MAH1giam != False && MAH1catxuong != False) {OpenPositionH1(OP_SELL);} } else if(MACDH1 != False && MAH1 == False) { if(MACDH4lon != False && MACDH1catlen != False) {OpenPositionH1(OP_BUY);} if(MACDH4nho != False && MACDH1catxuong != False) {OpenPositionH1(OP_SELL);} } } Sleep(1000); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OpenH11() { for(int i=0;i<1;i++) { double MA1H11 = iMA(NULL,60,MAH11,0,MODE_SMA,PRICE_CLOSE,1); double MA2H11= iMA(NULL,60,MAH11,0,MODE_SMA,PRICE_CLOSE,2); double MA3H11 = iMA(NULL,60,MAH11,0,MODE_SMA,PRICE_CLOSE,3); double MA1H12 = iMA(NULL,60,MAH12,0,MODE_SMA,PRICE_CLOSE,1); double MA2H12 = iMA(NULL,60,MAH12,0,MODE_SMA,PRICE_CLOSE,2); double MA3H12 = iMA(NULL,60,MAH12,0,MODE_SMA,PRICE_CLOSE,3); double MA1H13 = iMA(NULL,60,MAH13,0,MODE_SMA,PRICE_CLOSE,1); double MA2H13 = iMA(NULL,60,MAH13,0,MODE_SMA,PRICE_CLOSE,2); double MA3H13 = iMA(NULL,60,MAH13,0,MODE_SMA,PRICE_CLOSE,3); //======== double MACD1H1 = iMACD(NULL,60,12,26,9,PRICE_CLOSE,MODE_MAIN,1); double MACD2H1 = iMACD(NULL,60,12,26,9,PRICE_CLOSE,MODE_MAIN,2); double MACD3H1 = iMACD(NULL,60,12,26,9,PRICE_CLOSE,MODE_MAIN,3); double MACD1H4 = iMACD(NULL,240,12,26,9,PRICE_CLOSE,MODE_MAIN,1); double MACD2H4 = iMACD(NULL,240,12,26,9,PRICE_CLOSE,MODE_MAIN,2); double MACD3H4 = iMACD(NULL,240,12,26,9,PRICE_CLOSE,MODE_MAIN,3); bool MAH1tang = (MA1H11>MA1H13&&MA1H12>MA1H13); bool MAH1catlen = (MA1H11>MA1H12&&MA2H11<MA2H12); bool MAH1giam = (MA1H11<MA1H13&&MA1H12<MA1H13); bool MAH1catxuong = (MA1H11<MA1H12&&MA2H11>MA2H12); bool MACDH4lon = (MACD1H4>0); bool MACDH1catlen = (MACD1H1>0&&MACD2H1<0); bool MACDH4nho = (MACD1H4<0); bool MACDH1catxuong = (MACD1H1<0&&MACD2H1>0); if(MAH1 != False && MACDH1 != False) {continue;} if(MAH1 == False && MACDH1 == False) {continue;} if(MAH1 != False && MACDH1 == False) { if(MAH1tang != False && MAH1catlen != False) {OpenPositionH11(OP_BUY);} if(MAH1giam != False && MAH1catxuong != False) {OpenPositionH11(OP_SELL);} } else if(MACDH1 != False && MAH1 == False) { if(MACDH4lon != False && MACDH1catlen != False) {OpenPositionH11(OP_BUY);} if(MACDH4nho != False && MACDH1catxuong != False) {OpenPositionH11(OP_SELL);} } } Sleep(1000); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OpenH4() { for(int i=0;i<1;i++) { double MA1H41 = iMA(NULL,240,MAH41,0,MODE_SMA,PRICE_CLOSE,1); double MA2H41 = iMA(NULL,240,MAH41,0,MODE_SMA,PRICE_CLOSE,2); double MA3H41 = iMA(NULL,240,MAH41,0,MODE_SMA,PRICE_CLOSE,3); double MA1H42 = iMA(NULL,240,MAH42,0,MODE_SMA,PRICE_CLOSE,1); double MA2H42 = iMA(NULL,240,MAH42,0,MODE_SMA,PRICE_CLOSE,2); double MA3H42 = iMA(NULL,240,MAH42,0,MODE_SMA,PRICE_CLOSE,3); double MA1H43 = iMA(NULL,240,MAH43,0,MODE_SMA,PRICE_CLOSE,1); double MA2H43 = iMA(NULL,240,MAH43,0,MODE_SMA,PRICE_CLOSE,2); double MA3H43 = iMA(NULL,240,MAH43,0,MODE_SMA,PRICE_CLOSE,3); //======== double MACD1H4 = iMACD(NULL,240,12,26,9,PRICE_CLOSE,MODE_MAIN,1); double MACD2H4 = iMACD(NULL,240,12,26,9,PRICE_CLOSE,MODE_MAIN,2); double MACD3H4 = iMACD(NULL,240,12,26,9,PRICE_CLOSE,MODE_MAIN,3); double MACD1D = iMACD(NULL,1440,12,26,9,PRICE_CLOSE,MODE_MAIN,1); double MACD2D = iMACD(NULL,1440,12,26,9,PRICE_CLOSE,MODE_MAIN,2); double MACD3D = iMACD(NULL,1440,12,26,9,PRICE_CLOSE,MODE_MAIN,3); bool MAH4tang = (MA1H41>MA1H43&&MA1H42>MA1H43); bool MAH4catlen = (MA1H41>MA1H42&&MA2H41<MA2H42); bool MAH4giam = (MA1H41<MA1H43&&MA1H42<MA1H43); bool MAH4catxuong = (MA1H41<MA1H42&&MA2H41>MA2H42); bool MACDDlon = (MACD1D>0); bool MACDH4catlen = (MACD1H4>0&&MACD2H4<0); bool MACDDnho = (MACD1D<0); bool MACDH4catxuong = (MACD1H4<0&&MACD2H4>0); if(MAH4 != False && MACDH4 != False) {continue;} if(MAH4 == False && MACDH4 == False) {continue;} if(MAH4 != False && MACDH4 == False) { if(MAH4tang != False && MAH4catlen != False) {OpenPositionH4(OP_BUY);} if(MAH4giam != False && MAH4catxuong != False) {OpenPositionH4(OP_SELL);} } else if(MACDH4 != False && MAH4 == False) { if(MACDDlon != False && MACDH4catlen != False) {OpenPositionH4(OP_BUY);} if(MACDDnho != False && MACDH4catxuong != False) {OpenPositionH4(OP_SELL);} } } Sleep(1000); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OpenH41() { for(int i=0;i<1;i++) { double MA1H41 = iMA(NULL,240,MAH41,0,MODE_SMA,PRICE_CLOSE,1); double MA2H41 = iMA(NULL,240,MAH41,0,MODE_SMA,PRICE_CLOSE,2); double MA3H41 = iMA(NULL,240,MAH41,0,MODE_SMA,PRICE_CLOSE,3); double MA1H42 = iMA(NULL,240,MAH42,0,MODE_SMA,PRICE_CLOSE,1); double MA2H42 = iMA(NULL,240,MAH42,0,MODE_SMA,PRICE_CLOSE,2); double MA3H42 = iMA(NULL,240,MAH42,0,MODE_SMA,PRICE_CLOSE,3); double MA1H43 = iMA(NULL,240,MAH43,0,MODE_SMA,PRICE_CLOSE,1); double MA2H43 = iMA(NULL,240,MAH43,0,MODE_SMA,PRICE_CLOSE,2); double MA3H43 = iMA(NULL,240,MAH43,0,MODE_SMA,PRICE_CLOSE,3); //======== double MACD1H4 = iMACD(NULL,240,12,26,9,PRICE_CLOSE,MODE_MAIN,1); double MACD2H4 = iMACD(NULL,240,12,26,9,PRICE_CLOSE,MODE_MAIN,2); double MACD3H4 = iMACD(NULL,240,12,26,9,PRICE_CLOSE,MODE_MAIN,3); double MACD1D = iMACD(NULL,1440,12,26,9,PRICE_CLOSE,MODE_MAIN,1); double MACD2D = iMACD(NULL,1440,12,26,9,PRICE_CLOSE,MODE_MAIN,2); double MACD3D = iMACD(NULL,1440,12,26,9,PRICE_CLOSE,MODE_MAIN,3); bool MAH4tang = (MA1H41>MA1H43&&MA1H42>MA1H43); bool MAH4catlen = (MA1H41>MA1H42&&MA2H41<MA2H42); bool MAH4giam = (MA1H41<MA1H43&&MA1H42<MA1H43); bool MAH4catxuong = (MA1H41<MA1H42&&MA2H41>MA2H42); bool MACDDlon = (MACD1D>0); bool MACDH4catlen = (MACD1H4>0&&MACD2H4<0); bool MACDDnho = (MACD1D<0); bool MACDH4catxuong = (MACD1H4<0&&MACD2H4>0); if(MAH4 != False && MACDH4 != False) {continue;} if(MAH4 == False && MACDH4 == False) {continue;} if(MAH4 != False && MACDH4 == False) { if(MAH4tang != False && MAH4catlen != False) {OpenPositionH41(OP_BUY);} if(MAH4giam != False && MAH4catxuong != False) {OpenPositionH41(OP_SELL);} } else if(MACDH4 != False && MAH4 == False) { if(MACDDlon != False && MACDH4catlen != False) {OpenPositionH41(OP_BUY);} if(MACDDnho != False && MACDH4catxuong != False) {OpenPositionH41(OP_SELL);} } } Sleep(1000); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void CloseM15() { for(int i=0;i<1;i++) { double MA1M151 = iMA(NULL,15,MAM151,0,MODE_SMA,PRICE_CLOSE,1); double MA2M151 = iMA(NULL,15,MAM151,0,MODE_SMA,PRICE_CLOSE,2); double MA3M151 = iMA(NULL,15,MAM151,0,MODE_SMA,PRICE_CLOSE,3); double MA1M152 = iMA(NULL,15,MAM152,0,MODE_SMA,PRICE_CLOSE,1); double MA2M152 = iMA(NULL,15,MAM152,0,MODE_SMA,PRICE_CLOSE,2); double MA3M152 = iMA(NULL,15,MAM152,0,MODE_SMA,PRICE_CLOSE,3); double MA1M153 = iMA(NULL,15,MAM153,0,MODE_SMA,PRICE_CLOSE,1); double MA2M153 = iMA(NULL,15,MAM153,0,MODE_SMA,PRICE_CLOSE,2); double MA3M153 = iMA(NULL,15,MAM153,0,MODE_SMA,PRICE_CLOSE,3); //======== double MACD1M15 = iMACD(NULL,15,12,26,9,PRICE_CLOSE,MODE_MAIN,1); double MACD2M15 = iMACD(NULL,15,12,26,9,PRICE_CLOSE,MODE_MAIN,2); double MACD3M15 = iMACD(NULL,15,12,26,9,PRICE_CLOSE,MODE_MAIN,3); double MACD1H1 = iMACD(NULL,60,12,26,9,PRICE_CLOSE,MODE_MAIN,1); double MACD2H1 = iMACD(NULL,60,12,26,9,PRICE_CLOSE,MODE_MAIN,2); double MACD3H1 = iMACD(NULL,60,12,26,9,PRICE_CLOSE,MODE_MAIN,3); bool MAM15tang = (MA1M151>MA1M153&&MA1M152>MA1M153); bool MAM15catlen = (MA1M151>MA1M152&&MA2M151<MA2M152); bool MAM15giam = (MA1M151<MA1M153&&MA1M152<MA1M153); bool MAM15catxuong = (MA1M151<MA1M152&&MA2M151>MA2M152); bool MACDH1lon = (MACD1H1>0); bool MACDM15catlen = (MACD1M15>0&&MACD2M15<0); bool MACDH1nho = (MACD1H1<0); bool MACDM15catxuong = (MACD1M15<0&&MACD2M15>0); if(MAM15 != False && MACDM15 != False) {continue;} if(MAM15 == False && MACDM15 == False) {continue;} if(MAM15 != False && MACDM15 == False) { if(MAM15tang != False && MAM15catxuong != False) {ClosePositionM15(OP_BUY);} if(MAM15giam != False && MAM15catlen != False) {ClosePositionM15(OP_SELL);} } else if(MACDM15 != False && MAM15 == False) { if(MACDH1lon != False && MACDM15catxuong != False) {ClosePositionM15(OP_BUY);} if(MACDH1nho != False && MACDM15catlen != False) {ClosePositionM15(OP_SELL);} } } Sleep(1000); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void CloseM151() { for(int i=0;i<1;i++) { double MA1M151 = iMA(NULL,15,MAM151,0,MODE_SMA,PRICE_CLOSE,1); double MA2M151 = iMA(NULL,15,MAM151,0,MODE_SMA,PRICE_CLOSE,2); double MA3M151 = iMA(NULL,15,MAM151,0,MODE_SMA,PRICE_CLOSE,3); double MA1M152 = iMA(NULL,15,MAM152,0,MODE_SMA,PRICE_CLOSE,1); double MA2M152 = iMA(NULL,15,MAM152,0,MODE_SMA,PRICE_CLOSE,2); double MA3M152 = iMA(NULL,15,MAM152,0,MODE_SMA,PRICE_CLOSE,3); double MA1M153 = iMA(NULL,15,MAM153,0,MODE_SMA,PRICE_CLOSE,1); double MA2M153 = iMA(NULL,15,MAM153,0,MODE_SMA,PRICE_CLOSE,2); double MA3M153 = iMA(NULL,15,MAM153,0,MODE_SMA,PRICE_CLOSE,3); //=========== double MACD1M15 = iMACD(NULL,15,12,26,9,PRICE_CLOSE,MODE_MAIN,1); double MACD2M15 = iMACD(NULL,15,12,26,9,PRICE_CLOSE,MODE_MAIN,2); double MACD3M15 = iMACD(NULL,15,12,26,9,PRICE_CLOSE,MODE_MAIN,3); double MACD1H1 = iMACD(NULL,60,12,26,9,PRICE_CLOSE,MODE_MAIN,1); double MACD2H1 = iMACD(NULL,60,12,26,9,PRICE_CLOSE,MODE_MAIN,2); double MACD3H1 = iMACD(NULL,60,12,26,9,PRICE_CLOSE,MODE_MAIN,3); bool MAM15tang = (MA1M151>MA1M153&&MA1M152>MA1M153); bool MAM15catlen = (MA1M151>MA1M152&&MA2M151<MA2M152); bool MAM15giam = (MA1M151<MA1M153&&MA1M152<MA1M153); bool MAM15catxuong = (MA1M151<MA1M152&&MA2M151>MA2M152); bool MACDH1lon = (MACD1H1>0); bool MACDM15catlen = (MACD1M15>0&&MACD2M15<0); bool MACDH1nho = (MACD1H1<0); bool MACDM15catxuong = (MACD1M15<0&&MACD2M15>0); if(MAM15 != False && MACDM15 != False) {continue;} if(MAM15 == False && MACDM15 == False) {continue;} if(MAM15 != False && MACDM15 == False) { if(MAM15tang != False && MAM15catxuong != False) {ClosePositionM151(OP_BUY);} if(MAM15giam != False && MAM15catlen != False) {ClosePositionM151(OP_SELL);} } else if(MACDM15 != False && MAM15 == False) { if(MACDH1lon != False && MACDM15catxuong != False) {ClosePositionM151(OP_BUY);} if(MACDH1nho != False && MACDM15catlen != False) {ClosePositionM151(OP_SELL);} } } Sleep(1000); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void CloseH1() { for(int i=0;i<1;i++) { double MA1H11 = iMA(NULL,60,MAH11,0,MODE_SMA,PRICE_CLOSE,1); double MA2H11= iMA(NULL,60,MAH11,0,MODE_SMA,PRICE_CLOSE,2); double MA3H11 = iMA(NULL,60,MAH11,0,MODE_SMA,PRICE_CLOSE,3); double MA1H12 = iMA(NULL,60,MAH12,0,MODE_SMA,PRICE_CLOSE,1); double MA2H12 = iMA(NULL,60,MAH12,0,MODE_SMA,PRICE_CLOSE,2); double MA3H12 = iMA(NULL,60,MAH12,0,MODE_SMA,PRICE_CLOSE,3); double MA1H13 = iMA(NULL,60,MAH13,0,MODE_SMA,PRICE_CLOSE,1); double MA2H13 = iMA(NULL,60,MAH13,0,MODE_SMA,PRICE_CLOSE,2); double MA3H13 = iMA(NULL,60,MAH13,0,MODE_SMA,PRICE_CLOSE,3); //======== double MACD1H1 = iMACD(NULL,60,12,26,9,PRICE_CLOSE,MODE_MAIN,1); double MACD2H1 = iMACD(NULL,60,12,26,9,PRICE_CLOSE,MODE_MAIN,2); double MACD3H1 = iMACD(NULL,60,12,26,9,PRICE_CLOSE,MODE_MAIN,3); double MACD1H4 = iMACD(NULL,240,12,26,9,PRICE_CLOSE,MODE_MAIN,1); double MACD2H4 = iMACD(NULL,240,12,26,9,PRICE_CLOSE,MODE_MAIN,2); double MACD3H4 = iMACD(NULL,240,12,26,9,PRICE_CLOSE,MODE_MAIN,3); bool MAH1tang = (MA1H11>MA1H13&&MA1H12>MA1H13); bool MAH1catlen = (MA1H11>MA1H12&&MA2H11<MA2H12); bool MAH1giam = (MA1H11<MA1H13&&MA1H12<MA1H13); bool MAH1catxuong = (MA1H11<MA1H12&&MA2H11>MA2H12); bool MACDH4lon = (MACD1H4>0); bool MACDH1catlen = (MACD1H1>0&&MACD2H1<0); bool MACDH4nho = (MACD1H4<0); bool MACDH1catxuong = (MACD1H1<0&&MACD2H1>0); if(MAH1 != False && MACDH1 != False) {continue;} if(MAH1 == False && MACDH1 == False) {continue;} if(MAH1 != False && MACDH1 == False) { if(MAH1tang != False && MAH1catxuong != False) {ClosePositionH1(OP_BUY);} if(MAH1giam != False && MAH1catlen != False) {ClosePositionH1(OP_SELL);} } else if(MACDH1 != False && MAH1 == False) { if(MACDH4lon != False && MACDH1catxuong != False) {ClosePositionH1(OP_BUY);} if(MACDH4nho != False && MACDH1catlen != False) {ClosePositionH1(OP_SELL);} } } Sleep(1000); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void CloseH11() { for(int i=0;i<1;i++) { double MA1H11 = iMA(NULL,60,MAH11,0,MODE_SMA,PRICE_CLOSE,1); double MA2H11= iMA(NULL,60,MAH11,0,MODE_SMA,PRICE_CLOSE,2); double MA3H11 = iMA(NULL,60,MAH11,0,MODE_SMA,PRICE_CLOSE,3); double MA1H12 = iMA(NULL,60,MAH12,0,MODE_SMA,PRICE_CLOSE,1); double MA2H12 = iMA(NULL,60,MAH12,0,MODE_SMA,PRICE_CLOSE,2); double MA3H12 = iMA(NULL,60,MAH12,0,MODE_SMA,PRICE_CLOSE,3); double MA1H13 = iMA(NULL,60,MAH13,0,MODE_SMA,PRICE_CLOSE,1); double MA2H13 = iMA(NULL,60,MAH13,0,MODE_SMA,PRICE_CLOSE,2); double MA3H13 = iMA(NULL,60,MAH13,0,MODE_SMA,PRICE_CLOSE,3); //======== double MACD1H1 = iMACD(NULL,60,12,26,9,PRICE_CLOSE,MODE_MAIN,1); double MACD2H1 = iMACD(NULL,60,12,26,9,PRICE_CLOSE,MODE_MAIN,2); double MACD3H1 = iMACD(NULL,60,12,26,9,PRICE_CLOSE,MODE_MAIN,3); double MACD1H4 = iMACD(NULL,240,12,26,9,PRICE_CLOSE,MODE_MAIN,1); double MACD2H4 = iMACD(NULL,240,12,26,9,PRICE_CLOSE,MODE_MAIN,2); double MACD3H4 = iMACD(NULL,240,12,26,9,PRICE_CLOSE,MODE_MAIN,3); bool MAH1tang = (MA1H11>MA1H13&&MA1H12>MA1H13); bool MAH1catlen = (MA1H11>MA1H12&&MA2H11<MA2H12); bool MAH1giam = (MA1H11<MA1H13&&MA1H12<MA1H13); bool MAH1catxuong = (MA1H11<MA1H12&&MA2H11>MA2H12); bool MACDH4lon = (MACD1H4>0); bool MACDH1catlen = (MACD1H1>0&&MACD2H1<0); bool MACDH4nho = (MACD1H4<0); bool MACDH1catxuong = (MACD1H1<0&&MACD2H1>0); if(MAH1 != False && MACDH1 != False) {continue;} if(MAH1 == False && MACDH1 == False) {continue;} if(MAH1 != False && MACDH1 == False) { if(MAH1tang != False && MAH1catxuong != False) {ClosePositionH11(OP_BUY);} if(MAH1giam != False && MAH1catlen != False) {ClosePositionH11(OP_SELL);} } else if(MACDH1 != False && MAH1 == False) { if(MACDH4lon != False && MACDH1catxuong != False) {ClosePositionH11(OP_BUY);} if(MACDH4nho != False && MACDH1catlen != False) {ClosePositionH11(OP_SELL);} } } Sleep(1000); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void CloseH4() { for(int i=0;i<1;i++) { double MA1H41 = iMA(NULL,240,MAH41,0,MODE_SMA,PRICE_CLOSE,1); double MA2H41 = iMA(NULL,240,MAH41,0,MODE_SMA,PRICE_CLOSE,2); double MA3H41 = iMA(NULL,240,MAH41,0,MODE_SMA,PRICE_CLOSE,3); double MA1H42 = iMA(NULL,240,MAH42,0,MODE_SMA,PRICE_CLOSE,1); double MA2H42 = iMA(NULL,240,MAH42,0,MODE_SMA,PRICE_CLOSE,2); double MA3H42 = iMA(NULL,240,MAH42,0,MODE_SMA,PRICE_CLOSE,3); double MA1H43 = iMA(NULL,240,MAH43,0,MODE_SMA,PRICE_CLOSE,1); double MA2H43 = iMA(NULL,240,MAH43,0,MODE_SMA,PRICE_CLOSE,2); double MA3H43 = iMA(NULL,240,MAH43,0,MODE_SMA,PRICE_CLOSE,3); //======== double MACD1H4 = iMACD(NULL,240,12,26,9,PRICE_CLOSE,MODE_MAIN,1); double MACD2H4 = iMACD(NULL,240,12,26,9,PRICE_CLOSE,MODE_MAIN,2); double MACD3H4 = iMACD(NULL,240,12,26,9,PRICE_CLOSE,MODE_MAIN,3); double MACD1D = iMACD(NULL,1440,12,26,9,PRICE_CLOSE,MODE_MAIN,1); double MACD2D = iMACD(NULL,1440,12,26,9,PRICE_CLOSE,MODE_MAIN,2); double MACD3D = iMACD(NULL,1440,12,26,9,PRICE_CLOSE,MODE_MAIN,3); bool MAH4tang = (MA1H41>MA1H43&&MA1H42>MA1H43); bool MAH4catlen = (MA1H41>MA1H42&&MA2H41<MA2H42); bool MAH4giam = (MA1H41<MA1H43&&MA1H42<MA1H43); bool MAH4catxuong = (MA1H41<MA1H42&&MA2H41>MA2H42); bool MACDDlon = (MACD1D>0); bool MACDH4catlen = (MACD1H4>0&&MACD2H4<0); bool MACDDnho = (MACD1D<0); bool MACDH4catxuong = (MACD1H4<0&&MACD2H4>0); if(MAH4 != False && MACDH4 != False) {continue;} if(MAH4 == False && MACDH4 == False) {continue;} if(MAH4 != False && MACDH4 == False) { if(MAH4tang != False && MAH4catxuong != False) {ClosePositionH4(OP_BUY);} if(MAH4giam != False && MAH4catlen != False) {ClosePositionH4(OP_SELL);} } else if(MACDH4 != False && MAH4 == False) { if(MACDDlon != False && MACDH4catxuong != False) {ClosePositionH4(OP_BUY);} if(MACDDnho != False && MACDH4catlen != False) {ClosePositionH4(OP_SELL);} } } Sleep(1000); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void CloseH41() { for(int i=0;i<1;i++) { double MA1H41 = iMA(NULL,240,MAH41,0,MODE_SMA,PRICE_CLOSE,1); double MA2H41 = iMA(NULL,240,MAH41,0,MODE_SMA,PRICE_CLOSE,2); double MA3H41 = iMA(NULL,240,MAH41,0,MODE_SMA,PRICE_CLOSE,3); double MA1H42 = iMA(NULL,240,MAH42,0,MODE_SMA,PRICE_CLOSE,1); double MA2H42 = iMA(NULL,240,MAH42,0,MODE_SMA,PRICE_CLOSE,2); double MA3H42 = iMA(NULL,240,MAH42,0,MODE_SMA,PRICE_CLOSE,3); double MA1H43 = iMA(NULL,240,MAH43,0,MODE_SMA,PRICE_CLOSE,1); double MA2H43 = iMA(NULL,240,MAH43,0,MODE_SMA,PRICE_CLOSE,2); double MA3H43 = iMA(NULL,240,MAH43,0,MODE_SMA,PRICE_CLOSE,3); //======== double MACD1H4 = iMACD(NULL,240,12,26,9,PRICE_CLOSE,MODE_MAIN,1); double MACD2H4 = iMACD(NULL,240,12,26,9,PRICE_CLOSE,MODE_MAIN,2); double MACD3H4 = iMACD(NULL,240,12,26,9,PRICE_CLOSE,MODE_MAIN,3); double MACD1D = iMACD(NULL,1440,12,26,9,PRICE_CLOSE,MODE_MAIN,1); double MACD2D = iMACD(NULL,1440,12,26,9,PRICE_CLOSE,MODE_MAIN,2); double MACD3D = iMACD(NULL,1440,12,26,9,PRICE_CLOSE,MODE_MAIN,3); bool MAH4tang = (MA1H41>MA1H43&&MA1H42>MA1H43); bool MAH4catlen = (MA1H41>MA1H42&&MA2H41<MA2H42); bool MAH4giam = (MA1H41<MA1H43&&MA1H42<MA1H43); bool MAH4catxuong = (MA1H41<MA1H42&&MA2H41>MA2H42); bool MACDDlon = (MACD1D>0); bool MACDH4catlen = (MACD1H4>0&&MACD2H4<0); bool MACDDnho = (MACD1D<0); bool MACDH4catxuong = (MACD1H4<0&&MACD2H4>0); if(MAH4 != False && MACDH4 != False) {continue;} if(MAH4 == False && MACDH4 == False) {continue;} if(MAH4 != False && MACDH4 == False) { if(MAH4tang != False && MAH4catxuong != False) {ClosePositionH41(OP_BUY);} if(MAH4giam != False && MAH4catlen != False) {ClosePositionH41(OP_SELL);} } else if(MACDH4 != False && MAH4 == False) { if(MACDDlon != False && MACDH4catxuong != False) {ClosePositionH41(OP_BUY);} if(MACDDnho != False && MACDH4catlen != False) {ClosePositionH41(OP_SELL);} } } Sleep(1000); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OpenPositionM15(int command) { int order1 = 0; int loaiLenh; int lastError1 = 0; int solenh1 = DemsolenhM15(Symbol()); khoiLuong = Lotsize(khoiLuong); color mau ; double giavaolenh; if(command == OP_BUY ) { loaiLenh = OP_BUY ; mau = clrBlue;giavaolenh = Ask;} else {if(command == OP_SELL ) { loaiLenh = OP_SELL ; mau = clrYellow;giavaolenh = Bid;}} if(solenh1>0){return;} if(solenh1<=0) for(int abc1 = 0 ;abc1 <1; abc1++) { Com = Com_M15; Magic_Number = Magic_Number15; order1 = OrderSend( Symbol(),loaiLenh,khoiLuong,giavaolenh,Truotgia,Stop_Loss,Take_Profit,Com,Magic_Number,0,mau ); } lastError1=GetLastError(); if(lastError1!=135 && lastError1!=136 && lastError1!=137 && lastError1!=138) {return;} Sleep(1000); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OpenPositionM151(int command) { int order11 = 0; int loaiLenh; int lastError11 = 0; int solenh11 = DemsolenhM151(Symbol()); double lenhcuoiM15 = lenhcuoicungM15(Symbol()); khoiLuong = Lotsize(khoiLuong); color mau ; double giavaolenh; if(command == OP_BUY ) { loaiLenh = OP_BUY ; mau = clrBlue;giavaolenh = Ask;} else {if(command == OP_SELL ) { loaiLenh = OP_SELL ; mau = clrYellow;giavaolenh = Bid;}} if(solenh11>0){return;} if(lenhcuoiM15<0) for(int abc11 = 0 ;abc11 <1; abc11++) { Com = Com_M151; Magic_Number = Magic_Number15; order11 = OrderSend( Symbol(),loaiLenh,khoiLuong,giavaolenh,Truotgia,Stop_Loss,Take_Profit,Com,Magic_Number,0,mau ); } lastError11=GetLastError(); if(lastError11!=135 && lastError11!=136 && lastError11!=137 && lastError11!=138) {return;} Sleep(1000); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OpenPositionH1(int command) { int order2 = 0; int loaiLenh; int lastError2 = 0; int solenh2 = DemsolenhH1(Symbol()); khoiLuong = Lotsize(khoiLuong); color mau ; double giavaolenh; if(command == OP_BUY ) { loaiLenh = OP_BUY ; mau = clrBlue;giavaolenh = Ask;} else {if(command == OP_SELL ) { loaiLenh = OP_SELL ; mau = clrYellow;giavaolenh = Bid;}} if(solenh2>0){return;} if(solenh2<=0) for(int abc2 = 0 ;abc2 <1; abc2++) { Com = Com_H1; Magic_Number = Magic_Number60; order2 = OrderSend( Symbol(),loaiLenh,khoiLuong,giavaolenh,Truotgia,Stop_Loss,Take_Profit,Com,Magic_Number,0,mau ); } lastError2=GetLastError(); if(lastError2!=135 && lastError2!=136 && lastError2!=137 && lastError2!=138) {return;} Sleep(1000); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OpenPositionH11(int command) { int order21 = 0; int loaiLenh; int lastError21 = 0; int solenh21 = DemsolenhH11(Symbol()); double lenhcuoiH1 = lenhcuoicungH1(Symbol()); khoiLuong = Lotsize(khoiLuong); color mau ; double giavaolenh; if(command == OP_BUY ) { loaiLenh = OP_BUY ; mau = clrBlue;giavaolenh = Ask;} else {if(command == OP_SELL ) { loaiLenh = OP_SELL ; mau = clrYellow;giavaolenh = Bid;}} if(solenh21>0){return;} if(lenhcuoiH1<0) for(int abc21 = 0 ;abc21 <1; abc21++) { Com = Com_H11; Magic_Number = Magic_Number60; order21 = OrderSend( Symbol(),loaiLenh,khoiLuong,giavaolenh,Truotgia,Stop_Loss,Take_Profit,Com,Magic_Number,0,mau ); } lastError21=GetLastError(); if(lastError21!=135 && lastError21!=136 && lastError21!=137 && lastError21!=138) {return;} Sleep(1000); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OpenPositionH4(int command) { int order3 = 0; int loaiLenh; int lastError3 = 0; int solenh3 = DemsolenhH4(Symbol()); khoiLuong = Lotsize(khoiLuong); color mau ; double giavaolenh; if(command == OP_BUY ) { loaiLenh = OP_BUY ; mau = clrBlue;giavaolenh = Ask;} else {if(command == OP_SELL ) { loaiLenh = OP_SELL ; mau = clrYellow;giavaolenh = Bid;}} if(solenh3>0){return;} if(solenh3<=0) for(int abc3 = 0 ;abc3 <1; abc3++) { Com = Com_H4; Magic_Number = Magic_Number240; order3 = OrderSend( Symbol(),loaiLenh,khoiLuong,giavaolenh,Truotgia,Stop_Loss,Take_Profit,Com,Magic_Number,0,mau ); } lastError3=GetLastError(); if(lastError3!=135 && lastError3!=136 && lastError3!=137 && lastError3!=138) {return;} Sleep(1000); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OpenPositionH41(int command) { int order31 = 0; int loaiLenh; int lastError31 = 0; int solenh31 = DemsolenhH41(Symbol()); double lenhcuoiH4 = lenhcuoicungH4(Symbol()); khoiLuong = Lotsize(khoiLuong); color mau ; double giavaolenh; if(command == OP_BUY ) { loaiLenh = OP_BUY ; mau = clrBlue;giavaolenh = Ask;} else {if(command == OP_SELL ) { loaiLenh = OP_SELL ; mau = clrYellow;giavaolenh = Bid;}} if(solenh31>0){return;} if(lenhcuoiH4<0) for(int abc31 = 0 ;abc31 <1; abc31++) { Com = Com_H41; Magic_Number = Magic_Number240; order31 = OrderSend( Symbol(),loaiLenh,khoiLuong,giavaolenh,Truotgia,Stop_Loss,Take_Profit,Com,Magic_Number,0,mau ); } lastError31=GetLastError(); if(lastError31!=135 && lastError31!=136 && lastError31!=137 && lastError31!=138) {return;} Sleep(1000); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void ClosePositionM15(int command) { bool close1; int lastError1; int veticket1 = OrderticketM15(Symbol()); color mau ; double giadonglenh; double posLots1 = OrderlotM15(Symbol()); int solenh1 = DemsolenhM15(Symbol()); if(command == OP_BUY ) { mau = clrYellow;giadonglenh = Bid;} else {if(command == OP_SELL ) { mau = clrBlue;giadonglenh = Ask;}} for(int a1=0; a1<=1; a1++) { if(IsTradeContextFree()) { close1 = OrderClose(veticket1,posLots1,giadonglenh,Truotgia,mau); lastError1==GetLastError(); } } Sleep(1000); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void ClosePositionM151(int command) { bool close11; int lastError11; int veticket11 = OrderticketM151(Symbol()); color mau ; double giadonglenh; double posLots11 = OrderlotM151(Symbol()); int solenh11 = DemsolenhM151(Symbol()); if(command == OP_BUY ) { mau = clrBlue;giadonglenh = Bid;} else {if(command == OP_SELL ) { mau = clrYellow;giadonglenh = Ask;}} for(int a11=0; a11<=1; a11++) { if(IsTradeContextFree()) { close11 = OrderClose(veticket11,posLots11,giadonglenh,Truotgia,mau); lastError11==GetLastError(); } } Sleep(1000); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void ClosePositionH1(int command) { bool close2; int lastError2; int veticket2 = OrderticketH1(Symbol()); color mau ; double giadonglenh; double posLots2 = OrderlotH1(Symbol()); int solenh2 = DemsolenhH1(Symbol()); if(command == OP_BUY ) { mau = clrBlue;giadonglenh = Bid;} else {if(command == OP_SELL ) { mau = clrYellow;giadonglenh = Ask;}} for(int a2=0; a2<=1; a2++) { if(IsTradeContextFree()) { close2 = OrderClose(veticket2,posLots2,giadonglenh,Truotgia,mau); lastError2==GetLastError(); } } Sleep(1000); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void ClosePositionH11(int command) { bool close21; int lastError21; int veticket21 = OrderticketH11(Symbol()); color mau ; double giadonglenh; double posLots21 = OrderlotH11(Symbol()); int solenh21 = DemsolenhH11(Symbol()); if(command == OP_BUY ) { mau = clrBlue;giadonglenh = Bid;} else {if(command == OP_SELL ) { mau = clrYellow;giadonglenh = Ask;}} for(int a21=0; a21<=1; a21++) { if(IsTradeContextFree()) { close21 = OrderClose(veticket21,posLots21,giadonglenh,Truotgia,mau); lastError21==GetLastError(); } } Sleep(1000); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void ClosePositionH4(int command) { bool close3; int lastError3; int veticket3 = OrderticketH4(Symbol()); color mau ; double giadonglenh; double posLots3 = OrderlotH4(Symbol()); int solenh3 = DemsolenhH4(Symbol()); if(command == OP_BUY ) { mau = clrBlue;giadonglenh = Bid;} else {if(command == OP_SELL ) { mau = clrYellow;giadonglenh = Ask;}} for(int a3=0; a3<=1; a3++) { if(IsTradeContextFree()) { close3 = OrderClose(veticket3,posLots3,giadonglenh,Truotgia,mau); lastError3==GetLastError(); } } Sleep(1000); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void ClosePositionH41(int command) { bool close31; int lastError31; int veticket31 = OrderticketH41(Symbol()); color mau ; double giadonglenh; double posLots31 = OrderlotH41(Symbol()); int solenh31 = DemsolenhH41(Symbol()); if(command == OP_BUY ) { mau = clrBlue;giadonglenh = Bid;} else {if(command == OP_SELL ) { mau = clrYellow;giadonglenh = Ask;}} for(int a31=0; a31<=1; a31++) { if(IsTradeContextFree()) { close31 = OrderClose(veticket31,posLots31,giadonglenh,Truotgia,mau); lastError31==GetLastError(); } } Sleep(1000); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ double Lotsize(double Khoiluong) { double Taisan1 = AccountBalance(); double Taisan2 = AccountEquity(); if(Taisan1>=Taisan2) { if(Taisan2<200){Khoiluong =0.01;} if(Taisan2>200){Khoiluong = (Taisan2/200)*0.01*Gapthep-0.01;} } if(Taisan1<=Taisan2) { if(Taisan1<200){Khoiluong =0.01;} if(Taisan1>200){Khoiluong = (Taisan1/200)*0.01*Gapthep-0.01;} } if(Gapthep==0) { if(Taisan2<200){Khoiluong =0.01;} if(Taisan2>200){Khoiluong = (Taisan2/200)*0.01-0.01;} } if(Khoiluong<0.01) { Khoiluong =0.01; } Khoiluong = NormalizeDouble(Khoiluong,2); Sleep(1000); return(Khoiluong); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ double lenhcuoicungM15(string symm1) { double lastprofit1; datetime lasttime1; double lastLotsize1 ; int lasttype1; for(int i =0; i <= OrdersHistoryTotal()-1; i++) { if(OrderSelect(i, SELECT_BY_POS,MODE_HISTORY)==False) {continue;} if(OrderSymbol() != symm1){continue;} if(OrderMagicNumber()!= Magic_Number15){continue;} if(OrderType()>1 ){continue;} if(OrderCloseTime()> lasttime1 ) { lasttime1 = OrderCloseTime(); lastprofit1 = OrderProfit(); lastLotsize1 = OrderLots(); lasttype1 = OrderType(); } } Sleep(1000); return(lastprofit1); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ double lenhcuoicungH1(string symm2) { double lastprofit2; datetime lasttime2; double lastLotsize2 ; int lasttype2; for(int i =0; i <= OrdersHistoryTotal()-1; i++) { if(OrderSelect(i, SELECT_BY_POS,MODE_HISTORY)==False) {continue;} if(OrderSymbol() != symm2){continue;} if(OrderMagicNumber()!= Magic_Number60){continue;} if(OrderType()>1 ){continue;} if(OrderCloseTime()> lasttime2 ) { lasttime2 = OrderCloseTime(); lastprofit2 = OrderProfit(); lastLotsize2 = OrderLots(); lasttype2 = OrderType(); } } Sleep(1000); return(lastprofit2); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ double lenhcuoicungH4(string symm3) { double lastprofit3; datetime lasttime3; double lastLotsize3; int lasttype3; for(int i =0; i <= OrdersHistoryTotal()-1; i++) { if(OrderSelect(i, SELECT_BY_POS,MODE_HISTORY)==False) {continue;} if(OrderSymbol() != symm3){continue;} if(OrderMagicNumber()!= Magic_Number240){continue;} if(OrderType()>1 ){continue;} if(OrderCloseTime()> lasttime3 ) { lasttime3 = OrderCloseTime(); lastprofit3 = OrderProfit(); lastLotsize3 = OrderLots(); lasttype3 = OrderType(); } } Sleep(1000); return(lastprofit3); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ int Demsolenh(string captiencandem) { int dem; for(int i = OrdersTotal()-1 ; i>=0; i--) { if(OrderSelect(i, SELECT_BY_POS,MODE_TRADES)==False) {continue;} if(OrderSymbol() != captiencandem){continue;} dem ++;// dem dc 1 lenh } Sleep(1000); return(dem); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ int DemsolenhM15(string captiencandem1) { int dem1; for(int i = OrdersTotal()-1 ; i>=0; i--) { if(OrderSelect(i, SELECT_BY_POS,MODE_TRADES)==False) {continue;} if(OrderSymbol() != captiencandem1){continue;} if(OrderMagicNumber()!= Magic_Number15){continue;} if(OrderComment()!= Com_M15){continue;} dem1 ++;// dem dc 1 lenh } Sleep(1000); return(dem1); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ int DemsolenhM151(string captiencandem11) { int dem11; for(int i = OrdersTotal()-1 ; i>=0; i--) { if(OrderSelect(i, SELECT_BY_POS,MODE_TRADES)==False) {continue;} if(OrderSymbol() != captiencandem11){continue;} if(OrderMagicNumber()!= Magic_Number15){continue;} if(OrderComment()!= Com_M151){continue;} dem11 ++;// dem dc 1 lenh } Sleep(1000); return(dem11); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ int DemsolenhH1(string captiencandem2) { int dem2; for(int i = OrdersTotal()-1 ; i>=0; i--) { if(OrderSelect(i, SELECT_BY_POS,MODE_TRADES)==False) {continue;} if(OrderSymbol() != captiencandem2){continue;} if(OrderMagicNumber()!= Magic_Number60){continue;} if(OrderComment()!= Com_H1){continue;} dem2 ++;// dem dc 1 lenh } Sleep(1000); return(dem2); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ int DemsolenhH11(string captiencandem21) { int dem21; for(int i = OrdersTotal()-1 ; i>=0; i--) { if(OrderSelect(i, SELECT_BY_POS,MODE_TRADES)==False) {continue;} if(OrderSymbol() != captiencandem21){continue;} if(OrderMagicNumber()!= Magic_Number60){continue;} if(OrderComment()!= Com_H11){continue;} dem21 ++;// dem dc 1 lenh } Sleep(1000); return(dem21); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ int DemsolenhH4(string captiencandem3) { int dem3; for(int i = OrdersTotal()-1 ; i>=0; i--) { if(OrderSelect(i, SELECT_BY_POS,MODE_TRADES)==False) {continue;} if(OrderSymbol() != captiencandem3){continue;} if(OrderMagicNumber()!= Magic_Number240){continue;} if(OrderComment()!= Com_H4){continue;} dem3 ++;// dem dc 1 lenh } Sleep(1000); return(dem3); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ int DemsolenhH41(string captiencandem31) { int dem31; for(int i = OrdersTotal()-1 ; i>=0; i--) { if(OrderSelect(i, SELECT_BY_POS,MODE_TRADES)==False) {continue;} if(OrderSymbol() != captiencandem31){continue;} if(OrderMagicNumber()!= Magic_Number240){continue;} if(OrderComment()!= Com_H41){continue;} dem31 ++;// dem dc 1 lenh } Sleep(1000); return(dem31); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ bool IsTradeContextFree() { if(IsTradeAllowed()) return (true); uint startWait=GetTickCount(); Print("Trade context is busy! Waiting..."); while(true) { if(IsStopped()) return (false); uint diff=GetTickCount()-startWait; if(diff>30*1000) { Print("The waiting limit exceeded!"); return (false); } if(IsTradeAllowed()) { RefreshRates(); return (true); } Sleep(1000); } return (true); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ int OrderticketM15(string cmd) { int Ticket1 = 0; for(int i = 0 ; i < OrdersTotal() ; i++ ) { if(OrderSelect(i, SELECT_BY_POS,MODE_TRADES)==False) {continue;} if(OrderSymbol() != cmd){continue;} if(OrderMagicNumber()!= Magic_Number15){continue;} if(OrderComment()!= Com_M15){continue;} Ticket1 = OrderTicket(); } Sleep(1000); return(Ticket1); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ int OrderticketM151(string cmd) { int Ticket11 = 0; for(int i = 0 ; i < OrdersTotal() ; i++ ) { if(OrderSelect(i, SELECT_BY_POS,MODE_TRADES)==False) {continue;} if(OrderSymbol() != cmd){continue;} if(OrderMagicNumber()!= Magic_Number15){continue;} if(OrderComment()!= Com_M151){continue;} Ticket11 = OrderTicket(); } Sleep(1000); return(Ticket11); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ int OrderticketH1(string cmd) { int Ticket2 = 0; for(int i = 0 ; i < OrdersTotal() ; i++ ) { if(OrderSelect(i, SELECT_BY_POS,MODE_TRADES)==False) {continue;} if(OrderSymbol() != cmd){continue;} if(OrderMagicNumber()!= Magic_Number60){continue;} if(OrderComment()!= Com_H1){continue;} Ticket2 = OrderTicket(); } Sleep(1000); return(Ticket2); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ int OrderticketH11(string cmd) { int Ticket21 = 0; for(int i = 0 ; i < OrdersTotal() ; i++ ) { if(OrderSelect(i, SELECT_BY_POS,MODE_TRADES)==False) {continue;} if(OrderSymbol() != cmd){continue;} if(OrderMagicNumber()!= Magic_Number60){continue;} if(OrderComment()!= Com_H11){continue;} Ticket21 = OrderTicket(); } Sleep(1000); return(Ticket21); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ int OrderticketH4(string cmd) { int Ticket3 = 0; for(int i = 0 ; i < OrdersTotal() ; i++ ) { if(OrderSelect(i, SELECT_BY_POS,MODE_TRADES)==False) {continue;} if(OrderSymbol() != cmd){continue;} if(OrderMagicNumber()!= Magic_Number240){continue;} if(OrderComment()!= Com_H4){continue;} Ticket3 = OrderTicket(); } Sleep(1000); return(Ticket3); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ int OrderticketH41(string cmd) { int Ticket31 = 0; for(int i = 0 ; i < OrdersTotal() ; i++ ) { if(OrderSelect(i, SELECT_BY_POS,MODE_TRADES)==False) {continue;} if(OrderSymbol() != cmd){continue;} if(OrderMagicNumber()!= Magic_Number240){continue;} if(OrderComment()!= Com_H41){continue;} Ticket31 = OrderTicket(); } Sleep(1000); return(Ticket31); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ double OrderlotM15(string cmd) { double lot1 = 0; for(int i = 0 ; i < OrdersTotal() ; i++ ) { if(OrderSelect(i, SELECT_BY_POS,MODE_TRADES)==False) {continue;} if(OrderSymbol() != cmd){continue;} if(OrderMagicNumber()!= Magic_Number15){continue;} if(OrderComment()!= Com_M15){continue;} lot1 = OrderLots(); } Sleep(1000); return(lot1); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ double OrderlotM151(string cmd) { double lot11 = 0; for(int i = 0 ; i < OrdersTotal() ; i++ ) { if(OrderSelect(i, SELECT_BY_POS,MODE_TRADES)==False) {continue;} if(OrderSymbol() != cmd){continue;} if(OrderMagicNumber()!= Magic_Number15){continue;} if(OrderComment()!= Com_M151){continue;} lot11 = OrderLots(); } Sleep(1000); return(lot11); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ double OrderlotH1(string cmd) { double lot2 = 0; for(int i = 0 ; i < OrdersTotal() ; i++ ) { if(OrderSelect(i, SELECT_BY_POS,MODE_TRADES)==False) {continue;} if(OrderSymbol() != cmd){continue;} if(OrderMagicNumber()!= Magic_Number60){continue;} if(OrderComment()!= Com_H1){continue;} lot2 = OrderLots(); } Sleep(1000); return(lot2); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ double OrderlotH11(string cmd) { double lot21 = 0; for(int i = 0 ; i < OrdersTotal() ; i++ ) { if(OrderSelect(i, SELECT_BY_POS,MODE_TRADES)==False) {continue;} if(OrderSymbol() != cmd){continue;} if(OrderMagicNumber()!= Magic_Number60){continue;} if(OrderComment()!= Com_H11){continue;} lot21 = OrderLots(); } Sleep(1000); return(lot21); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ double OrderlotH4(string cmd) { double lot3 = 0; for(int i = 0 ; i < OrdersTotal() ; i++ ) { if(OrderSelect(i, SELECT_BY_POS,MODE_TRADES)==False) {continue;} if(OrderSymbol() != cmd){continue;} if(OrderMagicNumber()!= Magic_Number240){continue;} if(OrderComment()!= Com_H4){continue;} lot3 = OrderLots(); } Sleep(1000); return(lot3); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ double OrderlotH41(string cmd) { double lot31 = 0; for(int i = 0 ; i < OrdersTotal() ; i++ ) { if(OrderSelect(i, SELECT_BY_POS,MODE_TRADES)==False) {continue;} if(OrderSymbol() != cmd){continue;} if(OrderMagicNumber()!= Magic_Number240){continue;} if(OrderComment()!= Com_H41){continue;} lot31 = OrderLots(); } Sleep(1000); return(lot31); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+
Paste Settings
Paste Title :
[Optional]
Paste Folder :
[Optional]
Select
Syntax Highlighting :
[Optional]
Select
Markup
CSS
JavaScript
Bash
C
C#
C++
Java
JSON
Lua
Plaintext
C-like
ABAP
ActionScript
Ada
Apache Configuration
APL
AppleScript
Arduino
ARFF
AsciiDoc
6502 Assembly
ASP.NET (C#)
AutoHotKey
AutoIt
Basic
Batch
Bison
Brainfuck
Bro
CoffeeScript
Clojure
Crystal
Content-Security-Policy
CSS Extras
D
Dart
Diff
Django/Jinja2
Docker
Eiffel
Elixir
Elm
ERB
Erlang
F#
Flow
Fortran
GEDCOM
Gherkin
Git
GLSL
GameMaker Language
Go
GraphQL
Groovy
Haml
Handlebars
Haskell
Haxe
HTTP
HTTP Public-Key-Pins
HTTP Strict-Transport-Security
IchigoJam
Icon
Inform 7
INI
IO
J
Jolie
Julia
Keyman
Kotlin
LaTeX
Less
Liquid
Lisp
LiveScript
LOLCODE
Makefile
Markdown
Markup templating
MATLAB
MEL
Mizar
Monkey
N4JS
NASM
nginx
Nim
Nix
NSIS
Objective-C
OCaml
OpenCL
Oz
PARI/GP
Parser
Pascal
Perl
PHP
PHP Extras
PL/SQL
PowerShell
Processing
Prolog
.properties
Protocol Buffers
Pug
Puppet
Pure
Python
Q (kdb+ database)
Qore
R
React JSX
React TSX
Ren'py
Reason
reST (reStructuredText)
Rip
Roboconf
Ruby
Rust
SAS
Sass (Sass)
Sass (Scss)
Scala
Scheme
Smalltalk
Smarty
SQL
Soy (Closure Template)
Stylus
Swift
TAP
Tcl
Textile
Template Toolkit 2
Twig
TypeScript
VB.Net
Velocity
Verilog
VHDL
vim
Visual Basic
WebAssembly
Wiki markup
Xeora
Xojo (REALbasic)
XQuery
YAML
HTML
Paste Expiration :
[Optional]
Never
Self Destroy
10 Minutes
1 Hour
1 Day
1 Week
2 Weeks
1 Month
6 Months
1 Year
Paste Status :
[Optional]
Public
Unlisted
Private (members only)
Password :
[Optional]
Description:
[Optional]
Tags:
[Optional]
Encrypt Paste
(
?
)
Create New Paste
You are currently not logged in, this means you can not edit or delete anything you paste.
Sign Up
or
Login
Site Languages
×
English
Do you like cookies?
🍪 We use cookies to ensure you get the best experience on our website.
Learn more
I agree