Time: 2011-02-15 | Download file:Scalper.mq4
//+------------------------------------------------------------------+ //| !_rdb_Asisten_v3_ibfx.mq4 | //| Copyright © 2008, MetaQuotes Software Corp. | //| http://www.metaquotes.net | //+------------------------------------------------------------------+ /* #property copyright "rahman_DGBeta (_rdb_)" #property link "abdulrahman_maros@yahoo.com" #property show_inputs */ extern bool Mulai_Trading = true; //true extern bool Berhenti_Trading = false; //extern string For_All_Order = "Menutup Semua Order Sesuai Equity"; extern double Star_BALANCE = 0; extern double Max_Profit_Persen = 5; extern double Max_Loss_Persen = 25; //Persentase extern string For_All_Order = "kalau yang diatas diisi parameter ini tidak usah"; extern double Max_Equity = 0; extern double Min_Equity = 0; extern int TP_Trend_x_Spread = 7; //Perkiraan gerakan harga / kekuatan TP_Trend_x_Spread extern int SL_X_SPREAD = 0; //Pengali Spread untuk StopLoss sesuai TP_Trend_x_Spread (Spread*TP_Trend_x_Spread*SL_X_SPREAD) extern bool Fix_Spread = false; //Perkiraan gerakan harga / kekuatan TP_Trend_x_Spread extern int Spread_Tetap = 4; //Pengali Spread untuk StopLoss sesuai TP_Trend_x_Spread (Spread*TP_Trend_x_Spread*SL_X_SPREAD) //extern string __________oMn__________ = "Sama dengan trailing biasa di MT4"; extern bool Aktifkan_Trailing = true; extern int TrailingStop = 27; // Trailing ini sama dengan Trailing Normal di MT4 extern int TrailingLoss = 60; // Trailing ini sama dengan Trailing Normal di MT4 cuma mengangkat StopLoss string ___________oMn_________ = "Profit >= JagaSaatUntung"; extern int JagaSaatUntung = 18; extern int PenjagaUntung = 4; // Aktif jika Profit Point lebih besar dari PenjagaGawang*4 string JanganTutup_berFungsi = "Jika Analisa Pakai TP_Trend_x_Spread diatas"; extern bool TutupSemuaOrderProfit = false; //true, EA hanya menutup Order SELL extern bool TutupOrderProfit_Disini = false; //true, EA hanya menutup Order SELL extern bool TutupSemuaOrderLoss = false; //true, EA hanya menutup Order SELL extern bool TutupOrderLoss_Disini = false; //true, EA hanya menutup Order SELL extern bool JanganTutupOrderRugi = true; //true, EA hanya menutup extern bool JanganTutup_OP_BUY = false; //true, EA hanya menutup Order SELL extern bool JanganTutup_OP_SELL = false; //true, EA hanya menutup Order BUY extern string ________oMn____________ = "Menggunakan jumlah Point/Pips"; extern bool TP_SL_dengan_Jumlah_Point = false; //true, EA hanya berfungsi jika dipasang di semua chart yang ingin di tradingkan extern int TP = 35, SL = 25; //extern string ________oMn___________ = "Argumen diatas tidak dipakai"; //extern bool TP_SL_Bertingkat = false; //true, EA hanya berfungsi jika dipasang di semua chart yang ingin di tradingkan //extern int TingkatanSpread = 1; //extern string _________oMn________ = "Cuma ini yang aktif"; extern int TF = 5; extern bool tutup_dengan_P_Chanel = false; //true, EA hanya berfungsi jika dipasang di semua chart yang ingin di tradingkan extern bool tutup_dengan_NRTR = false; //true, EA hanya berfungsi jika dipasang di semua chart yang ingin di tradingkan extern bool tutup_dengan_NRTR_MACD_NL = false; //true, EA hanya berfungsi jika dipasang di semua chart yang ingin di tradingkan extern double KATR_NRTR = 2; //extern string NRTR_Period = "PERIOD_M15" ; extern bool tutup_dengan_nonlagma = false; //true, EA hanya berfungsi jika dipasang di semua chart yang ingin di tradingkan extern int nonlagma_Length = 15; bool Aktifkan_Bagi_Order = false; int Bagi_Order_Profit = 4; int Bagi_Order_Loss = 6; // Dikalikan dengan Spread Pairs extern string Pada_chart_EA_Aktif = "Menutup Langsung Order Aktif secara manual"; extern bool Hapus_Semuanya_disini = false; extern bool Hapus_OP_BUY = false; extern bool Hapus_OP_SELL = false; extern string OrderPending = "Menutup Langsung Order Pending secara manual"; extern bool HapusOrderPendingJika_No_OP=true; extern bool Hapus_OrderPending_ATAS = false; extern bool Hapus_OrderPending_BAWAH= false; extern bool Hapus_O_Pending_Disini = false; extern bool Hapus_Semua_O_Pending = false; string Slippage__ = "Maximum Deviasi Dari Harga"; extern int Slippage = 2; double point,tf,maxequity=0,minequity=0,persen_profit=0,persen_loss=0; int StartYear=2008; // Year to start (only for backtest) int StartMonth=1; // month to start (only for backtest) int EndYear=2009; // Year to stop trading (backtest and live) int EndMonth=12; // Month to stop trading (backtest and live) string Spread_sesuai_Broker = "Isikan manual sesuai broker"; int EURUSD=3,EURJPY=3,EURCHF=3,GBPUSD=3,GBPJPY=7,GBPCHF=7,USDJPY=3,USDCHF=3,AUDUSD=5,AUDJPY=5,AUDCHF=5, GOLD=100; string comment_text = "1"; // Untuk mengaktifkan pembagi order comment order harus sama dengan comment_text string option_0 = "Sapu Bersih Semua Order"; string option_1 = "Menjaga Order Sesuai Pair EA Aktif"; int option = 1; //pilihan metode tutup, "0" akan menutup semua order tanpa sisa //extern string ExpertAdvisorName = "OMN_Asisten_v9"; extern string CreatedBy = "rahman_Dg_Beta"; bool Izinkan_Buka_Posisi = true; int TakeProfit =45; // OP_SELL & OP_BUY int StopLoss =75; // OP_SELL & OP_BUY int MaxTrades =1; // Maximal orders terbuka string TimeFrameStr; int MagicNumber=00000000; // Magic number for the orders placed double Lots =0.1; // We start with this lots number int mm =1; // if one the lots size will increase based on account size double PersenModal =5; // PersenModalMasuk to calculate the lots size (only if mm is enabled) int AccountType =100000; // 0 if Normal Lots, 1 for mini lots, 2 for micro lots double Max_Lot = 6; double Percen_Lot = 1; double Percen_Lot_Strong = 2; double lotsi=0, mylotsi=0,myspread=0; int OpenOrders=0, cnt=0, total=0; int OpenMarketOrders=0,LimitOpenOrders=0; int LastOrderProfit=0, LastOrderOpen=0, LastOrderClose=0, LastOrderLot=0, LastBalance=0; int LastTicket=0, LastType=0,Sign; double LastClosePrice=0, LastLots=0,tp=0,sl=0; bool ContinueOpening=True; double LastPrice=0, LastPrice1=0; int PreviousOpenOrders=0; double Profit=0; double PipValue=0; datetime LastOrderOpenTime=0; //+------------------------------------------------------------------+ double longActive=0, shortActive=0; double longStop=0, shortStop=0; double longLimit=0, shortLimit=0; double longPending=0, shortPending=0; double allLong=0, allShort=0; double allActive=0, allPending=0; double grandTotal=0; double actualProfitMonitor=0; double actualProfitMonitor_pip=0; double ShortProfit=0; double LongProfit=0; double longActiveLot=0, shortActiveLot=0, longActiveLot1=0, shortActiveLot1=0; double longStopLot=0, shortStopLot=0; double longLimitLot=0, shortLimitLot=0; double longPendingLot=0, shortPendingLot=0; double allLongLot=0, allShortLot=0; double allActiveLot=0,allActiveLot1=0, allPendingLot=0; double grandTotalLot=0; //+---------------------------------------------------- ******** || ********* ------------------------------------------------+ //+---------------------------------------------------- ******** || ********* ------------------------------------------------+ int start() { //double volume10 =iVolume(NULL,PERIOD_M5,0); //if(volume10>1) return; //if (Symbol() == "USDJPY" || Symbol() == "EURJPY" || Symbol() == "GBPJPY") { point = 0.01; } //else { point = 0.0001; } if (mm!=0) { lotsi=(AccountBalance()*PersenModal/AccountType); } else { lotsi=Lots; } if (lotsi<0.1) lotsi=0.1; if (lotsi>100) lotsi=100; //---- //+---------------------------------------------------- ******** || ********* ------------------------------------------------+ actualProfitMonitor=0; actualProfitMonitor_pip=0; ShortProfit=0; LongProfit=0; longActive=0; shortActive=0; longStop=0; shortStop=0; longLimit=0; shortLimit=0; longPending=0; shortPending=0; allLong=0; allShort=0; allActive=0; allPending=0; grandTotal=0; longActiveLot=0; shortActiveLot=0; longActiveLot1=0; shortActiveLot1=0; longStopLot=0; shortStopLot=0; longLimitLot=0; shortLimitLot=0; longPendingLot=0; shortPendingLot=0; allLongLot=0; allShortLot=0; allActiveLot=0; allActiveLot1=0; allPendingLot=0; grandTotalLot=0; double mylotbl=0,myloteq=0,Max_Lot1=0,Percen_Lot1=0,Percen_Lot2=0,Long_Active_Lot=0,Short_Active_Lot=0,Net_Lot=0,Percen_NetLot, Percen_LotB=0,Percen_LotS=0,Percen_LotBS=0,Profit_Loss=0,LotHere=0,AllLotPercen=0,MyLotPercen=0; for(cnt=OrdersTotal()-1;cnt>=0;cnt--) { OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); if (OrderType()==OP_BUY) { longActive++; actualProfitMonitor += OrderProfit(); actualProfitMonitor_pip += ( (OrderOpenPrice()-MarketInfo(OrderSymbol(),MODE_BID)) / (MarketInfo(OrderSymbol(),MODE_POINT)) ); longActiveLot += OrderLots(); } if((OrderSymbol()==Symbol()) && (OrderType()==OP_BUY)) { longActiveLot1 += OrderLots();LongProfit += OrderProfit(); } else if (OrderType()==OP_SELL) { shortActive++; actualProfitMonitor += OrderProfit(); actualProfitMonitor_pip += ( (OrderOpenPrice()-MarketInfo(OrderSymbol(),MODE_ASK)) / (MarketInfo(OrderSymbol(),MODE_POINT)) ); shortActiveLot += OrderLots(); } if((OrderSymbol()==Symbol()) && (OrderType()==OP_SELL)) { shortActiveLot1 += OrderLots(); ShortProfit += OrderProfit(); } else if (OrderType()==OP_BUYSTOP) longStop++; else if (OrderType()==OP_SELLSTOP) shortStop++; else if (OrderType()==OP_BUYLIMIT) longLimit++; else if (OrderType()==OP_SELLLIMIT) shortLimit++; }//for longPending = longStop + longLimit; shortPending = shortStop + shortLimit; allPending = longPending + shortPending; allActive = longActive + shortActive; allLong = longStop + longLimit + longActive; allShort = shortStop + shortLimit + shortActive; grandTotal = allActive + allPending; longPendingLot = longStopLot + longLimitLot; shortPendingLot = shortStopLot + shortLimitLot; allPendingLot = longPendingLot + shortPendingLot; allLongLot = longStopLot + longLimitLot + longActiveLot; allShortLot = shortStopLot + shortLimitLot + shortActiveLot; grandTotalLot = allActiveLot + allPendingLot; allActiveLot = longActiveLot + shortActiveLot; allActiveLot1 = longActiveLot1 + shortActiveLot1; mylotbl = AccountBalance()/AccountType; myloteq = AccountEquity()/AccountType; Max_Lot1 = (Max_Lot/myloteq)*100; Percen_Lot1 = (Percen_Lot*myloteq)/100; // 5*2/100=0.1 lot Percen_Lot2 = (Percen_Lot_Strong*myloteq)/100; //10*2/100=0.2 lot Long_Active_Lot = longActiveLot1; Short_Active_Lot = shortActiveLot1; Net_Lot = longActiveLot1-shortActiveLot1; Percen_LotB = (Long_Active_Lot/myloteq)*100; Percen_LotS = (Short_Active_Lot/myloteq)*100; //0.1/2*100 =5% Percen_LotBS = ((Long_Active_Lot+Short_Active_Lot)/myloteq)*100; if(longActiveLot1-shortActiveLot1>0) Percen_NetLot = ((longActiveLot1-shortActiveLot1)/myloteq)*100; else if(longActiveLot1-shortActiveLot1<0) Percen_NetLot = (((longActiveLot1-shortActiveLot1)*(-1))/myloteq)*100; Profit_Loss = LongProfit+ShortProfit; LotHere = Long_Active_Lot+Short_Active_Lot; AllLotPercen = (allActiveLot/myloteq)*100; MyLotPercen = (myloteq/mylotbl)*100; //+------------------------------------------------------------------+ // bool result; OpenOrders=0; OpenMarketOrders=0; LimitOpenOrders=0; for(cnt=0;cntOP_SELL) //pending orders OrderDelete(OrderTicket()); } break; //+---------------------------------------------------- ******** || ********* ------------------------------------------------+ //+---------------------------------------------------- ******** || ********* ------------------------------------------------+ case 1: string mysymbol=""; /* if (Symbol() == "AUDCAD" || Symbol() == "AUDCAD.") { mysymbol = "AUDCAD"; } else if (Symbol() == "AUDCHF" || Symbol() == "AUDCHF.") { mysymbol = "AUDCHF"; } else if (Symbol() == "AUDJPY" || Symbol() == "AUDJPY.") { mysymbol = "AUDJPY"; } else if (Symbol() == "AUDNZD" || Symbol() == "AUDNZD.") { mysymbol = "AUDNZD"; } else if (Symbol() == "AUDUSD" || Symbol() == "AUDUSD.") { mysymbol = "AUDUSD"; } else if (Symbol() == "CHFJPY" || Symbol() == "CHFJPY.") { mysymbol = "CHFJPY"; } else if (Symbol() == "EURAUD" || Symbol() == "EURAUD.") { mysymbol = "EURAUD"; } else if (Symbol() == "EURCAD" || Symbol() == "EURCAD.") { mysymbol = "EURCAD"; } else if (Symbol() == "EURCHF" || Symbol() == "EURCHF.") { mysymbol = "EURCHF"; } else if (Symbol() == "EURGBP" || Symbol() == "EURGBP.") { mysymbol = "EURGBP"; } else if (Symbol() == "EURJPY" || Symbol() == "EURJPY.") { mysymbol = "EURJPY"; } else if (Symbol() == "EURUSD" || Symbol() == "EURUSD.") { mysymbol = "EURUSD"; } else if (Symbol() == "GBPCHF" || Symbol() == "GBPCHF.") { mysymbol = "GBPCHF"; } else if (Symbol() == "GBPCAD" || Symbol() == "GBPCAD.") { mysymbol = "GBPCAD"; } else if (Symbol() == "GBPJPY" || Symbol() == "GBPJPY.") { mysymbol = "GBPJPY"; } else if (Symbol() == "GBPUSD" || Symbol() == "GBPUSD.") { mysymbol = "GBPUSD"; } else if (Symbol() == "NZDCAD" || Symbol() == "NZDCAD.") { mysymbol = "NZDCAD"; } else if (Symbol() == "NZDCHF" || Symbol() == "NZDCHF.") { mysymbol = "NZDCHF"; } else if (Symbol() == "NZDJPY" || Symbol() == "NZDJPY.") { mysymbol = "NZDJPY"; } else if (Symbol() == "NZDUSD" || Symbol() == "NZDUSD.") { mysymbol = "NZDUSD"; } else if (Symbol() == "USDCHF" || Symbol() == "USDCHF.") { mysymbol = "USDCHF"; } else if (Symbol() == "USDJPY" || Symbol() == "USDJPY.") { mysymbol = "USDJPY"; } else if (Symbol() == "USDCAD" || Symbol() == "USDCAD.") { mysymbol = "USDCAD"; } else { mysymbol = Symbol(); } */ mysymbol = Symbol(); double MC0 =iMACD(NULL,TF,12,26,9,0,MODE_MAIN,1); // Main double MC1 =iMACD(NULL,TF,12,26,9,0,MODE_SIGNAL,1); // Signal, Line double NL1 =iCustom(NULL,TF ,"NonLagMA_v7.1",0,nonlagma_Length,0,0,1,1,0,0,0,2,1); //DnBuffer (W1 W2) double NRTR =iCustom(NULL,TF,"NRTR_Rosh_v2eAlert_mtf",45,KATR_NRTR,false,false,true,1,0,0,"","",0,1); // double PC1 =iCustom(NULL,TF,"PriceChannel_Stop_v6",5,0.2,1,1,1,0,500,5,1); //3 double PC2 =iCustom(NULL,TF,"PriceChannel_Stop_v6",5,0.2,1,1,1,0,500,4,1); //4 double closebar = iClose (NULL,TF,1); //+----- || total = OrdersTotal(); cnt=OrdersTotal()-1; while(cnt>=0) { if(OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES)==false) break; if(Mulai_Trading==true) { //+---------------------------------------------------- ******** || ********* ------------------------------------------------+ //+----- || Matrix Pengali TP_Trend_x_Spread dan Spread untuk di aplikasikan ke dalam TakeProfit dan StopLoss sesuai Pair // TP_TREND_X_SPREAD 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 // Pair Spread TP SL TP SL TP SL TP SL TP SL TP SL TP SL TP SL TP SL TP SL TP SL TP SL TP SL TP SL TP SL //(Symbol()=="EURUSD") 2 0 2 8 4 10 6 12 8 14 10 16 12 18 14 20 16 22 18 24 20 26 22 28 24 30 26 32 28 34 30 36 //(Symbol()=="EURJPY") 3 0 3 12 6 15 9 18 12 21 15 24 18 27 21 30 24 33 27 36 30 39 33 42 36 45 39 48 42 51 45 54 //(Symbol()=="EURCHF") 3 0 3 12 6 15 9 18 12 21 15 24 18 27 21 30 24 33 27 36 30 39 33 42 36 45 39 48 42 51 45 54 //(Symbol()=="GBPUSD") 3 0 3 12 6 15 9 18 12 21 15 24 18 27 21 30 24 33 27 36 30 39 33 42 36 45 39 48 42 51 45 54 //(Symbol()=="GBPJPY") 5 0 5 20 10 25 15 30 20 35 25 40 30 45 35 50 40 55 45 60 50 65 55 70 60 75 65 80 70 85 75 90 //(Symbol()=="GBPCHF") 5 0 5 20 10 25 15 30 20 35 25 40 30 45 35 50 40 55 45 60 50 65 55 70 60 75 65 80 70 85 75 90 //(Symbol()=="USDJPY") 2 0 2 8 4 10 6 12 8 14 10 16 12 18 14 20 16 22 18 24 20 26 22 28 24 30 26 32 28 34 30 36 //(Symbol()=="USDCHF") 3 0 3 12 6 15 9 18 12 21 15 24 18 27 21 30 24 33 27 36 30 39 33 42 36 45 39 48 42 51 45 54 //SL_X_SPREAD 3 //+---------------------------------------------------- ******** || ********* ------------------------------------------------+ if(Fix_Spread==true) {myspread=Spread_Tetap;} else {myspread=((MarketInfo(OrderSymbol(),MODE_ASK))-(MarketInfo(OrderSymbol(),MODE_BID)));} //+---------------------------------------------------- ******** || ********* ------------------------------------------------+ if (TP_SL_dengan_Jumlah_Point==false && (OrderSymbol()==mysymbol)) { //POSISI BUYYYYYYYYYYYYYYYYY if((OrderType()==OP_BUY)) { if(JanganTutup_OP_BUY==false) { //+----- || TakeProfit if ((TP_Trend_x_Spread>0) && (OrderTakeProfit()==0) && ((MarketInfo(OrderSymbol(),MODE_BID))>=(OrderOpenPrice()+((myspread*TP_Trend_x_Spread))))) { OrderClose(OrderTicket(),OrderLots(),(MarketInfo(OrderSymbol(),MODE_BID)),Slippage,Blue); //PlaySound("excellent_a.wav"); return(0); } //+----- || StopLoss if ((SL_X_SPREAD>0) && (OrderStopLoss()==0) && ((MarketInfo(OrderSymbol(),MODE_BID))<=(OrderOpenPrice()-((myspread*(SL_X_SPREAD)))))) { OrderClose(OrderTicket(),OrderLots(),(MarketInfo(OrderSymbol(),MODE_BID)),Slippage,Blue); //PlaySound("oh_man.wav"); return(0); } } //OP_BUY } //POSISI SELLLLLLLLLLLLLL if((OrderType()==OP_SELL)) { if(JanganTutup_OP_SELL==false) { //+----- || TakeProfit if ((TP_Trend_x_Spread>0) && (OrderTakeProfit()==0) && ((MarketInfo(OrderSymbol(),MODE_ASK))<=(OrderOpenPrice()-((myspread*TP_Trend_x_Spread)))))// && (close1>open1)) { OrderClose(OrderTicket(),OrderLots(),(MarketInfo(OrderSymbol(),MODE_ASK)),Slippage,Red); //PlaySound("excellent_a.wav"); return(0); } //+----- || StopLoss if ((SL_X_SPREAD>0) && (OrderStopLoss()==0) && ((MarketInfo(OrderSymbol(),MODE_ASK))>=(OrderOpenPrice()+((myspread*(SL_X_SPREAD)))))) { OrderClose(OrderTicket(),OrderLots(),(MarketInfo(OrderSymbol(),MODE_ASK)),Slippage,Red); //PlaySound("oh_man.wav"); return(0); } } //OP_BUY } } //TP_SL_dengan_Jumlah_Point //+---------------------------------------------------- ******** || ********* ------------------------------------------------+ //+---------------------------------------------------- ******** || ********* ------------------------------------------------+ //+---------------------------------------------------- ******** || ********* ------------------------------------------------+ //+---------------------------------------------------- ******** || ********* ------------------------------------------------+ //+----- || //POSISI BUYYYYYYYYYYYYYYYYY if((OrderType()==OP_BUY) && (OrderSymbol()==Symbol())) { //+----- || Aktifkan Menutup dengan Indikator NonLagMA Length 17 if(tutup_dengan_nonlagma==true && (NL1 TargetMax)|| (AccountEquity() = OrderOpenPrice())// || (AccountEquity()>TargetMax)|| (AccountEquity() =OrderOpenPrice()) //indikasi NRTR NAIK { OrderClose(OrderTicket(),OrderLots(),(MarketInfo(OrderSymbol(),MODE_BID)),Slippage,Yellow); //PlaySound("CONGRATS.WAV"); return(0); } if(tutup_dengan_P_Chanel==true && (PC1 = OrderOpenPrice())// || (AccountEquity()>TargetMax)|| (AccountEquity() = OrderOpenPrice())// || (AccountEquity()>TargetMax)|| (AccountEquity() 0) && // && (tutup_dengan_nonlagma==false) && (tutup_dengan_NRTR_MACD_NL==false) ((MarketInfo(OrderSymbol(),MODE_BID))>=(OrderOpenPrice()+(TP*Point)))) { OrderClose(OrderTicket(),OrderLots(),(MarketInfo(OrderSymbol(),MODE_BID)),Slippage,Blue); //PlaySound("excellent_a.wav"); return(0); } //+----- || StopLoss Semua Symbol disamakan if(TP_SL_dengan_Jumlah_Point==true && (SL>0) && ((MarketInfo(OrderSymbol(),MODE_BID))<=(OrderOpenPrice()-(SL*Point)))) { OrderClose(OrderTicket(),OrderLots(),(MarketInfo(OrderSymbol(),MODE_BID)),Slippage,Blue); //PlaySound("oh_man.wav"); return(0); } //+----- || Menghapus Order Buy Aktif pada symbol EA dijalankan if((Hapus_OP_BUY==true)) { OrderClose(OrderTicket(),OrderLots(),(MarketInfo(OrderSymbol(),MODE_BID)),Slippage,Blue); //PlaySound("oh_man.wav"); return(0); } } //+---------------------------------------------------- ******** || ********* ------------------------------------------------+ if((OrderType()==OP_BUY)) { persen_profit=Star_BALANCE*Max_Profit_Persen/100; //Max_Loss_Persen=Max_Profit_Persen/PembagiMaxMin; persen_loss=Star_BALANCE*Max_Loss_Persen/100; maxequity=NormalizeDouble((Star_BALANCE+persen_profit),2); minequity=NormalizeDouble((Star_BALANCE-persen_loss),2); //+----- || Menghapus Semua Order saat Equity melebihi TargetMax if((Star_BALANCE>1) && (AccountEquity()>maxequity)) { OrderClose(OrderTicket(),OrderLots(),(MarketInfo(OrderSymbol(),MODE_BID)),Slippage,Blue); //PlaySound("ringmybell.wav"); return(0); } //+----- || Menghapus Semua Order saat Equity Kurang dari TargetMin if((Star_BALANCE>1) && (AccountEquity() NL2) && (JanganTutup_OP_SELL==false) && JanganTutupOrderRugi==false)// || (AccountEquity()>TargetMax)|| (AccountEquity() NL2) && (JanganTutup_OP_SELL==false) && JanganTutupOrderRugi==true && Ask <= OrderOpenPrice())// || (AccountEquity()>TargetMax)|| (AccountEquity() PC2) && (JanganTutup_OP_SELL==false) && JanganTutupOrderRugi==true && Ask<=OrderOpenPrice()) //indikasi NRTR NAIK { OrderClose(OrderTicket(),OrderLots(),(MarketInfo(OrderSymbol(),MODE_ASK)),Slippage,Yellow); //PlaySound("CONGRATS.WAV"); return(0); } if(tutup_dengan_P_Chanel==true && (PC1>PC2) && (JanganTutup_OP_SELL==false) && JanganTutupOrderRugi==false) //indikasi NRTR NAIK { OrderClose(OrderTicket(),OrderLots(),(MarketInfo(OrderSymbol(),MODE_ASK)),Slippage,Yellow); //PlaySound("CONGRATS.WAV"); return(0); } //+----- || Aktifkan Menutup dengan Indikator NRTR Periode_M15 if(tutup_dengan_NRTR==true && (closebar>NRTR) && (JanganTutup_OP_SELL==false) && JanganTutupOrderRugi==false) //indikasi NRTR NAIK { OrderClose(OrderTicket(),OrderLots(),(MarketInfo(OrderSymbol(),MODE_ASK)),Slippage,Yellow); //PlaySound("CONGRATS.WAV"); return(0); } if(tutup_dengan_NRTR==true && (closebar>NRTR) && (JanganTutup_OP_SELL==false) && JanganTutupOrderRugi==true && Ask <= OrderOpenPrice())// || (AccountEquity()>TargetMax)|| (AccountEquity() NRTR)&&(MC0>MC1) && (NL1>NL2) && (JanganTutup_OP_SELL==false) && JanganTutupOrderRugi==false) //indikasi NRTR NAIK { OrderClose(OrderTicket(),OrderLots(),(MarketInfo(OrderSymbol(),MODE_ASK)),Slippage,Yellow); //PlaySound("CONGRATS.WAV"); return(0); } if(tutup_dengan_NRTR_MACD_NL==true && (closebar>NRTR)&&(MC0>MC1) && (NL1>NL2) && (JanganTutup_OP_SELL==false) && JanganTutupOrderRugi==true && Ask <= OrderOpenPrice())// || (AccountEquity()>TargetMax)|| (AccountEquity() 0) && // && (tutup_dengan_nonlagma==false) && (tutup_dengan_NRTR_MACD_NL==false) ((MarketInfo(OrderSymbol(),MODE_ASK)) <=(OrderOpenPrice()-(TP*Point)))) { OrderClose(OrderTicket(),OrderLots(),(MarketInfo(OrderSymbol(),MODE_ASK)),Slippage,Violet); //PlaySound("WOODY.WAV"); return(0); } //+----- || StopLoss Semua Symbol disamakan if(TP_SL_dengan_Jumlah_Point==true && (SL>0) && ((MarketInfo(OrderSymbol(),MODE_ASK))>=(OrderOpenPrice()+(SL*Point)))) { OrderClose(OrderTicket(),OrderLots(),(MarketInfo(OrderSymbol(),MODE_ASK)),Slippage,Violet); //PlaySound("oh_man.wav"); return(0); } //+----- || Menghapus Order Buy Aktif pada symbol EA dijalankan if((Hapus_OP_SELL==true)) { OrderClose(OrderTicket(),OrderLots(),(MarketInfo(OrderSymbol(),MODE_ASK)),Slippage,Violet); //PlaySound("oh_man.wav"); return(0); } } //+---------------------------------------------------- ******** || ********* ------------------------------------------------+ if((OrderType()==OP_SELL)) { //+----- || Menghapus Semua Order saat Equity melebihi TargetMax persen_profit=Star_BALANCE*Max_Profit_Persen/100; //Max_Loss_Persen=Max_Profit_Persen/PembagiMaxMin; persen_loss=Star_BALANCE*Max_Loss_Persen/100; maxequity=NormalizeDouble((Star_BALANCE+persen_profit),2); minequity=NormalizeDouble((Star_BALANCE-persen_loss),2); if((Star_BALANCE>1) && (AccountEquity()>maxequity)) { OrderClose(OrderTicket(),OrderLots(),(MarketInfo(OrderSymbol(),MODE_ASK)),Slippage,Violet); //PlaySound("BINGBING.WAV"); return(0); } //+----- || Menghapus Semua Order saat Equity Kurang dari TargetMin if((Star_BALANCE>1) && (AccountEquity() 1) { if((AccountEquity()>=maxequity) || (AccountEquity()<=minequity)) { OrderDelete(OrderTicket()); } } } //+---------------------------------------------------- ******** || ********* ------------------------------------------------+ //+---------------------------------------------------- ******** || ********* ------------------------------------------------+ //+----- || Menghapus Order Pending secara manual pada Pair yang diinginkan if((OrderSymbol()==Symbol()) && ((OrderType()==OP_SELLLIMIT || OrderType()==OP_BUYLIMIT || OrderType()==OP_BUYSTOP || OrderType()==OP_SELLSTOP))) //del pending orders { if(Hapus_O_Pending_Disini==true) { OrderDelete(OrderTicket()); } } //+----- || Menghapus Semua Order Pending secara manual if((OrderType()==OP_SELLLIMIT || OrderType()==OP_BUYLIMIT || OrderType()==OP_BUYSTOP || OrderType()==OP_SELLSTOP)) //del pending orders { if(Hapus_Semua_O_Pending==true) { OrderDelete(OrderTicket()); } } //+----- || Menghapus Semua Order Pending secara manual yang berada diatas harga sekarang if((OrderSymbol()==Symbol()) && (OrderType()==OP_SELLLIMIT || OrderType()==OP_BUYSTOP)) //del pending orders { if(Hapus_OrderPending_ATAS==true) { OrderDelete(OrderTicket()); } } //+----- || Menghapus Semua Order Pending secara manual yang berada dibawah harga sekarang if((OrderSymbol()==Symbol()) && (OrderType()==OP_BUYLIMIT || OrderType()==OP_SELLSTOP)) //del pending orders { if(Hapus_OrderPending_BAWAH==true) { OrderDelete(OrderTicket()); } } //+---------------------------------------------------- ******** || ********* ------------------------------------------------+ //+----- || Menghapus Order Pending saat tidak ada OP if((HapusOrderPendingJika_No_OP==true) && allActiveLot1==0 && (OrderSymbol()==mysymbol)) { if(OrderType()>OP_SELL) //pending orders OrderDelete(OrderTicket()); } //+---------------------------------------------------- ******** || ********* ------------------------------------------------+ //+----- || Berhenti Trading___ / Menghapus Langsung Semua Order yang ada secara manual if((OrderSymbol()==mysymbol) && Hapus_Semuanya_disini==true) { if(OrderType()==OP_BUY) OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_BID),Slippage,White); if(OrderType()==OP_SELL) OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_ASK),Slippage,White); if(OrderType()>OP_SELL) //pending orders OrderDelete(OrderTicket()); } if(Berhenti_Trading==true) { if(OrderType()==OP_BUY) OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_BID),Slippage,White); if(OrderType()==OP_SELL) OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_ASK),Slippage,White); if(OrderType()>OP_SELL) //pending orders OrderDelete(OrderTicket()); } //+---------------------------------------------------- ******** || ********* ------------------------------------------------+ //---Tutup dengan Max_Equity atau Min_Equity if((Max_Equity>1 && AccountEquity()>=Max_Equity) || (Min_Equity>1 && AccountEquity()<=Min_Equity)) { if(OrderType()==OP_BUY) OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_BID),Slippage,White); if(OrderType()==OP_SELL) OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_ASK),Slippage,White); if(OrderType()>OP_SELL) //pending orders OrderDelete(OrderTicket()); } //+---------------------------------------------------- ******** || ********* ------------------------------------------------+ //---TutupOrderProfit if(TutupSemuaOrderProfit==true) { if((OrderType()==OP_BUY) && (OrderClosePrice()>OrderOpenPrice())) OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_BID),Slippage,White); if((OrderType()==OP_SELL) && (OrderClosePrice() OrderOpenPrice())) OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_BID),Slippage,White); if(OrderSymbol()==Symbol()&&(OrderType()==OP_SELL) && (OrderClosePrice() OrderOpenPrice())) OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_ASK),Slippage,White); } if(TutupOrderLoss_Disini==true) { if(OrderSymbol()==Symbol()&&(OrderType()==OP_BUY) && (OrderClosePrice() OrderOpenPrice())) OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_ASK),Slippage,White); } //+---------------------------------------------------- ******** || ********* ------------------------------------------------+ if(Aktifkan_Trailing==true) { //TRAILING STOP BUY if ((OrderType()==OP_BUY) && (OrderSymbol() == Symbol())) { if((PenjagaUntung>0) && (JagaSaatUntung>0)) { if (((MarketInfo(OrderSymbol(),MODE_BID))-OrderOpenPrice())>(JagaSaatUntung*Point)) { if ((OrderStopLoss()<(OrderOpenPrice())) || OrderStopLoss()==0) //kalimat ini yang membbuatnya tidak kembali-kembali { OrderModify(OrderTicket(),OrderOpenPrice(),((OrderOpenPrice())+(PenjagaUntung*Point)),OrderTakeProfit(),Lime); return(0); } } } if(TrailingStop>0) { if (((MarketInfo(OrderSymbol(),MODE_BID))-OrderOpenPrice())>(TrailingStop*Point)) { if ((OrderStopLoss()<((MarketInfo(OrderSymbol(),MODE_BID))-(TrailingStop*Point))) || OrderStopLoss()==0) { OrderModify(OrderTicket(),OrderOpenPrice(),((MarketInfo(OrderSymbol(),MODE_BID))-(TrailingStop*Point)),OrderTakeProfit(),Lime); return(0); } } } if(TrailingLoss>0) { //if ((OrderOpenPrice()-(MarketInfo(OrderSymbol(),MODE_BID)))>(TrailingLoss*Point)) //{ if ((OrderStopLoss()<((MarketInfo(OrderSymbol(),MODE_BID))-(TrailingLoss*Point))) || OrderStopLoss()==0) { OrderModify(OrderTicket(),OrderOpenPrice(),((MarketInfo(OrderSymbol(),MODE_BID))-(TrailingLoss*Point)),OrderTakeProfit(),Lime); return(0); } //} } } //+---------------------------------------------------- ******** || ********* ------------------------------------------------+ //TRAILING STOP SELL if((OrderType() == OP_SELL) && (OrderSymbol() == Symbol())) { if((PenjagaUntung>0) && (JagaSaatUntung>0)) { if ((OrderOpenPrice()-(MarketInfo(OrderSymbol(),MODE_ASK)))>(JagaSaatUntung*Point)) { if (((OrderStopLoss())>(OrderOpenPrice())) || (OrderStopLoss()==0)) { OrderModify(OrderTicket(),OrderOpenPrice(),((OrderOpenPrice())-(PenjagaUntung*Point)),OrderTakeProfit(),Red); return(0); } } } if(TrailingStop>0) { if ((OrderOpenPrice()-(MarketInfo(OrderSymbol(),MODE_ASK)))>(TrailingStop*Point)) { if ((OrderStopLoss()>((MarketInfo(OrderSymbol(),MODE_ASK))+(TrailingStop*Point))) || OrderStopLoss()==0) { OrderModify(OrderTicket(),OrderOpenPrice(),((MarketInfo(OrderSymbol(),MODE_ASK))+(TrailingStop*Point)),OrderTakeProfit(),Red); return(0); } } } if(TrailingLoss>0) { //if ((OrderOpenPrice()-(MarketInfo(OrderSymbol(),MODE_ASK)))>(TrailingLoss*Point)) //{ if ((OrderStopLoss()>((MarketInfo(OrderSymbol(),MODE_ASK))+(TrailingLoss*Point))) || OrderStopLoss()==0) { OrderModify(OrderTicket(),OrderOpenPrice(),((MarketInfo(OrderSymbol(),MODE_ASK))+(TrailingLoss*Point)),OrderTakeProfit(),Red); return(0); } //} } } } //+---------------------------------------------------- ******** || ********* ------------------------------------------------+ //+---------------------------------------------------- ******** || ********* ------------------------------------------------+ } cnt--; } //while(cnt>=0) // break; //+---------------------------------------------------- ******** || ********* ------------------------------------------------+ }//switch (option) return(0);}//int CloseAll()