Monday, 29 October 2012

SCRIPT EA HEDGING


SCRIPT EA HEDGING

Posted: May 15, 2011 in Expert Advisor
1
 
 
 
 
 
 
Rate This

Ini salah satu contoh coding EA Hedging silahkan dipelajari dan dioprex sesuai dengan sistem teman-teman…
#property copyright “Andi Goen”
#property link “http://facebook.com/andi.goen”
extern string email = “”;
extern string Pair = “USDJPY”;
extern double Lots = 0.1;
extern int TakeProfit = 30;
extern int StopLoss = 300;
extern bool ConstantStop = TRUE;
extern int Step1 = 30;
extern int TP1 = 30;
extern int Step2 = 30;
extern int TP2 = 30;
extern int Step3 = 30;
extern int TP3 = 30;
extern int Step4 = 30;
extern int TP4 = 30;
extern int Step5 = 30;
extern int TP5 = 30;
extern int Step6 = 30;
extern int TP6 = 30;
extern int Step7 = 30;
extern int TP7 = 30;
extern int Step8 = 30;
extern int TP8 = 30;
extern int Step9 = 30;
extern int TP9 = 30;
extern int Step10 = 30;
extern int TP10 = 30;
int g_slippage_192 = 3;
int gi_196 = 2;
extern int StartHour = 0;
extern int EndHour = 24;
int g_magic_208 = 111;
int gi_212 = D’01.01.2012 14:00′;
int gi_216 = 1533279600;
string gs_220 = “Silahkan Trading Live”;

int start() {
double l_price_0;
double l_price_8;
double l_price_16;
double l_lots_24;
double l_pips_32;
double l_pips_40;
if (Year() > 2012) {
Alert(“EA_Hedging Expaired”);
return (0);
}
int l_ticket_48 = 0;
int l_ticket_52 = 0;
int l_ticket_56 = 0;
int l_ticket_60 = 0;
int l_ticket_64 = 0;
int l_ticket_68 = 0;
double l_ord_lots_72 = 0;
double l_ord_lots_80 = 0;
double l_ord_open_price_88 = 0;
double l_ord_open_price_96 = 0;
double l_ord_takeprofit_104 = 0;
double l_ord_takeprofit_112 = 0;
double l_ord_lots_120 = 0;
double l_ord_lots_128 = 0;
double l_ord_lots_136 = 0;
double l_ord_lots_144 = 0;
double ld_152 = 0;
double ld_160 = 0;
for (int l_pos_168 = 0; l_pos_168 < OrdersTotal(); l_pos_168++) {
OrderSelect(l_pos_168, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_208) {
if (OrderType() == OP_BUY && l_ticket_48 < OrderTicket()) {
l_ord_lots_72 = OrderLots();
l_ord_open_price_88 = OrderOpenPrice();
l_ticket_48 = OrderTicket();
l_ord_takeprofit_112 = OrderTakeProfit();
if (OrderLots() == Lots) ld_152 = OrderOpenPrice() – StopLoss * Point;
}
if (OrderType() == OP_SELL && l_ticket_52 < OrderTicket()) {
l_ord_lots_80 = OrderLots();
l_ord_open_price_96 = OrderOpenPrice();
l_ticket_52 = OrderTicket();
l_ord_takeprofit_104 = OrderTakeProfit();
if (OrderLots() == Lots) ld_160 = OrderOpenPrice() + StopLoss * Point;
}
if (OrderType() == OP_BUYLIMIT) {
l_ticket_56 = OrderTicket();
l_ord_lots_136 = OrderLots();
}
if (OrderType() == OP_SELLLIMIT) {
l_ticket_60 = OrderTicket();
l_ord_lots_144 = OrderLots();
}
if (OrderType() == OP_BUYSTOP) {
l_ticket_64 = OrderTicket();
l_ord_lots_120 = OrderLots();
}
if (OrderType() == OP_SELLSTOP) {
l_ticket_68 = OrderTicket();
l_ord_lots_128 = OrderLots();
}
}
}
if (l_ticket_48 == 0) {
if (l_ticket_56 != 0) OrderDelete(l_ticket_56);
if (l_ticket_64 != 0) OrderDelete(l_ticket_64);
l_price_8 = Ask – StopLoss * Point;
if (StopLoss = StartHour && TimeHour(TimeCurrent()) = gi_212 && TimeCurrent() <= gi_216) OrderSend(Symbol(), OP_BUY, Lots, Ask, g_slippage_192, l_price_8, l_price_16, "EA_Hedging", g_magic_208, 0, Blue);
else Alert(gs_220);
}
}
if (l_ticket_52 == 0) {
if (l_ticket_60 != 0) OrderDelete(l_ticket_60);
if (l_ticket_68 != 0) OrderDelete(l_ticket_68);
l_price_8 = Bid + StopLoss * Point;
if (StopLoss = StartHour && TimeHour(TimeCurrent()) = gi_212 && TimeCurrent() <= gi_216) OrderSend(Symbol(), OP_SELL, Lots, Bid, g_slippage_192, l_price_8, l_price_16, "EA_Hedging", g_magic_208, 0, Red);
else Alert(gs_220);
}
}
if (l_ticket_48 != 0 && l_ticket_56 == 0) {
l_pips_40 = FinalStep(l_ord_lots_72);
l_pips_32 = FinalTP(l_ord_lots_72);
l_price_0 = l_ord_open_price_88 – l_pips_40 * Point;
if (ConstantStop == FALSE) l_price_8 = l_price_0 – StopLoss * Point;
else l_price_8 = ld_152;
if (StopLoss <= 0) l_price_8 = 0;
l_price_16 = l_price_0 + l_pips_32 * Point;
l_lots_24 = NormalizeDouble(2.0 * l_ord_lots_72, gi_196);
OrderSend(Symbol(), OP_BUYLIMIT, l_lots_24, l_price_0, g_slippage_192, l_price_8, l_price_16, "EA_Hedging", g_magic_208, 0, Blue);
}
if (l_ticket_52 != 0 && l_ticket_60 == 0) {
l_pips_40 = FinalStep(l_ord_lots_80);
l_pips_32 = FinalTP(l_ord_lots_80);
l_price_0 = l_ord_open_price_96 + l_pips_40 * Point;
if (ConstantStop == FALSE) l_price_8 = l_price_0 + StopLoss * Point;
else l_price_8 = ld_160;
if (StopLoss <= 0) l_price_8 = 0;
l_price_16 = l_price_0 – l_pips_32 * Point;
l_lots_24 = NormalizeDouble(2.0 * l_ord_lots_80, gi_196);
OrderSend(Symbol(), OP_SELLLIMIT, l_lots_24, l_price_0, g_slippage_192, l_price_8, l_price_16, "APS_Hedging", g_magic_208, 0, Red);
}
for (l_pos_168 = 0; l_pos_168 < OrdersTotal(); l_pos_168++) {
OrderSelect(l_pos_168, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() == Symbol() && OrderType() == OP_BUY && l_ticket_48 != 0 && OrderMagicNumber() == g_magic_208) {
if (ConstantStop == FALSE) l_price_8 = l_ord_open_price_88 – StopLoss * Point;
else l_price_8 = ld_152;
if (StopLoss <= 0) l_price_8 = 0;
if (l_ticket_48 != OrderTicket()) l_price_16 = l_ord_takeprofit_112;
else l_price_16 = OrderTakeProfit();
if (l_price_16 != OrderTakeProfit() || l_price_8 != OrderStopLoss()) OrderModify(OrderTicket(), OrderOpenPrice(), l_price_8, l_price_16, 0, CLR_NONE);
}
if (OrderSymbol() == Symbol() && OrderType() == OP_SELL && l_ticket_52 != 0 && OrderMagicNumber() == g_magic_208) {
if (ConstantStop == FALSE) l_price_8 = l_ord_open_price_96 + StopLoss * Point;
else l_price_8 = ld_160;
if (StopLoss <= 0) l_price_8 = 0;
if (l_ticket_52 != OrderTicket()) l_price_16 = l_ord_takeprofit_104;
else l_price_16 = OrderTakeProfit();
if (l_price_16 != OrderTakeProfit() || l_price_8 != OrderStopLoss()) OrderModify(OrderTicket(), OrderOpenPrice(), l_price_8, l_price_16, 0, CLR_NONE);
}
}
return (0);
}
int FinalStep(double ad_0) {
ad_0 = NormalizeDouble(ad_0 / Lots, 0);
switch (ad_0) {
case 1.0:
return (Step1);
case 2.0:
return (Step2);
case 4.0:
return (Step3);
case 8.0:
return (Step4);
case 16.0:
return (Step5);
case 32.0:
return (Step6);
case 64.0:
return (Step7);
case 128.0:
return (Step8);
case 256.0:
return (Step9);
case 512.0:
return (Step10);
}
return (Step10);
}
int FinalTP(double ad_0) {
ad_0 = NormalizeDouble(ad_0 / Lots, 0);
switch (ad_0) {
case 1.0:
return (TP1);
case 2.0:
return (TP2);
case 4.0:
return (TP3);
case 8.0:
return (TP4);
case 16.0:
return (TP5);
case 32.0:
return (TP6);
case 64.0:
return (TP7);
case 128.0:
return (TP8);
case 256.0:
return (TP9);
case 512.0:
return (TP10);
}
return (TP10);
}

No comments:

Post a Comment