http://jumforex.blogspot.com/2012/12/belajar-membuat-ea-sederhana-21-jebakan.html
Pastikan sudah mengikuti di part 20 disini
Pada posting kali ini saya akan coba bahas tentang EA jebakan dengan menggunakan dua buah order pending stop.
Adapun rulenya adalah pada jam tertentu langsung pasang 2 buah order buystop dan sellstop dan ketika salah satu order pening stop tersebut tersentuh maka order pending stop yang tersisa langsung didelet.
Kemudian bila pada hari itu tidak tersentuh maka akan didelet. dan tambahan lain pada hari senin tidak trading karena EA ini cocok untuk trend pada hari itu , kalau hari senin diperkirakan biasanya sideway.
Jadi order setiap hari hanya akan melakukan order satu kali saja.
Coba perhatikan gambar di atas pada tanda panah , jadi pada jam server kira 2 jam 0 : 30 maka order stop akan di pasang .
Nah Kita coba buat deklarasinya sbb:
extern string Nama_EA = "Jum+Profit";
extern bool Trade_buystop = true;
extern bool Trade_sellstop = true;
extern string Jam_server = "Set sesuai selera";
extern int Jam = 0;
extern int Menit = 30;
extern bool Tp_in_Money = false;
extern double TP_in_money = 5;
extern int TP = 100;
extern int SL = 20;
extern double Lots = 0.1;
extern int Jarak_stop = 25;
extern bool TrailingStop_ = true;
extern int TrailingStop = 12;
extern int Magic = 69;
double slb,tpb,sls,tps,pt,lslb,ltpb;
Beberapa bagian yang saya coba siapkan adalah script delet order type, disini dibuat dalam bentuk fungsi sbb :
void closeall(int m)
{
for (int i = OrdersTotal() - 1; i >= 0; i--) {
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber()!=Magic /*|| m!= OrderType()*/) continue;
if (OrderType() == m) OrderDelete(OrderTicket());
if (OrderType() == m) OrderDelete(OrderTicket());
if (OrderType() == m) OrderClose(OrderTicket(), OrderLots(), Bid, 3, CLR_NONE);
if (OrderType() == m)OrderClose(OrderTicket(), OrderLots(), Ask, 3, CLR_NONE);
}
}
Untuk menentukan order pada jam tertentu sy buat bagian sbb
Hour()==Jam && Minute()==Menit
Untuk bagian delet ketika salah satu order stop tersenttuh adalah
if(jumlahorder(0)==1 && jumlahorder(1)==0){
closeall(5);
}
if(jumlahorder(0)==0 && jumlahorder(1)==1){
closeall(4);
}
sedang bagian untuk mendelet orderstop yang tidak tersentuh maka pada jam tersentu di delet
contoh jam 23
if(Hour()==23){
closeall(4);
closeall(5);
}
Untuk asesoris order Pending stop :
double as = Ask + Jarak_stop*pt;
double bi = Bid - Jarak_stop*pt;
if(SL==0)slb=0;else slb=as-SL*pt;
if(SL==0)sls=0;else sls=bi+SL*pt;
if(TP==0)tpb=0;else tpb=as+TP*pt;
if(TP==0)tps=0;else tps=bi-TP*pt;
Nah EA jadinya sbb
//+------------------------------------------------------------------+
//| EA Jum+Profit |
//| gifaesa@yahoo.com |
//| http://JumForex.blogspot.com |
//+------------------------------------------------------------------+
#property copyright "JumForex.blogspot.com"
#property link "Gifaesa@yahoo.com"
extern string Nama_EA = "Jum+Profit";
extern bool Trade_buystop = true;
extern bool Trade_sellstop = true;
extern string Jam_server = "Set sesuai selera";
extern int Jam = 0;
extern int Menit = 30;
extern bool Tp_in_Money = false;
extern double TP_in_money = 5;
extern int TP = 100;
extern int SL = 20;
extern double Lots = 0.1;
extern int Jarak_stop = 25;
extern bool TrailingStop_ = true;
extern int TrailingStop = 12;
extern int Magic = 69;
double slb,tpb,sls,tps,pt,lslb,ltpb;
//+------------------------------------------------------------------+
//| 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();
if(TrailingStop_)dtrailing();
if(Tp_in_Money ){
if(TP_in_money<= money(0)){
closeall(0);
closeall(2);
}
if(TP_in_money<= money(1)){
closeall(1);
closeall(3);
}
}
if(jumlahorder(0)==1 && jumlahorder(1)==0){
closeall(5);
}
if(jumlahorder(0)==0 && jumlahorder(1)==1){
closeall(4);
}
if(Hour()==23){
closeall(4);
closeall(5);
}
//----
double as = Ask + Jarak_stop*pt;
double bi = Bid - Jarak_stop*pt;
if(SL==0)slb=0;else slb=as-SL*pt;
if(SL==0)sls=0;else sls=bi+SL*pt;
if(TP==0)tpb=0;else tpb=as+TP*pt;
if(TP==0)tps=0;else tps=bi-TP*pt;
if(DayOfWeek()!=1 && Hour()==Jam && Minute()==Menit && jumlahorder(0)==0 && jumlahorder(1)==0){
if(jumlahorder(4)==0 && Trade_buystop ) {OrderSend(Symbol(),OP_BUYSTOP,NR(Lots),as,3,slb, tpb,Nama_EA,Magic,0,Blue);}
if(jumlahorder(5)==0 && Trade_sellstop ) {OrderSend(Symbol(),OP_SELLSTOP,NR(Lots),bi,3,sls, tps,Nama_EA,Magic,0,Red);}
}
return(0);
}
//+------------------------------------------------------------------+
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 closeall(int m)
{
for (int i = OrdersTotal() - 1; i >= 0; i--) {
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber()!=Magic /*|| m!= OrderType()*/) continue;
if (OrderType() == m) OrderDelete(OrderTicket());
if (OrderType() == m) OrderDelete(OrderTicket());
if (OrderType() == m) OrderClose(OrderTicket(), OrderLots(), Bid, 3, CLR_NONE);
if (OrderType() == m)OrderClose(OrderTicket(), OrderLots(), Ask, 3, CLR_NONE);
}
}
double money(int m)
{
double dp = 0;
int i;
for (i = 0; i < OrdersTotal(); i++) {
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber()!=Magic || m!=OrderType()) continue;
dp += OrderProfit();
}
return(dp);
}
void label()
{
Comment("\n ",
"\n ",
"\n ------------------------------------------------",
"\n :: =>+Jum+Profit<=",
"\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 :: Floting buy : ",money(0),
"\n :: Floting sell : ",money(1),
"\n ------------------------------------------------",
"\n :: >>By: Jum69<<",
"\n ------------------------------------------------");
}
Nah jadi deh
Jangan lupa kasih comment ya !
Pada posting kali ini saya akan coba bahas tentang EA jebakan dengan menggunakan dua buah order pending stop.
Adapun rulenya adalah pada jam tertentu langsung pasang 2 buah order buystop dan sellstop dan ketika salah satu order pening stop tersebut tersentuh maka order pending stop yang tersisa langsung didelet.
Kemudian bila pada hari itu tidak tersentuh maka akan didelet. dan tambahan lain pada hari senin tidak trading karena EA ini cocok untuk trend pada hari itu , kalau hari senin diperkirakan biasanya sideway.
Jadi order setiap hari hanya akan melakukan order satu kali saja.
Coba perhatikan gambar di atas pada tanda panah , jadi pada jam server kira 2 jam 0 : 30 maka order stop akan di pasang .
Nah Kita coba buat deklarasinya sbb:
extern string Nama_EA = "Jum+Profit";
extern bool Trade_buystop = true;
extern bool Trade_sellstop = true;
extern string Jam_server = "Set sesuai selera";
extern int Jam = 0;
extern int Menit = 30;
extern bool Tp_in_Money = false;
extern double TP_in_money = 5;
extern int TP = 100;
extern int SL = 20;
extern double Lots = 0.1;
extern int Jarak_stop = 25;
extern bool TrailingStop_ = true;
extern int TrailingStop = 12;
extern int Magic = 69;
double slb,tpb,sls,tps,pt,lslb,ltpb;
Beberapa bagian yang saya coba siapkan adalah script delet order type, disini dibuat dalam bentuk fungsi sbb :
void closeall(int m)
{
for (int i = OrdersTotal() - 1; i >= 0; i--) {
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber()!=Magic /*|| m!= OrderType()*/) continue;
if (OrderType() == m) OrderDelete(OrderTicket());
if (OrderType() == m) OrderDelete(OrderTicket());
if (OrderType() == m) OrderClose(OrderTicket(), OrderLots(), Bid, 3, CLR_NONE);
if (OrderType() == m)OrderClose(OrderTicket(), OrderLots(), Ask, 3, CLR_NONE);
}
}
Untuk menentukan order pada jam tertentu sy buat bagian sbb
Hour()==Jam && Minute()==Menit
Untuk bagian delet ketika salah satu order stop tersenttuh adalah
if(jumlahorder(0)==1 && jumlahorder(1)==0){
closeall(5);
}
if(jumlahorder(0)==0 && jumlahorder(1)==1){
closeall(4);
}
sedang bagian untuk mendelet orderstop yang tidak tersentuh maka pada jam tersentu di delet
contoh jam 23
if(Hour()==23){
closeall(4);
closeall(5);
}
Untuk asesoris order Pending stop :
double as = Ask + Jarak_stop*pt;
double bi = Bid - Jarak_stop*pt;
if(SL==0)slb=0;else slb=as-SL*pt;
if(SL==0)sls=0;else sls=bi+SL*pt;
if(TP==0)tpb=0;else tpb=as+TP*pt;
if(TP==0)tps=0;else tps=bi-TP*pt;
Bagian lain untuk membuat EA libut trading hari senin adalah
DayOfWeek()!=1
Nah EA jadinya sbb
//+------------------------------------------------------------------+
//| EA Jum+Profit |
//| gifaesa@yahoo.com |
//| http://JumForex.blogspot.com |
//+------------------------------------------------------------------+
#property copyright "JumForex.blogspot.com"
#property link "Gifaesa@yahoo.com"
extern string Nama_EA = "Jum+Profit";
extern bool Trade_buystop = true;
extern bool Trade_sellstop = true;
extern string Jam_server = "Set sesuai selera";
extern int Jam = 0;
extern int Menit = 30;
extern bool Tp_in_Money = false;
extern double TP_in_money = 5;
extern int TP = 100;
extern int SL = 20;
extern double Lots = 0.1;
extern int Jarak_stop = 25;
extern bool TrailingStop_ = true;
extern int TrailingStop = 12;
extern int Magic = 69;
double slb,tpb,sls,tps,pt,lslb,ltpb;
//+------------------------------------------------------------------+
//| 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();
if(TrailingStop_)dtrailing();
if(Tp_in_Money ){
if(TP_in_money<= money(0)){
closeall(0);
closeall(2);
}
if(TP_in_money<= money(1)){
closeall(1);
closeall(3);
}
}
if(jumlahorder(0)==1 && jumlahorder(1)==0){
closeall(5);
}
if(jumlahorder(0)==0 && jumlahorder(1)==1){
closeall(4);
}
if(Hour()==23){
closeall(4);
closeall(5);
}
//----
double as = Ask + Jarak_stop*pt;
double bi = Bid - Jarak_stop*pt;
if(SL==0)slb=0;else slb=as-SL*pt;
if(SL==0)sls=0;else sls=bi+SL*pt;
if(TP==0)tpb=0;else tpb=as+TP*pt;
if(TP==0)tps=0;else tps=bi-TP*pt;
if(DayOfWeek()!=1 && Hour()==Jam && Minute()==Menit && jumlahorder(0)==0 && jumlahorder(1)==0){
if(jumlahorder(4)==0 && Trade_buystop ) {OrderSend(Symbol(),OP_BUYSTOP,NR(Lots),as,3,slb, tpb,Nama_EA,Magic,0,Blue);}
if(jumlahorder(5)==0 && Trade_sellstop ) {OrderSend(Symbol(),OP_SELLSTOP,NR(Lots),bi,3,sls, tps,Nama_EA,Magic,0,Red);}
}
return(0);
}
//+------------------------------------------------------------------+
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 closeall(int m)
{
for (int i = OrdersTotal() - 1; i >= 0; i--) {
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber()!=Magic /*|| m!= OrderType()*/) continue;
if (OrderType() == m) OrderDelete(OrderTicket());
if (OrderType() == m) OrderDelete(OrderTicket());
if (OrderType() == m) OrderClose(OrderTicket(), OrderLots(), Bid, 3, CLR_NONE);
if (OrderType() == m)OrderClose(OrderTicket(), OrderLots(), Ask, 3, CLR_NONE);
}
}
double money(int m)
{
double dp = 0;
int i;
for (i = 0; i < OrdersTotal(); i++) {
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber()!=Magic || m!=OrderType()) continue;
dp += OrderProfit();
}
return(dp);
}
void label()
{
Comment("\n ",
"\n ",
"\n ------------------------------------------------",
"\n :: =>+Jum+Profit<=",
"\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 :: Floting buy : ",money(0),
"\n :: Floting sell : ",money(1),
"\n ------------------------------------------------",
"\n :: >>By: Jum69<<",
"\n ------------------------------------------------");
}
Nah jadi deh
Jangan lupa kasih comment ya !
No comments:
Post a Comment