//+---//+---+---+ //| //| EA EA RahasiaMartingale.mq4 RahasiaMartingale.mq4 || //| //| @DwiMalistyo @DwiMalistyo || //| //| http://ea.dwim.web.id http://ea.dwim.web.id || //+---//+---+---+ //
// ***** ***** Modified Modified for for RieLove RieLove System System ***** ***** //// #property copyright "@DwiMalistyo"
#property copyright "@DwiMalistyo" #property
#property link link "http://ea.dwim.web.id"http://ea.dwim.web.id"" //
// Konsep Trading Konsep Trading Martingale Martingale ini ini diambil diambil dari dari thread thread milik milik master master Purwanto8888Purwanto8888 //
// //
// "Rahasia "Rahasia Martingale Martingale System, System, 7 7 Tahun Tahun WD WD terus" terus" :: //
//
//http://indo.mt5.com/
//http://indo.mt5.com/showthread.php?6432-Rahashowthread.php?6432-Rahasia-martingale-system-7-tsia-martingale-system-7-tahun-WD-tahun-WD-t erus// erus// // // //Disclaimer: //Disclaimer: //
// Robot Robot EA EA hanyalah hanyalah alat alat bantu bantu untuk untuk trading trading forex.forex. //
// Segala Segala resiko resiko yang yang timbul timbul dari dari penggunaan penggunaan robot robot EA EA sepenuhnya sepenuhnya menjamenja di
di //
// tanggungjawab tanggungjawab pengguna.pengguna.
/*-- Parameter ini ditampilkan di EA dan bisa diubah --*/ /*-- Parameter ini ditampilkan di EA dan bisa diubah --*/ extern
extern int int TakeProfit TakeProfit = = 15; 15; // Nilai // Nilai TP TP setiap setiap OP OP di di EA EA Martingale Martingale iniini extern int
extern int PipStep PipStep = = 10; 10; // // Jarak Jarak pip pip dimana dimana akan akan buka buka OP OP barubaru extern
extern int int SL_level SL_level = = 3; 3; // // Penempatan Penempatan stoploss stoploss pada pada grid grid martingalmartingal e
e
extern int
extern int Slippage Slippage = 3; = 3; // // Apa Apa itu itu slippage slippage ? ? Googling Googling sendiri sendiri ya.ya. .
.
extern doubl
extern double Lots e Lots = 0.01; = 0.01; // // Nilai Nilai lots lots awal, awal, nantinya nantinya akan akan digandadiganda kan setiap step
kan setiap step extern
extern double double Multiply Multiply = = 2.0; 2.0; // // Nilai Nilai pengali pengali setiap setiap step step OP OP barubaru extern int
extern int MaxTrade MaxTrade = = 11; 11; // // Banyak Banyak OP OP maksimal maksimal yang yang boleh boleh dijalankandijalankan //extern
//extern bool bool UseTime UseTime = = false;// false;// Pilihan Pilihan untuk untuk membatasi membatasi kerja kerja EA EA dengdeng an waktu atau tidak.
an waktu atau tidak. extern int
extern int HourStart HourStart = 0; = 0; // // Awal Awal jam jam kerja kerja EA EA (Waktu (Waktu server)server) extern
extern int int HourEnd HourEnd = = 24; 24; // // Akhir Akhir jam jam kerja kerja EA EA (Waktu (Waktu server)server) extern
extern int int EAMagicNumber = EAMagicNumber = 8095; 8095; // // Magic Magic NumberNumber /*-- Parameter ini tidak ditampilkan di EA --*/
/*-- Parameter ini tidak ditampilkan di EA --*/ string
string EAName EAName = = "EA "EA RahasiaMartingale\nCodRahasiaMartingale\nCoding ing by: by: DwiM-Modified"DwiM-Modified" ; // Nama EA, untuk ditampilkan di layar
; // Nama EA, untuk ditampilkan di layar string
string EAComment EAComment = = "DwiM"; "DwiM"; // // Variabel Variabel ini ini akak an kita masukkan di setiap OP sebagai Comment
an kita masukkan di setiap OP sebagai Comment double
double SetPoint SetPoint = = 0; 0; // // Variabel Variabel SetPoiSetPoi nt untuk kode digit broker 4 atau 5
nt untuk kode digit broker 4 atau 5 double
double Stoploss Stoploss = = 0;0; //string
//string Pair Pair = = "USDCAD";"USDCAD";
//+---//+---+---+ //|
//| expert expert initialization initialization function function || //+---//+---+---+ int init() int init() { { //---- SetBroker(); SetBroker();
//---- return(0); }
//+---+
//| expert deinitialization function |
//+---+ int deinit() { //---- return(0); } //+---+
//| expert start function |
//+---+ int start() { //---- int iTrade=0; int TotalBuy = 0; int TotalSell = 0;
/*-- Fungsi ini untuk memastikan EA hanya dijalankan di Pair USCAD-- if(Symbol()!=Pair)
{
Comment("Wrong Pair. Please use USDCAD"); return(0);
}*/
Comment(EAName,"\nServer Time: ",Hour(), "\nPairs : ",Symbol(),
"\nEquity : ",AccountEquity(),
"\nBalance : ",AccountBalance()); // Tampilkan Nam a EA di layar
for(int i=0;i<OrdersTotal();i++) {
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()==Symbol() && OrderComment()==EAComment && OrderMagicNumb er()==EAMagicNumber) { if(OrderType()==OP_BUY) TotalBuy++; if(OrderType()==OP_SELL)TotalSell++; } }
/* -- Jika tidak ada BUY --*/
if(TotalBuy==0 && (Hour() >= HourStart && Hour() <= HourEnd)) {
if(SL_level <= 1)Stoploss = 0;
else Stoploss = Bid-(SL_level-1)*PipStep*SetPoint;
OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, Stoploss, Ask+TakeProfit *SetPoint, EAComment, EAMagicNumber);
}
/* -- Jika tidak ada SELL --*/
if(TotalSell==0 && (Hour() >= HourStart && Hour() <= HourEnd)) {
if(SL_level <= 1)Stoploss = 0;
OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage, Stoploss, Bid-TakeProfit *SetPoint, EAComment, EAMagicNumber);
}
/* -- Inilah Fungsi Martingale. Jika ada satu atau lebih OP, periksa apakah a da OP yang harus dimartingale --*/
if(TotalBuy >= 1 || TotalSell >= 1) { GoMartingale(); } //---- return(0); } //+============================================================================= +//
/*-- Fungsi untuk menjalankan Martingale --*/ void GoMartingale() { double LastOPBUY = 0; double LastOPSELL = 0; double LastBUYLots = 0; double LastSELLLots = 0; int iTotalBuy = 0; int iTotalSell = 0; int Spread=0;
Spread= MarketInfo(Symbol(), MODE_SPREAD);
for(int iCount=0;iCount<OrdersTotal();iCount++) {
OrderSelect(iCount,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()==Symbol() && OrderComment()==EAComment && OrderMagicNumber ()==EAMagicNumber)
{
if(OrderType()==OP_BUY) {
if(LastOPBUY == 0 || LastOPBUY > OrderOpenPrice()) LastOPBUY = OrderO penPrice();
if(LastBUYLots < OrderLots()) LastBUYLots = OrderLots();
iTotalBuy++;
/* Bila mencapai batas OP maksimal, jangan tambah OP lagi */ // if(iTotalBuy==MaxTrade) {return(0);}
}
if(OrderType()==OP_SELL) {
if(LastOPSELL == 0 || LastOPSELL < OrderOpenPrice()) LastOPSELL=Order OpenPrice();
if(LastSELLLots<OrderLots()) LastSELLLots=OrderLots();
iTotalSell++;
/* Bila mencapai batas OP maksimal, jangan tambah OP lagi */ // if(iTotalSell==MaxTrade) {return(0);}
} } }
//Martingale OP BUY -- Bila mencapai batas OP maksimal, jangan tambah OP lagi if(iTotalBuy > 0 && iTotalBuy <= MaxTrade && Ask <= LastOPBUY - (PipStep*SetP
oint)) {
if(SL_level <= 1)Stoploss = 0;
else Stoploss = Bid-(SL_level-1)*PipStep*SetPoint;
OrderSend(Symbol(), OP_BUY, Multiply*LastBUYLots, Ask, Slippage, Stoploss, Ask+TakeProfit*SetPoint, EAComment, EAMagicNumber);
ModifyTP(); }
//Martingale OP SELL -- Bila mencapai batas OP maksimal, jangan tambah OP lagi if(iTotalSell > 0 && iTotalSell <= MaxTrade && Bid >= LastOPSELL + (PipStep*Se tPoint))
{
if(SL_level <= 1)Stoploss = 0;
else Stoploss = Ask+(SL_level-1)*PipStep*SetPoint;
OrderSend(Symbol(), OP_SELL, Multiply*LastSELLLots, Bid, Slippage, Stoplos s, Bid-TakeProfit*SetPoint, EAComment, EAMagicNumber);
ModifyTP(); }
return(0); }
/*-- Fungsi ModifyTP ini untuk mengubah semua OP agar TP di titik yang sama --*/ void ModifyTP()
{
int iCount=0; double NewBUY_TP=0; double NewSELL_TP=0;
/*- Ambil nilai Take Profit dari Order terakhir -*/ for(iCount=0;iCount<OrdersTotal();iCount++)
{
OrderSelect(iCount,SELECT_BY_POS,MODE_TRADES);
/*-- Kalau OP-nya adalah BUY, ambil nilai TP yang paling kecil. Jadikan TP bersama --*/
if(OrderType()==OP_BUY && OrderSymbol()==Symbol() && OrderComment()==EACom ment && OrderMagicNumber()==EAMagicNumber)
{
if(NewBUY_TP==0) NewBUY_TP=OrderTakeProfit();
if(NewBUY_TP>OrderTakeProfit()) NewBUY_TP=OrderTakeProfit(); }
/*-- Kalau OP-nya adalah SELL, ambil nilai TP yang paling besar. Jadikan T P bersama --*/
if(OrderType()==OP_SELL && OrderSymbol()==Symbol() && OrderComment()==EACo mment && OrderMagicNumber()==EAMagicNumber)
{
if(NewSELL_TP==0) NewSELL_TP=OrderTakeProfit();
if(NewSELL_TP<OrderTakeProfit()) NewSELL_TP=OrderTakeProfit(); }
}
/*- Ubah semua nilai OP TakeProfit dengan yang baru (2x lipat) -*/ for(iCount=0;iCount<OrdersTotal();iCount++)
{
OrderSelect(iCount,SELECT_BY_POS,MODE_TRADES);
if(OrderType()==OP_BUY && OrderSymbol()==Symbol() && OrderComment()==EACom ment && OrderMagicNumber()==EAMagicNumber)
{
Print("Mofify BUY TP: ",NewBUY_TP);
OrderModify(OrderTicket(), OrderLots(), OrderStopLoss(), NewBUY_TP, 0); }
/*- Kalau ada beberapa OP SELL, maka ubahlah TP mereka -*/
if(OrderType()==OP_SELL && OrderSymbol()==Symbol() && OrderComment()==EACo mment && OrderMagicNumber()==EAMagicNumber)
{
Print("Mofify SELL TP: ",NewSELL_TP);
OrderModify(OrderTicket(), OrderLots(), OrderStopLoss(), NewSELL_TP, 0) ;
} } }
/*--agar EA bisa running di Broker 4 Digit atau 5 Digit--*/ void SetBroker()
{
if (Digits==3 || Digits==5) // Perintah untuk broker 5 Digits {SetPoint=Point*10;}
else // Perintah untuk broker 4 Digits
{SetPoint=Point;} }