//+------------------------------------------------------------------+
//| EA BUY SELL PADA JAM TERTENTU.mq4 |
//+------------------------------------------------------------------+
#property copyright "Copyright @ Sonny"
#property link ""
#property version "1.00"
#property strict
extern double Lot = 0.1;
extern int SL = 200;
extern int TP = 300;
double NilaiPip, SLBUY,TPBUY,SLSELL,TPSELL;
string TeksBuy = "Robot Buy";
string TeksSell = "Robot Sell";
int Magic_Number = 777;
datetime JamCandle;
////+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
if(Digits==3 || Digits==5) NilaiPip = 1*Point; else NilaiPip = Point;
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
}
//+------------------------------------------------------------------+
////| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
if(SL==0)SLBUY=0; else SLBUY=Ask-SL*NilaiPip;
if(TP==0)TPBUY=0; else TPBUY=Ask+TP*NilaiPip;
if(SL==0)SLSELL=0; else SLSELL=Bid+SL*NilaiPip;
if(TP==0)TPSELL=0; else TPSELL=Bid-TP*NilaiPip;
if(Hour()==2 && Minute()==15)
{
datetime JamCandleShift0 = iTime(Symbol(),NULL,0);
if(JamCandle!=JamCandleShift0)
{
if(jumlahbuysell(0)==0)
{
int ticket = OrderSend(Symbol(),OP_BUY,Lot,Ask,4,SLBUY,TPBUY,TeksBuy,0,Magic_Number,Blue);
}
if(jumlahbuysell(1)==0)
{
int ticket = OrderSend(Symbol(),OP_SELL,Lot,Bid,4,SLSELL,TPSELL,TeksSell,0,Magic_Number,Red);
}
JamCandle=JamCandleShift0;
}
}
}
//+------------------------------------------------------------------+
////+------------------------------------------------------------------+
int jumlahbuysell(int type)
{
int hasilnya = 0;
for(int jumlahorderawal=0; jumlahorderawal<OrdersTotal(); jumlahorderawal++)
{
if(!OrderSelect(jumlahorderawal,SELECT_BY_POS,MODE_TRADES))
continue;
if(OrderSymbol()!=Symbol()
|| OrderMagicNumber()!=Magic_Number
|| OrderType()!=type)
continue;
hasilnya++;
}
return(hasilnya);
}
//+------------------------------------------------------------------+
Demikian Share Belajar Program MQL4 Script MQL4 Supaya EA Dapat Transaksi Buy dan Sell Pada Jam Tertentu, Semoga Bermanfaat.
0 comments:
Posting Komentar