Belajar Membuat EA Sederhana 25 (Cut Switching)
http://jumforex.blogspot.com/2013/02/belajar-membuat-ea-sederhana-25-cut.html
Mungkin sudah pada ngintip di part 24
Kali ini kita akan bahas tentang EA model cut switching , saya sih juga gak begitu memahami betul tentang strategy ini tapi yang jelas ini termasuk juga EA martingel tapi untuk kondisi trending.
Ea ini setelah order maka bila floting negatif maka akan di cut loss dan dilanjutkan dengan order baru dengan arah yang berlawanan dengan memeperhitungkan kelipatan lotsnya
Nah sebenarnya bisa dibuat dengan beberapa model , tapi kali ini kita akan buat model menggunakan tidak menggunakan pending stop.
bagian triger digunakan indikator fractals
Perhatikan cara codingnya:
Kali ini kita akan bahas tentang EA model cut switching , saya sih juga gak begitu memahami betul tentang strategy ini tapi yang jelas ini termasuk juga EA martingel tapi untuk kondisi trending.
Ea ini setelah order maka bila floting negatif maka akan di cut loss dan dilanjutkan dengan order baru dengan arah yang berlawanan dengan memeperhitungkan kelipatan lotsnya
Nah sebenarnya bisa dibuat dengan beberapa model , tapi kali ini kita akan buat model menggunakan tidak menggunakan pending stop.
bagian triger digunakan indikator fractals
Perhatikan cara codingnya:
for(int d=0; d< Bars ; d++){ double up=iFractals(Symbol(),0,MODE_UPPER,d); if(up!=0 ) break;}
for(int e=0; e< Bars ; e++){ double lo=iFractals(Symbol(),0,MODE_LOWER,e); if( lo!=0) break;}
int signal;
if(Bid > up) signal=1;// signal buy
if(Ask < lo)signal=2;//signal sell
Bagian lain yang perlu diperhatikan adalah membaca history orderprofit, ordertype dan magic number
double trad(int m)
{
double pr,op;
for (int i = 0; i < OrdersHistoryTotal(); i++) {
if (!OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)) continue;
if (OrderSymbol() != Symbol()/* || OrderComment() != Nama_EA*/) continue;
if(m==1)pr=OrderProfit();
if(m==2)pr=OrderType();
if(m==3)pr=OrderMagicNumber();
}
return(pr);
}
- history orderprofit diperlukan untuk mengetahui orderprofit pada order close yang terakhir itu untung ata rugi
- history ordertype diperlukan untuk mengetahui type order pada order close yang terakhir itu type buy atau sell
- history magicnumber diperlukan untuk mengetahui membatasidan memperhitungkan level order
Untuk memperhitungkan perkalian lotsnya digunakan fungsi sbb:
double xlot()
{
double ylot,dlot;
for (int i = 0; i < OrdersHistoryTotal(); i++) {
if (!OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)) continue;
if (OrderSymbol() != Symbol()/* || OrderComment() != Nama_EA */) continue;
dlot=OrderLots();
}
ylot=NR(dlot*DiMarti);
return(ylot);
}
Untuk penentuan trigernya saya coba gunakan indikator Fractals
//+------------------------------------------------------------------+
//| Jum+switch+.mq4 |
//| gifaesa@yahoo.com |
//| http://JumForex.blogspot.com |
//+------------------------------------------------------------------+
#property copyright "JumForex.blogspot.com"
#property link "Gifaesa@yahoo.com"
extern string Target_Equety_ = "Harus lebih besar dari Equety+";
extern double Target_Equety = 1000;
extern int Mulai_Jam = 0;
extern int Akhir_Jam = 20;
extern int TP = 30;
extern int SL = 20;
extern double Lots = 0.01;
extern int Max_order = 12;
extern double DiMarti = 2;
extern int Magic = 69;
string Nama_EA = "Jum+SwitchFractals+";
double slb,tpb,sls,tps,pt,bal;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
bal= AccountBalance();
if(Digits==3 || Digits==5) pt=10*Point; else pt=Point;
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
ObjectDelete("j");
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
if(SL==0||TP==0){Alert(" Isi dulu TP Dan SLnya"); return(0);}
label();
if(Target_Equety<AccountEquity()) {
closeall(0);
closeall(1);
Alert("Cek Target_Equetynya salah ");
return(0);
}
for(int d=0; d< Bars ; d++){
double up=iFractals(Symbol(),0,MODE_UPPER,d);
if(up!=0 ) break;}
for(int e=0; e< Bars ; e++){
double lo=iFractals(Symbol(),0,MODE_LOWER,e);
if( lo!=0) break;}
int signal;
if(Bid > up) signal=1;
if(Ask < lo)signal=2;
if(Jam_trade()==1 && DayOfWeek()>1){
if((trad(1)>0) || (trad(1)==0)){
if(jumlahorder(0)==0 && jumlahorder(1)==0){
if(signal==1) {OrderSend(Symbol(),OP_BUY,NR(Lots),Ask,3,Ask-SL*pt, Ask+TP*pt,Nama_EA,Magic,0,Blue);}
if(signal==2) {OrderSend(Symbol(),OP_SELL,NR(Lots),Bid,3,Bid+SL*pt, Bid-TP*pt,Nama_EA,Magic,0,Red);}
}
}
}
if(jumlahorder(0)==0 && jumlahorder(1)==0 && trad(3)<Max_order+Magic ){
if(trad(1)<0 && trad(2)==1) {OrderSend(Symbol(),OP_BUY,xlot(),Ask,3,Ask-SL*pt, Ask+TP*pt,Nama_EA,trad(3)+1,0,Blue); }
if(trad(1)<0 && trad(2)==0) {OrderSend(Symbol(),OP_SELL,xlot(),Bid,3,Bid+SL*pt, Bid-TP*pt,Nama_EA,trad(3)+1,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() || OrderComment() != Nama_EA || 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 closeall(int m)
{
for (int i = OrdersTotal() - 1; i >= 0; i--) {
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderComment() != Nama_EA || OrderType()!=m) continue;
if (OrderType() > 1) OrderDelete(OrderTicket());
else {
if (OrderType() == 0) OrderClose(OrderTicket(), OrderLots(), Bid, 3, CLR_NONE);
else OrderClose(OrderTicket(), OrderLots(), Ask, 3, CLR_NONE);
}
}
}
double money()
{
double dp = 0;
int i;
for (i = 0; i < OrdersTotal(); i++) {
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderComment() != Nama_EA) continue;
dp += OrderProfit();
}
return(dp);
}
double trad(int m)
{
double pr,op;
for (int i = 0; i < OrdersHistoryTotal(); i++) {
if (!OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)) continue;
if (OrderSymbol() != Symbol()/* || OrderComment() != Nama_EA*/) continue;
if(m==1)pr=OrderProfit();
if(m==2)pr=OrderType();
if(m==3)pr=OrderMagicNumber();
}
return(pr);
}
double xlot()
{
double ylot,dlot;
for (int i = 0; i < OrdersHistoryTotal(); i++) {
if (!OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)) continue;
if (OrderSymbol() != Symbol()/* || OrderComment() != Nama_EA */) continue;
dlot=OrderLots();
}
ylot=NR(dlot*DiMarti);
return(ylot);
}
void label()
{
ObjectCreate("j",OBJ_LABEL,0,0,0);
ObjectSet("j",OBJPROP_CORNER,4);
ObjectSet("j",OBJPROP_XDISTANCE,10);
ObjectSet("j",OBJPROP_YDISTANCE,10);
ObjectSetText("j","Jum+switchFractals from : JumForex.blogspot.com ",21,"Mistral",Aqua);
Comment("\n ",
"\n ",
"\n ------------------------------------------------",
"\n :: Spread : ", MarketInfo(Symbol(), MODE_SPREAD),
"\n :: Leverage : 1 : ", AccountLeverage(),
"\n :: Jam Server :", Hour(), ":", Minute(),
"\n ------------------------------------------------",
"\n :: Equity sekarang : ", AccountEquity()," $",
"\n :: Target_Equety : ", Target_Equety ," $",
"\n ------------------------------------------------",
"\n :: Posisi floting :",money()," $",
"\n :: Level :",trad(3)-Magic,
"\n ------------------------------------------------",
"\n :: >>By: Jum69<<",
"\n ------------------------------------------------");
//+------------------------------------------------------------------+
}
Hello Everybody,
ReplyDeleteI've included a list of the highest ranking forex brokers:
1. Best Forex Broker
2. eToro - $50 minimum 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.
Imagine if you had a robot with 6 years authenticated proof?
ReplyDeleteI just completed a webinar with Mark and his partner, Antony, two days ago and it was AMAZING.
During the webinar MARK and ANTONY shared their stories to success and answered questions about their new version of the GPS Forex Robot that CAME OUT TODAY!