EA MagiCandle

EA MagiCandle最新版

更新日期:2022-03-03分类标签: 语言:中文平台:没限制

28 人已下载 手机查看

#property copyright “http://ecandlestick.com”
#property link “http://ecandlestick.com”

// LIMIT ACCOUNT DAN KADALUARSA

// GANTI NOMOR ACCOUNT DENGAN NOMOR ACCOUNT KLIEN YANG BELI EA ANDA
// JIKA = 0, MAKA SEMUA NOMOR ACCOUNT BISA DIPAKAI
int NomorAccount = 0;

// GANTI TANGGAL DIBAWAH SESUAI DENGAN KADALUARSA YANG ANDA INGINKAN
// FORMAT TANGGAL ADALAH “TAHUN.BULAN.TANGGAL JAM:MENIT”
string Kadaluarsa = “2029.9.12 00:00”;

//+==================================================================+
//| CARA MENGKOMPILE |
//| Klik tombol Compile (centang hijau) di panel atas. |
//| Lihat pesan yang muncul di bagian bawah, jika ada pesan error |
//| Berarti proses mengkompile tidak berhasil dan Anda salah input |
//+==================================================================+

extern string _EA = “____EA MagiCandle____”;
extern int Magic = 20121001;
extern bool compounding = false;
extern double risk = 2;
extern double Lots = 0.1;
extern int Max_Level = 10;
extern double Faktor_Lot = 25;
extern int TakeProfit = 10;
extern int StopLoss = 0;
extern int TP_In_Money = 10;
extern int SL_In_Money = 0;
extern double Max_Lot = 10;
extern int Minimum_Volume = 15;

extern string _TIMEFILTER = “_______ TIME FILTER KOMPUTER_______”;
extern bool Use_TimeFilter = false;
extern int StartHour = 0;
extern int EndHour = 24;
int EndHour1, StartHour1, GMTOffset;
string comment1;

 

double FreeMargin, loti;
int Trailing_Stop = 0;
double MinLots, MaxLots, minlot, TPBuy, SLBuy;
int DIGIT, convert, slippage=10, spread, stoplevel;
double last_lot_sell, last_price_sell, last_lot_buy, last_price_buy, last_price, last_lot;
int last_type, pending, OpenOrders, cnt, openbuy, opensell;
bool CLOSE, DELETE;
datetime time;
double SL;
double Lot_Marti;
double harga;
double last_tp, last_sl;

bool marti_buy;
bool marti_sell;
double last_open_buy;
double last_open_sell;
bool selisihbuy;
bool selisihsell;
double last_tp_buy;
double last_tp_sell;
double last_sl_buy;
double last_sl_sell;
string volume_string;
double volume_double;
int pembagi;
double rata_buy, rata_sell;
int pengali_TP_SL_money;
double Lot_Awal_Pasang;
double h1_time;

//+——————————————————————+
//| expert initialization function |
//+——————————————————————+
int init()
{
if (!IsExpertEnabled()) {Alert (“EA BELUM AKTIF, KLIK TOMBOL AKTIVASI EA”);}
if (!IsTradeAllowed()) {Alert (“EA BELUM AKTIF, CENTANG PADA ALLOW LIVE TRADING”);}

minlot =MarketInfo(Symbol(),MODE_MINLOT);
if (minlot/0.01==1) {DIGIT=2;} else {DIGIT=1;}
if (MarketInfo (Symbol(), MODE_LOTSTEP)*10<1) {DIGIT=2;} else {DIGIT=1;}
if (Digits==5 ||Digits==3 || Symbol()==”GOLD” || Symbol()==”GOLD.” || Symbol()==”GOLDm”) {convert=10; slippage=100;} else {convert=1;}
MinLots = NormalizeDouble((MarketInfo(Symbol(), MODE_MINLOT)),DIGIT);
MaxLots = NormalizeDouble((MarketInfo(Symbol(), MODE_MAXLOT)),DIGIT);
FreeMargin = AccountBalance();
if (risk==1) {pembagi = 200000;}
if (risk==2) {pembagi = 100000;}
loti = NormalizeDouble(FreeMargin/pembagi,DIGIT);
if (compounding)
{
Lot_Awal_Pasang=loti;
}
else
{
pengali_TP_SL_money = 1;
}

 

return(0);
}
//+——————————————————————+
//| expert deinitialization function |
//+——————————————————————+
int deinit()
{
//—-

//—-
return(0);
}
//+——————————————————————+
//| expert start function |
//+——————————————————————+
int start()
{

if (ObjectFind (“h1”)<0)
{
Alert (“SILAKAN PASANG INDI TBST KE CHART”);
return (0);
}
volume_string = ObjectDescription(“h1”) ;
volume_double = StrToDouble (volume_string);
h1_time = ObjectGet(“h1″, OBJPROP_TIME1) ;

 

minlot =MarketInfo(Symbol(),MODE_MINLOT);
if (minlot/0.01==1) {DIGIT=2;} else {DIGIT=1;}
if (MarketInfo (Symbol(), MODE_LOTSTEP)*10<1) {DIGIT=2;} else {DIGIT=1;}
if (Digits==5 ||Digits==3 || Symbol()==”GOLD” || Symbol()==”GOLD.” || Symbol()==”GOLDm”) {convert=10; slippage=100;} else {convert=1;}
MinLots = NormalizeDouble((MarketInfo(Symbol(), MODE_MINLOT)),DIGIT);
MaxLots = NormalizeDouble((MarketInfo(Symbol(), MODE_MAXLOT)),DIGIT);
FreeMargin = AccountBalance();
if (risk==1) {pembagi = 200000;}
if (risk==2) {pembagi = 100000;}
loti = NormalizeDouble(FreeMargin/pembagi,DIGIT);
if (compounding)
{
Lots=loti;
pengali_TP_SL_money = Lots / Lot_Awal_Pasang;
}

if(Lots<MinLots){Lots=MinLots;}
if(Lots>MaxLots){Lots=MaxLots;}
Lots = NormalizeDouble (Lots,DIGIT);
stoplevel=NormalizeDouble(MarketInfo(Symbol(),MODE_STOPLEVEL),2);
spread = NormalizeDouble(MarketInfo(Symbol(),MODE_SPREAD),2);
if (Trailing_Stop*convert<stoplevel+spread && Trailing_Stop!=0) {Trailing_Stop=(stoplevel+spread)/convert;}

if (TakeProfit*convert<stoplevel+spread && TakeProfit!=0) {TakeProfit=(stoplevel+spread)/convert;}

if (TP_In_Money!=0 && ProfitInMoney()>=TP_In_Money*pengali_TP_SL_money && OpenOrders>0) {CloseAll(7); Alert (“TP IN MONEY”);}
if (SL_In_Money!=0 && ProfitInMoney()<=-SL_In_Money*pengali_TP_SL_money && OpenOrders>0) {CloseAll(7); Alert (“SL IN MONEY”);}

openord();
if (TimeFilter() && kadaluarsa() && LoginNumber())
{
if (buy() && openbuy==0 && sudah_open_candle_ini(OP_BUY)==false )
{
if (OPEN (Symbol(), OP_BUY, Blue, Lots, slippage, Ask, false, 0, 0, “Magic”, Magic))
{time=iTime (Symbol(),0,0); Sleep(5000);}
}
if (sell() && opensell==0 && sudah_open_candle_ini(OP_SELL)==false)
{
if (OPEN (Symbol(), OP_SELL, Red, Lots, slippage, Bid, false, 0, 0, “Magic”, Magic))
{time=iTime (Symbol(),0,0); Sleep(5000);}
}
}

 

//+——————————————————————+
//| OPEN MARTINGALE HYBRID |
//+——————————————————————+
openord();
if (buy() && openbuy>0 && openbuy<Max_Level && sudah_open_candle_ini(OP_BUY)==false )
{
selisihbuy = (last_price_buy – Ask)/(convert*Point);
Lot_Marti = Lots + (last_lot_buy * (selisihbuy/Faktor_Lot));
if (Lot_Marti>Max_Lot) {Lot_Marti=Max_Lot;}
Lot_Marti = NormalizeDouble (Lot_Marti, DIGIT);

if (selisihbuy>0)
{
if (OPEN (Symbol(), OP_BUY, Blue, Lot_Marti, slippage, Ask, false, 0, 0, “Next Magic”, Magic))
{time=iTime (Symbol(),0,0); marti_buy=false; }
}
}

openord();
if (sell() && opensell>0 && opensell<Max_Level && sudah_open_candle_ini(OP_SELL)==false)
{
selisihsell = (Bid – last_price_sell)/(convert*Point);
Lot_Marti = Lots + (last_lot_sell * (selisihsell/Faktor_Lot));
if (Lot_Marti>Max_Lot) {Lot_Marti=Max_Lot;}
Lot_Marti = NormalizeDouble (Lot_Marti, DIGIT);

if (selisihsell>0)
{
if (OPEN (Symbol(), OP_SELL, Red, Lot_Marti, slippage, Bid, false, 0, 0, “Next Magic”, Magic))
{time=iTime (Symbol(),0,0); marti_sell=false; }
}
}

openord();
rata_buy = rata_price(OP_BUY);
rata_sell = rata_price(OP_SELL);

openord();
if (openbuy>0)
{
ModifyTP(OP_BUY, rata_buy + TakeProfit*convert*Point);
if (StopLoss!=0) {ModifySL(OP_BUY, rata_buy – StopLoss*convert*Point);}
}
if (opensell>0)
{
ModifyTP(OP_SELL, rata_sell – TakeProfit*convert*Point);
if (StopLoss!=0) {ModifySL(OP_SELL, rata_sell + StopLoss*convert*Point);}
}

 

komentar (1, “MAGIC”, DoubleToStr (Magic,0));
komentar (2, “NAMA”, AccountName());
komentar (3, “No. ACC”, AccountNumber());
komentar (4, “BROKER”, AccountCompany());
komentar (5, “LEVERAGE”, “1:”+DoubleToStr(AccountLeverage(),0));
komentar (6, “BALANCE”, DoubleToStr (AccountBalance(),2));
komentar (7, “EQUITY”, DoubleToStr (AccountEquity(),2));

if (GetLastError()==134) {Alert (“BALANCE TIDAK CUKUP UNTUK MEMBUKA ORDER”); return (0);}

return(0);
}
//+——————————————————————+
void ModifyTP(int tipe, double TP) // TP disini diambil dari OrderTakeProfit() dari OP terakhir
{
for (cnt = OrdersTotal(); cnt >= 0; cnt–)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() == Symbol() && OrderMagicNumber()==Magic && (OrderType()==tipe) )
{
if (NormalizeDouble (OrderTakeProfit(),Digits)!=NormalizeDouble (TP,Digits))
{
OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss(), NormalizeDouble (TP,Digits), 0, CLR_NONE);
}
}
}
}

void ModifySL(int tipe, double SL) // TP disini diambil dari OrderTakeProfit() dari OP terakhir
{
for (cnt = OrdersTotal(); cnt >= 0; cnt–)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() == Symbol() && OrderMagicNumber()==Magic && (OrderType()==tipe) )
{
if (NormalizeDouble (OrderStopLoss(),Digits)!=NormalizeDouble (SL,Digits))
{
OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble (SL,Digits), OrderTakeProfit(), 0, CLR_NONE);
}
}
}
}

bool kadaluarsa()
{datetime kada = StrToTime(Kadaluarsa); if (TimeCurrent()>kada) {Alert (“Expert Advisor has expired”);return (false);} else {return (true);}}

bool LoginNumber()
{if (AccountNumber()==NomorAccount || NomorAccount == 0 ) {return (true);} else {Alert (“Login Number dont match “); return (false);}}

 

 

double rata_price(int tipe)
{
double total_lot=0;
double total_kali=0;
double rata_price=0;
for(cnt=0;cnt<OrdersTotal();cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol()==Symbol() && OrderMagicNumber() == Magic && (OrderType()==tipe))
{
total_lot = total_lot + OrderLots();
total_kali = total_kali + (OrderLots() * OrderOpenPrice());
}
}
if (total_lot!=0) {rata_price = total_kali / total_lot;} else {rata_price = 0;}
return (rata_price);
}

bool sudah_open_candle_ini(int tipe)
{
bool sudahopenhariini=false;
for(cnt=0;cnt<OrdersTotal();cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol()==Symbol() && OrderMagicNumber() == Magic && OrderType()==tipe )
{
if (OrderOpenTime()>=iTime(Symbol(),0,0)) {sudahopenhariini=true;}
}
}
for(cnt=0;cnt<OrdersHistoryTotal();cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_HISTORY);
if (OrderSymbol()==Symbol() && OrderMagicNumber() == Magic && OrderType()==tipe)
{
if (OrderOpenTime()>=iTime(Symbol(),0,0)) {sudahopenhariini=true;}
}
}

return (sudahopenhariini);

}

bool buy()
{
if (h1_time<Time[1]) {return (false);}
if (volume_double>=Minimum_Volume && Close[1] > Open[1]) {return (true);} else {return (false);}
}

bool sell()
{
if (h1_time<Time[1]) {return (false);}
if (volume_double>=Minimum_Volume && Close[1] < Open[1]) {return (true);} else {return (false);}
}

 

void komentar (int baris, string label1, string label2)
{
if (!IsTradeAllowed() || !IsExpertEnabled()) {ObjectDelete(“baris0”); return (0);}
int x,y;
switch(baris)
{
case 1: x=40; y=60; break;
case 2: x=40; y=75; break;
case 3: x=40; y=90; break;
case 4: x=40; y=105; break;
case 5: x=40; y=120; break;
case 6: x=40; y=135; break;
case 7: x=40; y=150; break;
case 8: x=40; y=165; break;
case 9: x=40; y=180; break;
case 10: x=40; y=195; break;
case 11: x=40; y=210; break;
case 12: x=40; y=225; break;
case 13: x=40; y=240; break;
case 14: x=40; y=255; break;
case 15: x=40; y=270; break;
case 16: x=40; y=285; break;
case 17: x=40; y=300; break;
}
Monitor(“baris0″, WindowExpertName()+ ” IS RUNNING”, 10, 40, 20, Yellow,0);
Monitor(“baris00”, “Jasa Pembuatan Expert Advisor http://eCandleStick.com”, 8, 40, 10, Yellow,2);
Monitor(“baris”+baris, label1, 8, x, y, Yellow,0);
Monitor(“baris_”+baris, “:”, 8, x+150, y, Yellow,0);
Monitor(“baris-“+baris, label2, 8, x+160, y, Yellow,0);
}

 

void Monitor(string nama, string isi, int ukuran, int x, int y, color warna, int pojok)
{
if (ObjectFind(nama)<0) {ObjectCreate (nama,OBJ_LABEL,0,0,0,0,0);}
ObjectSet (nama,OBJPROP_CORNER,pojok);
ObjectSet (nama,OBJPROP_XDISTANCE,x);
ObjectSet (nama,OBJPROP_YDISTANCE,y);
ObjectSetText (nama,isi,ukuran,”Tahoma”,warna);
}

 

 

bool OPEN (string symbol, int tipe, color warna, double Lots, double slippage, double harga, bool hidden_mode, double StopLoss, double TakeProfit, string komen, int Magic )
{
double TP, SL;
int ticket=0;
//while (ticket<=0)
// {
RefreshRates();
stoplevel=NormalizeDouble(MarketInfo(Symbol(),MODE_STOPLEVEL),0);
spread = NormalizeDouble(MarketInfo(Symbol(),MODE_SPREAD),0);
if (tipe==OP_BUY || tipe==OP_BUYLIMIT || tipe==OP_BUYSTOP)
{
if (TakeProfit*convert>stoplevel && !hidden_mode) {TP=harga+TakeProfit*convert*Point;} else {TP=0;}
if (StopLoss*convert>stoplevel+spread && !hidden_mode) {SL=harga-StopLoss*convert*Point;} else {SL=0;}
}

if (tipe==OP_SELL || tipe==OP_SELLLIMIT || tipe==OP_SELLSTOP)
{
if (TakeProfit*convert>stoplevel && !hidden_mode) {TP=harga-TakeProfit*convert*Point;} else {TP=0;}
if (StopLoss*convert>stoplevel+spread && !hidden_mode) {SL=harga+StopLoss*convert*Point;} else {SL=0;}
}

ticket = OrderSend(symbol,tipe,Lots,NormalizeDouble (harga,Digits) ,slippage,SL,TP,komen,Magic,0,warna);
if (ticket<=0) {Sleep(1000);} else {return (true);}
// }

}
bool TimeFilter()
{
EndHour1=EndHour+GMTOffset;
StartHour1=StartHour+GMTOffset;
if ((StartHour+GMTOffset)<0) {StartHour1=StartHour+GMTOffset+24;}
if ((EndHour+GMTOffset)<0) {EndHour1=EndHour+GMTOffset+24;}
if ((StartHour+GMTOffset)>24) {StartHour1=StartHour+GMTOffset-24;}
if ((EndHour+GMTOffset)>24) {EndHour1=EndHour+GMTOffset-24;}

if (Use_TimeFilter==false) {return (true);}
else

 

if (StartHour1<EndHour1)
{
if (TimeHour(TimeLocal())>=StartHour1 && TimeHour(TimeLocal())<EndHour1){return (true);} else {return (false);}
}

else

if (StartHour1>EndHour1)

{
if (TimeHour(TimeLocal())>=StartHour1 || TimeHour(TimeLocal())<EndHour1){return (true);} else {return (false);}
}

}

 

 

void openord()
{
OpenOrders=0; openbuy=0; opensell=0; pending=0;
for(cnt=0;cnt<OrdersTotal();cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol()==Symbol() && OrderMagicNumber() == Magic && (OrderType()==OP_BUY ||OrderType()==OP_SELL))
{
OpenOrders++;
last_price = OrderOpenPrice();
last_lot = OrderLots();
last_type = OrderType();
last_tp = OrderTakeProfit();
last_sl = OrderStopLoss();
}

if (OrderSymbol()==Symbol() && OrderMagicNumber() == Magic && (OrderType()==OP_BUYLIMIT || OrderType()==OP_BUYSTOP || OrderType()==OP_SELLSTOP || OrderType()==OP_SELLLIMIT))
{pending++;}

if (OrderSymbol()==Symbol() && OrderMagicNumber() == Magic && OrderType()==OP_BUY)
{
openbuy++;
last_price_buy = OrderOpenPrice();
last_lot_buy = OrderLots();
last_open_buy = OrderOpenPrice();
last_tp_buy = OrderTakeProfit();
last_sl_buy = OrderStopLoss();
}
if (OrderSymbol()==Symbol() && OrderMagicNumber() == Magic && OrderType()==OP_SELL)
{
opensell++;
last_price_sell = OrderOpenPrice();
last_lot_sell = OrderLots();
last_open_sell = OrderOpenPrice();
last_tp_sell = OrderTakeProfit();
last_sl_sell = OrderStopLoss();
}
}
}

 

double ProfitInMoney()
{
double Profit=0;
for(cnt=0;cnt<OrdersTotal();cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol()==Symbol() && OrderMagicNumber() == Magic && (OrderType()==OP_BUY || OrderType()==OP_SELL) )
{Profit = Profit + OrderProfit();}
}
return (Profit);
}

// BUY = 0
// SELL = 1
// BUYLIMIT=2
// SELLIMIT=3
// BUYSTOP = 4
// SELLSTOP = 5
void CloseAll(int tipe)
{
CLOSE=false;
DELETE=false;
for(cnt=OrdersTotal();cnt>=0;cnt–)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol()==Symbol() && OrderMagicNumber() == Magic)
{
if (OrderType()==OP_BUY && (tipe==0 || tipe==7))
{

int retry=0;
while (CLOSE==false)
{
RefreshRates();
CLOSE = OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),slippage,Blue);
if (CLOSE==false) {Sleep(1000); retry++;}
if (GetLastError()==4108 || GetLastError()==145) {CLOSE=true;}
}
CLOSE=false;
}
if (OrderType()==OP_SELL && (tipe==1 || tipe==7))
{

retry=0;
while (CLOSE==false)
{
RefreshRates();
CLOSE = OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),slippage,Red);
if (CLOSE==false) {Sleep(1000); retry++;}
if (GetLastError()==4108 || GetLastError()==145) {CLOSE=true;}
}
CLOSE=false;
}

}
}
for(cnt=OrdersTotal();cnt>=0;cnt–)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol()==Symbol() && OrderMagicNumber() == Magic)
{

if (OrderType()==OP_BUYLIMIT && (tipe==2 || tipe==7))
{

retry=0;
while (DELETE==false)
{
RefreshRates();
DELETE = OrderDelete(OrderTicket());
if (DELETE==false) {Sleep(1000); retry++;}
if (GetLastError()==4108 || GetLastError()==145) {DELETE=true;}
}
DELETE=false;
}
if (OrderType()==OP_SELLLIMIT && (tipe==3 || tipe==7))
{
retry=0;
while (DELETE==false)
{
RefreshRates();
DELETE = OrderDelete(OrderTicket());
if (DELETE==false) {Sleep(1000); retry++;}
if (GetLastError()==4108 || GetLastError()==145) {DELETE=true;}
}
DELETE=false;
}
if (OrderType()==OP_BUYSTOP && (tipe==4 || tipe==7))
{
retry=0;
while (DELETE==false)
{
RefreshRates();
DELETE = OrderDelete(OrderTicket());
if (DELETE==false) {Sleep(1000); retry++;}
if (GetLastError()==4108 || GetLastError()==145) {DELETE=true;}
}
DELETE=false;
}
if (OrderType()==OP_SELLSTOP && (tipe==5 || tipe==7))
{
retry=0;
while (DELETE==false)
{
RefreshRates();
DELETE = OrderDelete(OrderTicket());
if (DELETE==false) {Sleep(1000); retry++;}
if (GetLastError()==4108 || GetLastError()==145) {DELETE=true;}
}
DELETE=false;
}
}
}
}

如果你对文件有了解,请帮助投票!

If you are familiar with the file, please help vote!

平均评分 0 / 5. 投票数: 0

到目前为止还没有投票!成为第一位投票人。

相关资源

暂无评论

暂无评论...