Belajar Membuat EA Sederhana 26 (Otomatik Close)
http://jumforex.blogspot.com/2013/02/belajar-membuat-ea-sederhana-26.html
Setelah pada part sebelumnya sudah banyak share dan cara membuat Ea berjenis kelamin Martingel...
Kali ini saya lanjutkan dengan membuat Ea sederhana dan cukup profitabel dan model yang saya akan share ini salah satu model dari EA riel saya ......
Ea ini merupakan sedikit dari ngoprek EA pada part 12 disini
ini hasil pada account salah satu frend saya:
Ini Juga baru dimulai hehehe
Pada Ea tersebut akan saya tambahkan close otomatis ketika ada signal yang berlawanan.....
//+------------------------------------------------------------------+
//| EA Jum MantiQ+ |
//| gifaesa@yahoo.com |
//| http://JumForex.blogspot.com |
//+------------------------------------------------------------------+
#property copyright "JumForex.blogspot.com"
#property link "Gifaesa@yahoo.com"
extern bool Trade_buy = true;
extern bool Trade_sell = true;
extern int Mulai_Jam = 6;
extern int Akhir_Jam = 20;
extern int TP = 0;
extern int SL = 0;
extern double Lots = 0.1;
extern int TrailingStop = 40;
extern int Magic = 69;
extern bool Close_Oto = true;
extern string Seting_MA = "Sesuka Hati";
extern int Pereode = 33;
double slb,tpb,sls,tps,pt,x;
string Nama_EA = "Jum+MantiQ";
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
if(Digits==3 || Digits==5) pt=10*Point; else pt=Point;
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
label();
dtrailing();
//----
double MA2 =iMA(Symbol(),0,Pereode,0,MODE_SMA,PRICE_CLOSE ,2);
double MA1 =iMA(Symbol(),0,Pereode,0,MODE_SMA,PRICE_CLOSE ,1);
int signal;
if(Open[2]<MA2 && Close[2]>MA2 && Open[1]>MA1 && Close[1]>MA1 && Ask>MA1){ signal=1;if(Close_Oto)closeall(1); }// aturan buy
if(Open[2]>MA2 && Close[2]<MA2 && Open[1]<MA1 && Close[1]<MA1 && Bid<MA1){ signal=2;if(Close_Oto)closeall(0); }//aturan sell
if(Jam_trade()==1 && jumlahorder(1)+jumlahorder(0)==0){
if(SL==0)slb=0;else slb=Ask-SL*pt;
if(SL==0)sls=0;else sls=Bid+SL*pt;
if(TP==0)tpb=0;else tpb=Ask+TP*pt;
if(TP==0)tps=0;else tps=Bid-TP*pt;
if( Trade_buy && signal==1) {OrderSend(Symbol(),OP_BUY,NR(Lots),Ask,3,slb, tpb,Nama_EA,Magic,0,Blue);}
if( Trade_sell && signal==2) {OrderSend(Symbol(),OP_SELL,NR(Lots),Bid,3,sls, tps,Nama_EA,Magic,0,Red);}
}
//----
return(0);
}
//+------------------------------------------------------------------+
int Jam_trade()
{
bool trade = false;
if(Mulai_Jam > Akhir_Jam){
if (Hour() >= Mulai_Jam || Hour() < Akhir_Jam) trade = true;
} else
if (Hour() >= Mulai_Jam && Hour() < Akhir_Jam) trade = true;
return (trade);
}
int jumlahorder( int tipe)
{
int total=0;
for(int i=0; i<OrdersTotal(); i++)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=Magic || OrderType()!=tipe) continue;
total++;
}
return(total);
}
double NR(double thelot)
{
double maxlots = MarketInfo(Symbol(), MODE_MAXLOT),
minilot = MarketInfo(Symbol(), MODE_MINLOT),
lstep = MarketInfo(Symbol(), MODE_LOTSTEP);
double lots = lstep * NormalizeDouble(thelot / lstep, 0);
lots = MathMax(MathMin(maxlots, lots), minilot);
return (lots);
}
void dtrailing()
{
for(int i=0; i<OrdersTotal(); i++){
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=Magic ) continue;
if(OrderType()==OP_BUY) {
if(Bid-OrderOpenPrice()>pt*TrailingStop) {
if((OrderStopLoss()<Bid-pt*TrailingStop) || (OrderStopLoss()==0)) {
OrderModify(OrderTicket(),OrderOpenPrice(),Bid-pt*TrailingStop,OrderTakeProfit(),0,Green);
return(0);
}
}
}
if(OrderType()==OP_SELL) {
if((OrderOpenPrice()-Ask)>(pt*TrailingStop)){
if(OrderStopLoss()>(Ask+pt*TrailingStop) || (OrderStopLoss()==0)){
OrderModify(OrderTicket(),OrderOpenPrice(),Ask+pt*TrailingStop,OrderTakeProfit(),0,Red);
return(0);
}
}
}
}
}
void label()
{
Comment("\n ",
"\n ",
"\n ------------------------------------------------",
"\n :: =>+Jum+MantiQ<=",
"\n :: =>JumForex.blogspot.com<=",
"\n ------------------------------------------------",
"\n :: Spread : ", MarketInfo(Symbol(), MODE_SPREAD),
"\n :: Leverage : 1 : ", AccountLeverage(),
"\n :: Equity : ", AccountEquity(),
"\n :: Jam Server :", Hour(), ":", Minute(),
"\n ------------------------------------------------",
"\n :: >>By: Jum69<<",
"\n ------------------------------------------------");
}
void closeall(int m)
{
for (int i = OrdersTotal() - 1; i >= 0; i--) {
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber()!=Magic || OrderType()!=m) continue;
if (OrderType() > 1) OrderDelete(OrderTicket());
if (OrderType() == 0) OrderClose(OrderTicket(), OrderLots(), Bid, 3, CLR_NONE);
if (OrderType() == 1)OrderClose(OrderTicket(), OrderLots(), Ask, 3, CLR_NONE);
}
}
========================================
Hey Everybody,
ReplyDeleteI've included a list of the most recommended forex brokers:
1. Most Recommended Forex Broker
2. eToro - $50 min. deposit.
Here is a list of the best forex instruments:
1. ForexTrendy - Recommended Odds Software.
2. EA Builder - Custom Strategies Autotrading.
3. Fast FX Profit - Secret Forex Strategy.
Hopefully these lists are helpful to you...
Quantum Binary Signals
ReplyDeleteProfessional trading signals delivered to your mobile phone every day.
Follow our trades today and earn up to 270% daily.
GPS robot [10x increase of the deposit amount]
ReplyDeleteI just finished a webinar with Mark and his partner, Antony, two days ago and it was AMAZING.
During the webinar Mark and Antony shared their secrets to success and answered questions about their new version of the GPS Forex Robot that is coming out TODAY!