Sabtu, 21 Juli 2012

TECHNICAL CHOPPY MOD V2 ( system forex )

Pair : EU, GU, EURCHF, USDCAD
Time Frame : M5
Take Profit : 10 - 20 Pips
Stops Lost : 20 - 30 pips
Rule :
Trading only on European session,
Candlestick wait 100 pips from the open market,

sell entry rule: wait SMA 7 cross SMA 50 ( up to down )
entry sell stop 10 pips from the price of crossing

buy entry rule: wait SMA 7 cross SMA 50 ( down to up )
entry buy stop 10 pips from the price of crossing

Kamis, 19 Juli 2012

CODING EA SEJUTA UMAT

CODING EA SEJUTA UMAT

I would then dismantle EA sejuta umat, EA has been using that acc PAMM, and the results were incredible !

This coding EA sejuta umat

#property copyright “Copyright © 2009,Milik Bersama”
#property link      “http://www.kitacobaramerame.com”
#property show_inputs
extern string Expert_Comment = “OP Robot”;
extern double TargetEquity = 50000.0;
extern bool CloseAllNow = FALSE;
extern int MaxTrades = 20;
extern double Lots = 0.1;
extern double LotDigit = 2.0;
extern bool SwitchLot = TRUE;
extern double TakeProfit = 10.0;
extern double Pips = 7.0;
extern double Multiplier = 1.5;
extern int MaxOrderBuy = 5;
extern int MaxOrderSell = 5;
extern double TS_Buy = 3.0;
extern double TS_Sell = 3.0;
extern double Slippage = 5.0;
extern bool UseHourTrade = TRUE;
extern bool ContinueTrade = FALSE;
extern int StartHour = 0;
extern int EndHour = 24;
extern int Magic = 291179;
extern double AutoCalculate = 20.0;
bool gi_204 = FALSE;
bool gi_208 = TRUE;
double g_pips_212 = 0.0;
bool gi_220 = FALSE;
bool gi_224 = TRUE;
bool gi_228 = FALSE;
double gd_232 = 0.0;
bool gi_240 = FALSE;
double g_price_244;
double gd_252;
double gd_unused_260;
double gd_unused_268;
double g_price_276;
double g_bid_284;
double g_ask_292;
double gd_300;
double gd_308;
double gd_316;
bool gi_324;
int g_time_328 = 0;
int gi_332;
int gi_336 = 0;
double gd_340;
int g_pos_348 = 0;
int gi_352;
double gd_356 = 0.0;
bool gi_364 = FALSE;
bool gi_368 = FALSE;
bool gi_372 = FALSE;
int gi_376;
bool gi_380 = FALSE;
int g_datetime_384 = 0;
int g_datetime_388 = 0;
double gd_392;
double gd_400;
double gd_408;
int g_count_420;
int g_count_424;
int g_count_428;
color g_color_432;
double g_bid_436;
int init() {
gd_316 = MarketInfo(Symbol(), MODE_SPREAD) * Point;
return (0);
}
int deinit() {
return (0);
}
int start() {
double l_ord_lots_0;
double l_ord_lots_8;
double l_iclose_16;
double l_iclose_24;
if (CloseAllNow == TRUE)
if (gd_408 == 0.0) CloseThisSymbolAll();
if (AccountEquity() > TargetEquity) {
CloseThisSymbolAll();
Comment(“\nTARGET TERCAPAI!”,
“\nModified by www.dpkforex.com”);
if (g_bid_436 > Close[0]) g_color_432 = Yellow;
else g_color_432 = Gold;
g_bid_436 = Bid;
tprofit();
return (0);
}
gd_408 = 0;
if (UseHourTrade) {
if (StartHour < EndHour) {
if (Hour() >= StartHour && Hour() <= EndHour) gd_408 = 1;
} else
if (Hour() >= StartHour || Hour() <= EndHour) gd_408 = 1;
}
g_count_420 = 0;
g_count_424 = 0;
g_count_428 = 0;
for (int l_pos_32 = 0; l_pos_32 < OrdersTotal(); l_pos_32++) {
OrderSelect(l_pos_32, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic) {
g_count_420++;
if (OrderType() == OP_BUY) g_count_424++;
if (OrderType() == OP_SELL) g_count_428++;
}
}
if (gd_408 == 0.0) {
if (ContinueTrade && g_count_420 > 0) {
Comment(“\nTrading …. CONTINUE!”,
“\nStart Hour : “, StartHour, “  EndHour : “, EndHour,
“\nModified by www.dpkforex.com”);
}
if (!ContinueTrade || (ContinueTrade && g_count_420 < 1)) {
Comment(“\nNon-Trading Hours! Im here www.dpkforex.com”);
return (0);
}
} else {
Comment(“\nTrading is READY!”,
“\nStart Hour : “, StartHour, “  EndHour : “, EndHour,
“\nModified by www.dpkforex.com”);
}
string ls_36 = “false”;
string ls_44 = “false”;
if (gi_240 == FALSE || (gi_240 && (EndHour > StartHour && (Hour() >= StartHour && Hour() <= EndHour)) || (StartHour > EndHour && !(Hour() >= EndHour && Hour() <= StartHour)))) ls_36 = “true”;
if (gi_240 && (EndHour > StartHour && !(Hour() >= StartHour && Hour() <= EndHour)) || (StartHour > EndHour && (Hour() >= EndHour && Hour() <= StartHour))) ls_44 = “true”;
if (gi_224) TrailingAlls(TS_Buy, TS_Sell, g_price_276);
if (gi_228)
if (TimeCurrent() >= gi_332) Print(“Closed All due to TimeOut”);
if (g_time_328 == Time[0]) return (0);
g_time_328 = Time[0];
double ld_52 = CalculateProfit();
if (gi_220) {
if (ld_52 < 0.0 && MathAbs(ld_52) > AutoCalculate / 100.0 * AccountEquityHigh()) {
Print(“Closed All due to Stop Out”);
gi_380 = FALSE;
}
}
gi_352 = CountTrades();
if (gi_352 == 0) gi_324 = FALSE;
for (g_pos_348 = OrdersTotal() – 1; g_pos_348 >= 0; g_pos_348–) {
OrderSelect(g_pos_348, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != Magic) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic) {
if (OrderType() == OP_BUY) {
gi_368 = TRUE;
gi_372 = FALSE;
l_ord_lots_0 = OrderLots();
break;
}
}
if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic) {
if (OrderType() == OP_SELL) {
gi_368 = FALSE;
gi_372 = TRUE;
l_ord_lots_8 = OrderLots();
break;
}
}
}
if (gi_352 > 0 && gi_352 <= MaxTrades) {
RefreshRates();
gd_300 = FindLastBuyPrice();
gd_308 = FindLastSellPrice();
if (gi_368 && gd_300 – Ask >= Pips * Point) gi_364 = TRUE;
if (gi_372 && Bid – gd_308 >= Pips * Point) gi_364 = TRUE;
}
if (gi_352 < 1) {
gi_372 = FALSE;
gi_368 = FALSE;
gi_364 = TRUE;
gd_252 = AccountEquity();
}
if (gi_364) {
gd_300 = FindLastBuyPrice();
gd_308 = FindLastSellPrice();
if (gi_372) {
if (gi_204 || ls_44 == “true”) {
fOrderCloseMarket(0, 1);
gd_340 = NormalizeDouble(Multiplier * l_ord_lots_8, LotDigit);
} else gd_340 = fGetLots(OP_SELL);
if (gi_208 && ls_36 == “true”) {
gi_336 = gi_352;
if (gd_340 > 0.0) {
RefreshRates();
gi_376 = OpenPendingOrder(1, gd_340, Bid, Slippage, Ask, 0, 0, Expert_Comment + “-” + gi_336, Magic, 0, HotPink);
if (gi_376 < 0) {
Print(“Error: “, GetLastError());
return (0);
}
gd_308 = FindLastSellPrice();
gi_364 = FALSE;
gi_380 = TRUE;
}
}
} else {
if (gi_368) {
if (gi_204 || ls_44 == “true”) {
fOrderCloseMarket(1, 0);
gd_340 = NormalizeDouble(Multiplier * l_ord_lots_0, LotDigit);
} else gd_340 = fGetLots(OP_BUY);
if (gi_208 && ls_36 == “true”) {
gi_336 = gi_352;
if (gd_340 > 0.0) {
gi_376 = OpenPendingOrder(0, gd_340, Ask, Slippage, Bid, 0, 0, Expert_Comment + “-” + gi_336, Magic, 0, Lime);
if (gi_376 < 0) {
Print(“Error: “, GetLastError());
return (0);
}
gd_300 = FindLastBuyPrice();
gi_364 = FALSE;
gi_380 = TRUE;
}
}
}
}
}
if (gi_364 && gi_352 < 1) {
l_iclose_16 = iClose(Symbol(), 0, 2);
l_iclose_24 = iClose(Symbol(), 0, 1);
g_bid_284 = Bid;
g_ask_292 = Ask;
if (!gi_372 && !gi_368 && ls_36 == “true”) {
gi_336 = gi_352;
if (l_iclose_16 > l_iclose_24) {
gd_340 = fGetLots(OP_SELL);
if (gd_340 > 0.0) {
gi_376 = OpenPendingOrder(1, gd_340, g_bid_284, Slippage, g_bid_284, 0, 0, Expert_Comment + “-” + gi_336, Magic, 0, HotPink);
if (gi_376 < 0) {
Print(gd_340, “Error: “, GetLastError());
return (0);
}
gd_300 = FindLastBuyPrice();
gi_380 = TRUE;
}
} else {
gd_340 = fGetLots(OP_BUY);
if (gd_340 > 0.0) {
gi_376 = OpenPendingOrder(0, gd_340, g_ask_292, Slippage, g_ask_292, 0, 0, Expert_Comment + “-” + gi_336, Magic, 0, Lime);
if (gi_376 < 0) {
Print(gd_340, “Error: “, GetLastError());
return (0);
}
gd_308 = FindLastSellPrice();
gi_380 = TRUE;
}
}
}
if (gi_376 > 0) gi_332 = TimeCurrent() + 60.0 * (60.0 * gd_232);
gi_364 = FALSE;
}
gi_352 = CountTrades();
g_price_276 = 0;
double ld_60 = 0;
for (g_pos_348 = OrdersTotal() – 1; g_pos_348 >= 0; g_pos_348–) {
OrderSelect(g_pos_348, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != Magic) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic) {
if (OrderType() == OP_BUY || OrderType() == OP_SELL) {
g_price_276 += OrderOpenPrice() * OrderLots();
ld_60 += OrderLots();
}
}
}
if (gi_352 > 0) g_price_276 = NormalizeDouble(g_price_276 / ld_60, Digits);
if (gi_380) {
for (g_pos_348 = OrdersTotal() – 1; g_pos_348 >= 0; g_pos_348–) {
OrderSelect(g_pos_348, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != Magic) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic) {
if (OrderType() == OP_BUY) {
g_price_244 = g_price_276 + TakeProfit * Point;
gd_unused_260 = g_price_244;
gd_356 = g_price_276 – g_pips_212 * Point;
gi_324 = TRUE;
}
}
if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic) {
if (OrderType() == OP_SELL) {
g_price_244 = g_price_276 – TakeProfit * Point;
gd_unused_268 = g_price_244;
gd_356 = g_price_276 + g_pips_212 * Point;
gi_324 = TRUE;
}
}
}
}
if (gi_380) {
if (gi_324 == TRUE) {
for (g_pos_348 = OrdersTotal() – 1; g_pos_348 >= 0; g_pos_348–) {
OrderSelect(g_pos_348, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != Magic) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic) OrderModify(OrderTicket(), g_price_276, OrderStopLoss(), g_price_244, 0, Yellow);
gi_380 = FALSE;
}
}
}
watermark();
return (0);
}
double ND(double ad_0) {
return (NormalizeDouble(ad_0, Digits));
}
int fOrderCloseMarket(bool ai_0 = TRUE, bool ai_4 = TRUE) {
int li_ret_8 = 0;
for (int l_pos_12 = OrdersTotal() – 1; l_pos_12 >= 0; l_pos_12–) {
if (OrderSelect(l_pos_12, SELECT_BY_POS, MODE_TRADES)) {
if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic) {
if (OrderType() == OP_BUY && ai_0) {
RefreshRates();
if (!IsTradeContextBusy()) {
if (!OrderClose(OrderTicket(), OrderLots(), ND(Bid), 5, CLR_NONE)) {
Print(“Error close BUY ” + OrderTicket());
li_ret_8 = -1;
}
} else {
if (g_datetime_384 != iTime(NULL, 0, 0)) {
g_datetime_384 = iTime(NULL, 0, 0);
Print(“Need close BUY ” + OrderTicket() + “. Trade Context Busy”);
}
return (-2);
}
}
if (OrderType() == OP_SELL && ai_4) {
RefreshRates();
if (!IsTradeContextBusy()) {
if (!OrderClose(OrderTicket(), OrderLots(), ND(Ask), 5, CLR_NONE)) {
Print(“Error close SELL ” + OrderTicket());
li_ret_8 = -1;
}
} else {
if (g_datetime_388 != iTime(NULL, 0, 0)) {
g_datetime_388 = iTime(NULL, 0, 0);
Print(“Need close SELL ” + OrderTicket() + “. Trade Context Busy”);
}
return (-2);
}
}
}
}
}
return (li_ret_8);
}
double fGetLots(int a_cmd_0) {
double l_lots_4;
int l_datetime_12;
switch (SwitchLot) {
case FALSE:
l_lots_4 = Lots;
break;
case TRUE:
l_lots_4 = NormalizeDouble(Lots * MathPow(Multiplier, gi_336), LotDigit);
break;
case 2:
l_datetime_12 = 0;
l_lots_4 = Lots;
for (int l_pos_20 = OrdersHistoryTotal() – 1; l_pos_20 >= 0; l_pos_20–) {
if (OrderSelect(l_pos_20, SELECT_BY_POS, MODE_HISTORY)) {
if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic) {
if (l_datetime_12 < OrderCloseTime()) {
l_datetime_12 = OrderCloseTime();
if (OrderProfit() < 0.0) l_lots_4 = NormalizeDouble(OrderLots() * Multiplier, LotDigit);
else l_lots_4 = Lots;
}
}
} else return (-3);
}
}
if (AccountFreeMarginCheck(Symbol(), a_cmd_0, l_lots_4) <= 0.0) return (-1);
if (GetLastError() == 134/* NOT_ENOUGH_MONEY */) return (-2);
if (l_lots_4 < 0.01) l_lots_4 = 0.01;
return (l_lots_4);
}
int CountTrades() {
int l_count_0 = 0;
for (int l_pos_4 = OrdersTotal() – 1; l_pos_4 >= 0; l_pos_4–) {
OrderSelect(l_pos_4, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != Magic) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic)
if (OrderType() == OP_SELL || OrderType() == OP_BUY) l_count_0++;
}
return (l_count_0);
}
void CloseThisSymbolAll() {
for (int l_pos_0 = OrdersTotal() – 1; l_pos_0 >= 0; l_pos_0–) {
OrderSelect(l_pos_0, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() == Symbol()) {
if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic) {
if (OrderType() == OP_BUY) OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, Blue);
if (OrderType() == OP_SELL) OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, Red);
}
Sleep(1000);
}
}
}
int OpenPendingOrder(int ai_0, double a_lots_4, double a_price_12, int a_slippage_20, double ad_24, int ai_unused_32, int ai_36, string a_comment_40, int a_magic_48, int a_datetime_52, color a_color_56) {
int l_ticket_60 = 0;
int l_error_64 = 0;
int l_count_68 = 0;
int li_72 = 100;
switch (ai_0) {
case 2:
for (l_count_68 = 0; l_count_68 < li_72; l_count_68++) {
l_ticket_60 = OrderSend(Symbol(), OP_BUYLIMIT, a_lots_4, a_price_12, a_slippage_20, StopLong(ad_24, g_pips_212), TakeLong(a_price_12, ai_36), a_comment_40, a_magic_48, a_datetime_52, a_color_56);
l_error_64 = GetLastError();
if (l_error_64 == 0/* NO_ERROR */) break;
if (!((l_error_64 == 4/* SERVER_BUSY */ || l_error_64 == 137/* BROKER_BUSY */ || l_error_64 == 146/* TRADE_CONTEXT_BUSY */ || l_error_64 == 136/* OFF_QUOTES */))) break;
Sleep(1000);
}
break;
case 4:
for (l_count_68 = 0; l_count_68 < li_72; l_count_68++) {
l_ticket_60 = OrderSend(Symbol(), OP_BUYSTOP, a_lots_4, a_price_12, a_slippage_20, StopLong(ad_24, g_pips_212), TakeLong(a_price_12, ai_36), a_comment_40, a_magic_48, a_datetime_52, a_color_56);
l_error_64 = GetLastError();
if (l_error_64 == 0/* NO_ERROR */) break;
if (!((l_error_64 == 4/* SERVER_BUSY */ || l_error_64 == 137/* BROKER_BUSY */ || l_error_64 == 146/* TRADE_CONTEXT_BUSY */ || l_error_64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 0:
for (l_count_68 = 0; l_count_68 < li_72; l_count_68++) {
RefreshRates();
if (g_count_424 < MaxOrderBuy) {
l_ticket_60 = OrderSend(Symbol(), OP_BUY, a_lots_4, Ask, a_slippage_20, StopLong(Bid, g_pips_212), TakeLong(Ask, ai_36), a_comment_40, a_magic_48, a_datetime_52, a_color_56);
l_error_64 = GetLastError();
if (l_error_64 == 0/* NO_ERROR */) break;
if (!((l_error_64 == 4/* SERVER_BUSY */ || l_error_64 == 137/* BROKER_BUSY */ || l_error_64 == 146/* TRADE_CONTEXT_BUSY */ || l_error_64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
}
break;
case 3:
for (l_count_68 = 0; l_count_68 < li_72; l_count_68++) {
l_ticket_60 = OrderSend(Symbol(), OP_SELLLIMIT, a_lots_4, a_price_12, a_slippage_20, StopShort(ad_24, g_pips_212), TakeShort(a_price_12, ai_36), a_comment_40, a_magic_48, a_datetime_52, a_color_56);
l_error_64 = GetLastError();
if (l_error_64 == 0/* NO_ERROR */) break;
if (!((l_error_64 == 4/* SERVER_BUSY */ || l_error_64 == 137/* BROKER_BUSY */ || l_error_64 == 146/* TRADE_CONTEXT_BUSY */ || l_error_64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 5:
for (l_count_68 = 0; l_count_68 < li_72; l_count_68++) {
l_ticket_60 = OrderSend(Symbol(), OP_SELLSTOP, a_lots_4, a_price_12, a_slippage_20, StopShort(ad_24, g_pips_212), TakeShort(a_price_12, ai_36), a_comment_40, a_magic_48, a_datetime_52, a_color_56);
l_error_64 = GetLastError();
if (l_error_64 == 0/* NO_ERROR */) break;
if (!((l_error_64 == 4/* SERVER_BUSY */ || l_error_64 == 137/* BROKER_BUSY */ || l_error_64 == 146/* TRADE_CONTEXT_BUSY */ || l_error_64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 1:
for (l_count_68 = 0; l_count_68 < li_72; l_count_68++) {
if (g_count_428 < MaxOrderSell) {
l_ticket_60 = OrderSend(Symbol(), OP_SELL, a_lots_4, Bid, a_slippage_20, StopShort(Ask, g_pips_212), TakeShort(Bid, ai_36), a_comment_40, a_magic_48, a_datetime_52, a_color_56);
l_error_64 = GetLastError();
if (l_error_64 == 0/* NO_ERROR */) break;
if (!((l_error_64 == 4/* SERVER_BUSY */ || l_error_64 == 137/* BROKER_BUSY */ || l_error_64 == 146/* TRADE_CONTEXT_BUSY */ || l_error_64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
}
}
return (l_ticket_60);
}
double StopLong(double ad_0, int ai_8) {
if (ai_8 == 0) return (0);
return (ad_0 – ai_8 * Point);
}
double StopShort(double ad_0, int ai_8) {
if (ai_8 == 0) return (0);
return (ad_0 + ai_8 * Point);
}
double TakeLong(double ad_0, int ai_8) {
if (ai_8 == 0) return (0);
return (ad_0 + ai_8 * Point);
}
double TakeShort(double ad_0, int ai_8) {
if (ai_8 == 0) return (0);
return (ad_0 – ai_8 * Point);
}
double CalculateProfit() {
double ld_ret_0 = 0;
for (g_pos_348 = OrdersTotal() – 1; g_pos_348 >= 0; g_pos_348–) {
OrderSelect(g_pos_348, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != Magic) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic)
if (OrderType() == OP_BUY || OrderType() == OP_SELL) ld_ret_0 += OrderProfit();
}
return (ld_ret_0);
}
void TrailingAlls(int ai_0, int ai_4, double a_price_8) {
int li_16;
double l_ord_stoploss_20;
double l_price_28;
if (ai_4 != 0) {
for (int l_pos_36 = OrdersTotal() – 1; l_pos_36 >= 0; l_pos_36–) {
if (OrderSelect(l_pos_36, SELECT_BY_POS, MODE_TRADES)) {
if (OrderSymbol() != Symbol() || OrderMagicNumber() != Magic) continue;
if (OrderSymbol() == Symbol() || OrderMagicNumber() == Magic) {
if (OrderType() == OP_BUY) {
li_16 = NormalizeDouble((Bid – a_price_8) / Point, 0);
if (li_16 < ai_0) continue;
l_ord_stoploss_20 = OrderStopLoss();
l_price_28 = Bid – ai_4 * Point;
if (l_ord_stoploss_20 == 0.0 || (l_ord_stoploss_20 != 0.0 && l_price_28 > l_ord_stoploss_20)) OrderModify(OrderTicket(), a_price_8, l_price_28, OrderTakeProfit(), 0, Aqua);
}
if (OrderType() == OP_SELL) {
li_16 = NormalizeDouble((a_price_8 – Ask) / Point, 0);
if (li_16 < ai_0) continue;
l_ord_stoploss_20 = OrderStopLoss();
l_price_28 = Ask + ai_4 * Point;
if (l_ord_stoploss_20 == 0.0 || (l_ord_stoploss_20 != 0.0 && l_price_28 < l_ord_stoploss_20)) OrderModify(OrderTicket(), a_price_8, l_price_28, OrderTakeProfit(), 0, Red);
}
}
Sleep(1000);
}
}
}
}
double AccountEquityHigh() {
if (CountTrades() == 0) gd_392 = AccountEquity();
if (gd_392 < gd_400) gd_392 = gd_400;
else gd_392 = AccountEquity();
gd_400 = AccountEquity();
return (gd_392);
}
double FindLastBuyPrice() {
double l_ord_open_price_0;
int l_ticket_8;
double ld_unused_12 = 0;
int l_ticket_20 = 0;
for (int l_pos_24 = OrdersTotal() – 1; l_pos_24 >= 0; l_pos_24–) {
OrderSelect(l_pos_24, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != Magic) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic && OrderType() == OP_BUY) {
l_ticket_8 = OrderTicket();
if (l_ticket_8 > l_ticket_20) {
l_ord_open_price_0 = OrderOpenPrice();
ld_unused_12 = l_ord_open_price_0;
l_ticket_20 = l_ticket_8;
}
}
}
return (l_ord_open_price_0);
}
double FindLastSellPrice() {
double l_ord_open_price_0;
int l_ticket_8;
double ld_unused_12 = 0;
int l_ticket_20 = 0;
for (int l_pos_24 = OrdersTotal() – 1; l_pos_24 >= 0; l_pos_24–) {
OrderSelect(l_pos_24, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != Magic) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic && OrderType() == OP_SELL) {
l_ticket_8 = OrderTicket();
if (l_ticket_8 > l_ticket_20) {
l_ord_open_price_0 = OrderOpenPrice();
ld_unused_12 = l_ord_open_price_0;
l_ticket_20 = l_ticket_8;
}
}
}
return (l_ord_open_price_0);
}
void watermark() {
string l_text_0 = “www.dpkforex.com : free donation LibertyReserve : U1240603″;
ObjectCreate(“dpkfx”, OBJ_LABEL, 0, 0, 0);
ObjectSetText(“dpkfx”, l_text_0, 8, “Verdana Bold”, Silver);
ObjectSet(“dpkfx”, OBJPROP_CORNER, 2);
ObjectSet(“dpkfx”, OBJPROP_XDISTANCE, 5);
ObjectSet(“dpkfx”, OBJPROP_YDISTANCE, 10);
}
void tprofit() {
string l_text_8;
string l_text_0 = “Asik nih dah capai TARGET..!!”;
ObjectCreate(“dpkfx”, OBJ_LABEL, 0, 0, 0);
ObjectSetText(“dpkfx”, l_text_0, 15, “Verdana Bold”, White);
ObjectSet(“dpkfx”, OBJPROP_CORNER, 2);
ObjectSet(“dpkfx”, OBJPROP_XDISTANCE, 5);
ObjectSet(“dpkfx”, OBJPROP_YDISTANCE, 40);
if (!IsTesting() && !IsDemo()) {
l_text_8 = “free donation LibertyReserve : U1240603″;
ObjectCreate(“dpkfx1″, OBJ_LABEL, 0, 0, 0);
ObjectSetText(“dpkfx1″, l_text_8, 10, “Verdana Bold”, g_color_432);
ObjectSet(“dpkfx1″, OBJPROP_CORNER, 2);
ObjectSet(“dpkfx1″, OBJPROP_XDISTANCE, 5);
ObjectSet(“dpkfx1″, OBJPROP_YDISTANCE, 26);
}
}

Rabu, 18 Juli 2012

CODING EA PIPLASER

CODING EA PIPLASER
 
#property copyright “The PipLaser Team”
#property link      “”
#include <WinUser32.mqh>
#import “kernel32.dll”
int GetTimeZoneInformation(int& a0[]);
#import
/*#import “PipLaser.dll”
void Activate(string a0, int a1, int a2, string a3, int a4);
int GetState();
int GetGmtOffset(int a0, int a1, double& a2[]);
bool open_buy(double a0, double a1, int a2, int a3, double a4, double a5, int a6, double a7, int a8);
bool open_sell(double a0, double a1, int a2, int a3, double a4, double a5, int a6, double a7, int a8);
bool trade_time(int a0);
#import*/
extern string ver.1.00 = “PipLaser”;
//extern string AuthCode = “”;
extern string Trading = “Trade Management”;
extern double MinLotSize = 0.01;
extern double MaxLotSize = 10.0;
extern double TradeLevel = 20.0;
extern bool EquityMode = TRUE;
extern bool StealthMode = FALSE;
extern int PipTarget = 8;
extern int StopLoss = 50;
extern int TimeProtect = 120;
extern string Broker = “Broker Management”;
extern int GmtOffset = 1;
extern bool AutoGmtOffset = TRUE;
extern int MaxSpread = 5;
extern int Reference = 201007;
int g_period_168 = 11;
int gi_172 = 7;
extern string DrawSettings = “Screen Settings”;
extern int TopPadding = 20;
extern int LeftPadding = 20;
extern color TextColor1 = Gold;
extern color TextColor2 = DarkOrange;
int g_datetime_200;
int gi_204;
int gi_208 = 0;
int gi_216 = 0;
string gs_220;
string gsa_228[] = {“.”, “..”, “…”, “….”, “…..”};
int gi_240 = 0;
int gi_244 = 0;
int gi_248 = 0;
int gi_252;
int gi_256;
int gi_260;
int gi_264;
int gi_268 = -1;
//string gs_272 = “0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ”;
bool gi_292;
bool gi_300;
string CPrint(bool ai_0, string as_4, string as_12 = “”) {
if (ai_0) return (as_4);
return (as_12);
}
/*string PPrint(int ai_0) {
int li_4 = MathMod(ai_0, 5);
return (gsa_228[li_4]);
}
void PrintResponse(int ai_0, int ai_4 = -1, int ai_8 = -1) {
bool li_12 = FALSE;
if (gi_268 != ai_0) {
li_12 = TRUE;
gi_268 = ai_0;
}
if (ai_4 == -1) ai_4 = gi_244;
if (ai_8 == -1) ai_8 = gi_240;
gi_244 = ai_4;
gi_240 = ai_8;
if (ai_0 & 16384 > 0) PrintLNL(li_12, “Authenticated”, TextColor1);
else PrintLNL(li_12, “Authentication failed – error(” + ai_0 + “)”, TextColor1);
if (ai_0 & 512 > 0) PrintLNL(li_12, “Attention: Upgrade available”, TextColor1);
if (ai_0 & 1024 > 0) PrintLNL(li_12, “Error: Upgrade required”, TextColor1);
if (ai_0 & 1 > 0) PrintLNL(li_12, “Error: WinINet initialisation failed”, TextColor1);
if (ai_0 & 2 > 0) PrintLNL(li_12, “Error: WinINet connection failed”, TextColor1);
if (ai_0 & 4 > 0) PrintLNL(li_12, “Error: Invalid account number”, TextColor1);
if (ai_0 & 8 > 0) PrintLNL(li_12, “Error: Invalid account status”, TextColor1);
if (ai_0 & 16 > 0) PrintLNL(li_12, “Error: Dll and Expert versions mismatch”, TextColor1);
if (ai_0 & 128 > 0) PrintLNL(li_12, “Error: Unable to retrieve authentication code”, TextColor1);
if (ai_0 & 256 > 0) PrintLNL(li_12, “Error: Server response failure”, TextColor1);
if (ai_0 & 2048 > 0) PrintLNL(li_12, “Error: Invalid authorisation details”, TextColor1);
if (ai_0 & 4096 > 0) PrintLNL(li_12, “Error: Authorisation declined”, TextColor1);
}
*/
string GetObjName(int ai_0) {
return (StringConcatenate(“PipLaser”, ” lb: “, ai_0));
}
void GetPos(int ai_0, int &ai_4, int &ai_8) {
string l_name_12 = GetObjName(ai_0);
if (ObjectFind(l_name_12) == 0) {
ai_4 = ObjectGet(l_name_12, OBJPROP_XDISTANCE);
ai_8 = ObjectGet(l_name_12, OBJPROP_YDISTANCE);
}
}
/*void PrintLNL(bool ai_0, string as_4, int ai_12 = -1, int ai_16 = -1, double ad_20 = -1.0, int ai_28 = 0) {
PrintLN(as_4, ai_12, ai_16, ad_20, ai_28);
if (ai_0) Print(as_4);
}*/
void PrintLN(string a_text_0, color a_color_8 = -1, int ai_12 = -1, double ad_16 = -1.0, int ai_24 = 0) {
if (a_color_8 == CLR_NONE) a_color_8 = TextColor1;
if (ai_12 == -1) ai_12 = gi_244;
if (ad_16 == -1.0) ad_16 = gi_240;
string l_name_28 = GetObjName(ai_12);
if (ObjectFind(l_name_28) != 0) {
ObjectCreate(l_name_28, OBJ_LABEL, 0, 0, 0);
ObjectSet(l_name_28, OBJPROP_CORNER, 0);
}
ObjectSetText(l_name_28, a_text_0, 8, “Tahoma”, a_color_8);
ObjectSet(l_name_28, OBJPROP_XDISTANCE, gi_256 + ai_24);
ObjectSet(l_name_28, OBJPROP_YDISTANCE, gi_252 + 14.0 * ad_16);
if (gi_240 < ad_16 + 1.0) gi_240 = ad_16 + 1.0;
if (gi_244 < ai_12 + 1) gi_244 = ai_12 + 1;
if (gi_248 < ai_12) gi_248 = ai_12;
}
void PrintSep(int ai_0 = -1, double ad_4 = -1.0, int ai_12 = 0) {
if (ai_0 == -1) ai_0 = gi_244;
if (ad_4 == -1.0) ad_4 = gi_240;
PrintLN(“_______”, TextColor2, ai_0, ad_4 – 0.3, ai_12);
if (gi_240 < ad_4 + 1.0) gi_240 = ad_4 + 1.0;
}
void Deleteobjects(int ai_0, int ai_4) {
for (int li_8 = ai_0; li_8 <= ai_4; li_8++) ObjectDelete(GetObjName(li_8));
}
/*double Base36Decode(string as_0) {
int li_24;
as_0 = StringUpper(as_0);
int l_str_len_8 = StringLen(as_0);
double ld_ret_12 = 0;
for (int li_20 = 0; li_20 < l_str_len_8; li_20++) {
li_24 = StringFind(gs_272, StringSubstr(as_0, l_str_len_8 – li_20 – 1, 1));
ld_ret_12 += li_24 * MathPow(36, li_20);
}
return (ld_ret_12);
}
string Base36Encode(double ad_0) {
string l_str_concat_8 = “”;
for (ad_0 = MathAbs(ad_0); ad_0 >= 1.0; ad_0 = MathFloor(ad_0 / 36.0)) l_str_concat_8 = StringConcatenate(StringSubstr(gs_272, MathMod(ad_0, 36), 1), l_str_concat_8);
return (l_str_concat_8);
}
string StringUpper(string as_0) {
int li_8;
int li_20;
int l_str_len_16 = StringLen(as_0);
for (int li_12 = 0; li_12 < l_str_len_16; li_12++) {
li_20 = 0;
li_8 = StringGetChar(as_0, li_12);
if (li_8 > ‘`’ && li_8 < ‘{‘) li_20 = li_8 – 32;
if (li_8 > ‘ß’ && li_8 < 256) li_20 = li_8 – 32;
if (li_8 == ‘¸’) li_20 = 168;
if (li_20 > 0) as_0 = StringSetChar(as_0, li_12, li_20);
}
return (as_0);
}
*/
double OrderSize() {
double ld_ret_0;
double l_lotsize_8 = MarketInfo(Symbol(), MODE_LOTSIZE);
double ld_16 = NormalizeDouble(MarketInfo(Symbol(), MODE_LOTSTEP), 2);
double ld_24 = NormalizeDouble(MarketInfo(Symbol(), MODE_TICKVALUE), 2);
double ld_32 = NormalizeDouble(MarketInfo(Symbol(), MODE_MARGINREQUIRED), 2);
int li_40 = 2;
if (ld_16 == 0.1) li_40 = 1;
else
if (ld_16 > 0.1) li_40 = 0;
double ld_44 = NormalizeDouble(MarketInfo(Symbol(), MODE_MINLOT), li_40);
double ld_52 = NormalizeDouble(MarketInfo(Symbol(), MODE_MAXLOT), li_40);
if (TradeLevel < 0.0) ld_ret_0 = MathAbs(TradeLevel);
else {
if (EquityMode) ld_ret_0 = NormalizeDouble(AccountEquity() * TradeLevel / 100.0 / StopLoss / ld_24 * ld_16, li_40);
else ld_ret_0 = NormalizeDouble(AccountFreeMargin() * TradeLevel / l_lotsize_8, li_40);
}
if (ld_ret_0 < MinLotSize) ld_ret_0 = NormalizeDouble(MinLotSize, li_40);
if (ld_ret_0 > MaxLotSize) ld_ret_0 = NormalizeDouble(MaxLotSize, li_40);
if (ld_ret_0 < ld_44) ld_ret_0 = NormalizeDouble(ld_44, li_40);
if (ld_ret_0 > ld_52) ld_ret_0 = NormalizeDouble(ld_52, li_40);
return (ld_ret_0);
}
double PointValue() {
if (MarketInfo(Symbol(), MODE_DIGITS) == 5.0 || MarketInfo(Symbol(), MODE_DIGITS) == 3.0) return (10.0 * Point);
return (Point);
}
double TimeProtect() {
for (int l_pos_0 = OrdersTotal() – 1; l_pos_0 >= 0; l_pos_0–) {
OrderSelect(l_pos_0, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() == Symbol() && OrderMagicNumber() == Reference) {
if (g_datetime_200 – OrderOpenTime() >= 60 * TimeProtect && OrderProfit() >= 10.0 * OrderLots()) {
if (OrderType() == OP_BUY) OrderClose(OrderTicket(), OrderLots(), NormalizeDouble(Bid, Digits), 1, Green);
if (OrderType() == OP_SELL) OrderClose(OrderTicket(), OrderLots(), NormalizeDouble(Ask, Digits), 1, Red);
}
}
}
return (0.0);
}
double ClosedProfit() {
double ld_ret_0 = 0;
for (int l_pos_8 = OrdersHistoryTotal() – 1; l_pos_8 >= 0; l_pos_8–) {
OrderSelect(l_pos_8, SELECT_BY_POS, MODE_HISTORY);
if (OrderSymbol() == Symbol() && OrderMagicNumber() == Reference && TimeYear(OrderCloseTime()) == TimeYear(g_datetime_200) && TimeMonth(OrderCloseTime()) == TimeMonth(g_datetime_200) &&
TimeDay(OrderCloseTime()) == TimeDay(g_datetime_200)) ld_ret_0 += OrderProfit();
}
return (ld_ret_0);
}
double OpenProfit() {
double ld_ret_0 = 0;
for (int l_pos_8 = OrdersTotal() – 1; l_pos_8 >= 0; l_pos_8–) {
OrderSelect(l_pos_8, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() == Symbol() && OrderMagicNumber() == Reference) ld_ret_0 += OrderProfit();
}
return (ld_ret_0);
}
bool OpenTrades() {
for (int l_pos_0 = OrdersTotal() – 1; l_pos_0 >= 0; l_pos_0–) {
OrderSelect(l_pos_0, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() == Symbol() && OrderMagicNumber() == Reference) return (TRUE);
}
return (FALSE);
}
void CheckForOpen() {
double l_ifractals_0;
double l_ifractals_8;
double l_ifractals_16;
double l_ifractals_24;
HideTestIndicators(TRUE);
for (int li_32 = 1; li_32 < Bars; li_32++) {
if (iFractals(NULL, PERIOD_M15, MODE_UPPER, li_32) != 0.0) {
l_ifractals_0 = iFractals(NULL, PERIOD_M15, MODE_UPPER, li_32);
break;
}
}
for (li_32 = 1; li_32 < Bars; li_32++) {
if (iFractals(NULL, PERIOD_M15, MODE_LOWER, li_32) != 0.0) {
l_ifractals_8 = iFractals(NULL, PERIOD_M15, MODE_LOWER, li_32);
break;
}
}
for (li_32 = 1; li_32 < Bars; li_32++) {
if (iFractals(NULL, PERIOD_H1, MODE_UPPER, li_32) != 0.0) {
l_ifractals_16 = iFractals(NULL, PERIOD_H1, MODE_UPPER, li_32);
break;
}
}
for (li_32 = 1; li_32 < Bars; li_32++) {
if (iFractals(NULL, PERIOD_H1, MODE_LOWER, li_32) != 0.0) {
l_ifractals_24 = iFractals(NULL, PERIOD_H1, MODE_LOWER, li_32);
break;
}
}
double ld_36 = MathRound((l_ifractals_0 – l_ifractals_8) / PointValue());
double ld_44 = MathRound((l_ifractals_16 – l_ifractals_24) / PointValue());
double ld_52 = l_ifractals_0 – (l_ifractals_0 – l_ifractals_8) / 2.0;
bool li_60 = FALSE;
if (iClose(Symbol(), PERIOD_M15, 0) <= l_ifractals_16 && iClose(Symbol(), PERIOD_M15, 0) >= l_ifractals_24) li_60 = TRUE;
bool li_64 = FALSE;
bool li_68 = FALSE;
if (Ask <= NormalizeDouble(iMA(Symbol(), PERIOD_M5, g_period_168, 0, MODE_SMA, PRICE_OPEN, 0), Digits) – 5.0 * PointValue()) li_64 = TRUE;
if (Bid >= NormalizeDouble(iMA(Symbol(), PERIOD_M5, g_period_168, 0, MODE_SMA, PRICE_OPEN, 0), Digits) + 5.0 * PointValue()) li_68 = TRUE;
double ld_72 = 10000.0;
int li_80 = 6;
int li_84 = 0;
ld_72 /= (li_80 – li_84);
double l_ima_88 = iMA(NULL, PERIOD_M1, g_period_168, 0, MODE_EMA, PRICE_CLOSE, li_84 + 0);
double l_ima_96 = iMA(NULL, PERIOD_M1, g_period_168, 0, MODE_EMA, PRICE_CLOSE, li_80 + 0);
double ld_104 = ld_72 * (l_ima_88 – l_ima_96);
if (open_buy(Ask, Bid, MaxSpread, li_60, ld_104, ld_52, gi_172, PointValue(), li_64)) {
OrderSend(Symbol(), OP_BUY, OrderSize(), NormalizeDouble(Ask, Digits), 2, 0, 0, “”, Reference, 0, Green);
Sleep(1000);
}
if (open_sell(Ask, Bid, MaxSpread, li_60, ld_104, ld_52, gi_172, PointValue(), li_68)) {
OrderSend(Symbol(), OP_SELL, OrderSize(), NormalizeDouble(Bid, Digits), 2, 0, 0, “”, Reference, 0, Red);
Sleep(1000);
}
}
void init() {
double l_global_var_4;
double ld_12;
gi_256 = LeftPadding;
gi_252 = TopPadding;
if (gi_260 != LeftPadding || gi_264 != TopPadding) {
gi_260 = LeftPadding;
gi_264 = TopPadding;
} else GetPos(0, gi_256, gi_252);
gi_244 = 0;
gi_240 = 0;
gs_220 = “PipLaser” + ” ver: ” + “1.00″ + CPrint(IsTesting(), ” (backtesting)”, “”);
PrintLN(gs_220, TextColor2);
PrintSep();
ObjectsRedraw();
/*for (int l_count_0 = 0; !IsStopped() && !IsConnected() || StringLen(AccountName()) <= 0; l_count_0++) {
PrintLN(“Waiting for connection” + PPrint(l_count_0), TextColor1, 2, 2);
ObjectsRedraw();
Sleep(150);
}
PrintLN(“Authentication…”, TextColor1, 2, 2);
ObjectsRedraw();
gi_216 = 0;
AuthCode = StringTrimLeft(StringTrimRight(AuthCode));
if (StringLen(AuthCode) <= 0) {
if (GlobalVariableCheck(“GV_PipLaser_REC”)) {
l_global_var_4 = GlobalVariableGet(“GV_PipLaser_REC”);
AuthCode = Base36Encode(l_global_var_4);
} else gi_216 |= 32;
} else {
ld_12 = Base36Decode(AuthCode);
if (GlobalVariableSet(“GV_PipLaser_REC”, ld_12) == 0) gi_216 |= 64;
}
Activate(“1.00″, AccountNumber(), IsDemo(), AuthCode, 1);
gi_212 = GetState();
gi_212 |= gi_216;
PrintResponse(gi_212, 2, 2);
PrintSep();
ObjectsRedraw();*/
gi_292 = StringFind(Symbol(), “USDCAD”) < 0;
gi_300 = TRUE;
}
void deinit() {
if (IsTesting() == 0) {
switch (UninitializeReason()) {
case REASON_CHARTCLOSE:
case REASON_REMOVE:
Deleteobjects(0, gi_248);
gi_248 = 0;
return;
case REASON_RECOMPILE:
case REASON_CHARTCHANGE:
case REASON_PARAMETERS:
case REASON_ACCOUNT:
Deleteobjects(1, gi_248);
gi_248 = 1;
}
}
}
void start() {
double l_price_4;
double l_price_12;
if (gi_300) {
if (gi_292) MessageBox(“You have selected the wrong currency pair!\nCorrect currency pair is USDCAD.”, gs_220 + “: Warning”, MB_ICONEXCLAMATION);
gi_300 = FALSE;
}
if (gi_292 == 0) {
//gi_212 = GetState();
g_datetime_200 = TimeCurrent();
if (!IsTesting() && AutoGmtOffset) {
//double lda_0[1] = {0};
//if (gi_208 != 0)
GmtOffset = GetGmtOffset();//lda_0[0];
//gi_208 = MathMod(24+Hour()-GMTOffset,24);//GetGmtOffset();//g_datetime_200, 1, lda_0);
}
gi_204 = g_datetime_200 – 3600.0 * GmtOffset;
if (!IsTesting() || IsVisualMode()) {
GetPos(0, gi_256, gi_252);
gi_244 = 0;
gi_240 = 0;
PrintLN(gs_220, TextColor2);
PrintSep();
//PrintResponse(gi_212 | gi_216);
//PrintSep();
PrintLN(“ServerTime:”);
PrintLN(TimeToStr(g_datetime_200), TextColor2, gi_244, gi_240 – 1, 60);
PrintLN(“UtcTime:”);
PrintLN(TimeToStr(gi_204), TextColor2, gi_244, gi_240 – 1, 45);
PrintLN(“GmtOffset:”);
PrintLN(StringConcatenate(DoubleToStr(GmtOffset, 1), CPrint(!IsTesting() && AutoGmtOffset, ” (automatic)”, ” (manual)”)), TextColor2, gi_244, gi_240 – 1, 50);
PrintSep();
PrintLN(“Closed Trade P/L:”);
PrintLN(DoubleToStr(ClosedProfit(), 2), TextColor2, gi_244, gi_240 – 1, 85);
PrintLN(“Open Trade P/L:”);
PrintLN(DoubleToStr(OpenProfit(), 2), TextColor2, gi_244, gi_240 – 1, 75);
PrintLN(“Balance:”);
PrintLN(DoubleToStr(AccountBalance(), 2), TextColor2, gi_244, gi_240 – 1, 40);
PrintLN(“Equity:”);
PrintLN(DoubleToStr(AccountEquity(), 2), TextColor2, gi_244, gi_240 – 1, 40);
PrintLN(“Free Margin:”);
PrintLN(DoubleToStr(AccountFreeMargin(), 2), TextColor2, gi_244, gi_240 – 1, 60);
PrintLN(“Margin Required:”);
PrintLN(StringConcatenate(DoubleToStr(MarketInfo(Symbol(), MODE_MARGINREQUIRED), 2), ” per $”, DoubleToStr(MarketInfo(Symbol(), MODE_LOTSIZE), 2), ” position”), TextColor2, gi_244, gi_240 – 1, 80);
PrintLN(“Pending Order Size:”);
PrintLN(StringConcatenate(DoubleToStr(OrderSize(), 2), ” lots @ $”, DoubleToStr(MarketInfo(Symbol(), MODE_TICKVALUE), 2), ” per tick per “, DoubleToStr(MarketInfo(Symbol(), MODE_MINLOT), 2), ” lots”), TextColor2, gi_244, gi_240 – 1, 95);
Deleteobjects(gi_244, gi_248);
gi_248 = gi_244 – 1;
ObjectsRedraw();
}
if (OpenTrades()) {
if (TimeProtect > 0) TimeProtect();
for (int l_pos_20 = OrdersTotal() – 1; l_pos_20 >= 0; l_pos_20–) {
OrderSelect(l_pos_20, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() == Symbol() && OrderMagicNumber() == Reference) {
if (OrderType() == OP_BUY) {
if (OrderOpenPrice() – Ask >= PointValue() * StopLoss || Ask – OrderOpenPrice() >= PointValue() * PipTarget) OrderClose(OrderTicket(), OrderLots(), NormalizeDouble(Bid, Digits), 1, Green);
else {
if (!StealthMode && OrderStopLoss() == 0.0 || OrderTakeProfit() == 0.0) {
l_price_4 = NormalizeDouble(OrderOpenPrice() + PointValue() * PipTarget, Digits);
l_price_12 = NormalizeDouble(OrderOpenPrice() – PointValue() * StopLoss, Digits);
OrderModify(OrderTicket(), OrderOpenPrice(), l_price_12, l_price_4, 0, Green);
}
}
}
if (OrderType() == OP_SELL) {
if (OrderOpenPrice() – Bid >= PointValue() * PipTarget || Bid – OrderOpenPrice() >= PointValue() * StopLoss) OrderClose(OrderTicket(), OrderLots(), NormalizeDouble(Ask, Digits), 1, Red);
else {
if (!StealthMode && OrderStopLoss() == 0.0 || OrderTakeProfit() == 0.0) {
l_price_4 = NormalizeDouble(OrderOpenPrice() – PointValue() * PipTarget, Digits);
l_price_12 = NormalizeDouble(OrderOpenPrice() + PointValue() * StopLoss, Digits);
OrderModify(OrderTicket(), OrderOpenPrice(), l_price_12, l_price_4, 0, Red);
}
}
}
}
}
}
if (trade_time(gi_204) && !OpenTrades()) CheckForOpen();
}
}
bool open_buy(double a1, double a2, int a3, bool a4, double a5, double a6, int a7, double a8, bool a9) {
return (a1-a2<a3*a8 && a4 && a5<=-0.12 && a2<=a6-a8*a7 && a9);
}
bool open_sell(double a1, double a2, int a3, bool a4, double a5, double a6, int a7, double a8, bool a9) {
return (a1-a2<a3*a8 && a4 && a5>=0.12 && a6-a8*a7<=a1 && a9);
}
bool trade_time(int time) {
if (DayOfWeek()>0) {
if (TimeHour(time) != 22) return (false);
}
else {
if (TimeHour(time) != 22 || Minute() < 30 ) return (false);
}
if (Month() == 10 ) {
if (TimeDay(time) == 17) return (false);
if (TimeDay(time)==27) return (false);
}
else if (Month() == 11) {
if (TimeDay(time) == 1) return (false);
if (TimeDay(time)==23) return (false);
}
return (true);
}
double TimeZoneLocal() {
int lia_0[43];
switch (GetTimeZoneInformation(lia_0)) {
case 0:
return (lia_0[0] / (-60.0));
case 1:
return (lia_0[0] / (-60.0));
case 2:
return ((lia_0[0] + lia_0[42]) / (-60.0));
}
return (0);
}
double GetGmtOffset() {
int li_0 = (TimeCurrent() – TimeLocal()) / 60;
int li_4 = MathRound(li_0 / 30.0);
li_0 = 30 * li_4;
double ld_ret_8 = TimeZoneLocal() + li_0 / 60.0;
return (ld_ret_8);
}

Selasa, 17 Juli 2012

CODING EA PYRAMID

There PyramidEA code but this coding only run in demo acc .. No coding acc lock it ..
if my friends want the make the acc real, my friends have to find and edit lockingnya, must be run in real acc


#property copyright “Copyright © 2009 PyramidEA™”
#property link “http://www.PyramidRobotForex.com”
extern string PyramidEA = “.:: PyramidEA™ ULTIMATE DEMO ::.”;
extern string AccountTypeInfo = “2=(0.01 Lot), 1=(0.1 Lot), 0=(1.0 Lot)”;
extern int AccountType = 2;
double gd_96 = 0.01;
double gd_104 = 7.0;
double g_pips_112 = 53.0;
int gi_120 = 23;
int gi_124 = 7;
double gd_128 = 2.3;
double gd_136 = 1.7;
bool gi_144 = TRUE;
int gi_148 = 2;
int gi_152 = 2;
int gi_156 = 7;
int gi_160 = 18;
int gi_164 = 19;
int g_magic_168 = 13579;
int gi_172 = 24680;
bool gi_176 = TRUE;
string g_comment_180 = “PyramidEA DEMO”;

int gi_unused_188 = 0;
double g_pips_192 = 0.0;
int gi_unused_200 = 0;
int g_count_204 = 0;
int g_pos_208 = 0;
int g_slippage_212 = 5;
double g_price_216 = 0.0;
double g_price_224 = 0.0;
double g_ask_232 = 0.0;
double g_bid_240 = 0.0;
double gd_248 = 0.0;
double g_lots_256 = 0.0;
double gd_unused_264 = 0.0;
int g_cmd_272 = OP_BUY;
int gi_276 = 0;
bool gi_280 = TRUE;
double g_ord_open_price_284 = 0.0;
int gi_292 = 0;
double gd_296 = 0.0;
int g_ticket_304 = 0;
int gi_308 = 0;
double g_price_312 = 0.0;
double g_ord_lots_320 = 0.0;
double gd_unused_328 = 0.0;
string gs_336 = “”;
int g_count_344 = 0;
int start() {
bool l_bool_0;
int l_acc_number_4;
if (gi_176) {
l_bool_0 = IsDemo();
if (!l_bool_0) {
l_acc_number_4 = AccountNumber();
if (l_acc_number_4 != gi_172) {
Alert(“Only DEMO Account can use this EA ! – PyramidRobotForex.com”);
return (0);
}
}
}
double l_icustom_8 = iCustom(NULL, 0, “Indicator1″, 0, 1);
double l_icustom_16 = iCustom(NULL, 0, “Indicator1″, 1, 1);
double l_icustom_24 = iCustom(NULL, 0, “Indicator2″, 2, 1);
double l_icustom_32 = iCustom(NULL, 0, “Indicator2″, 3, 1);
double l_icustom_40 = iCustom(NULL, 0, “Indicator3″, 0, 1);
double l_icustom_48 = iCustom(NULL, 0, “Indicator3″, 1, 1);
double l_icustom_56 = iCustom(NULL, 0, “Indicator3″, 2, 1);
double l_imacd_64 = iMACD(NULL, 0, 12, 26, 9, PRICE_CLOSE, MODE_SIGNAL, 1);
double l_imacd_72 = iMACD(NULL, 0, 12, 26, 9, PRICE_CLOSE, MODE_MAIN, 1);
double ld_80 = NormalizeDouble(MarketInfo(Symbol(), MODE_MINLOT), AccountType);
double ld_88 = NormalizeDouble(MarketInfo(Symbol(), MODE_MAXLOT), AccountType);
double ld_96 = NormalizeDouble(MarketInfo(Symbol(), MODE_LOTSIZE), AccountType);
double l_tickvalue_104 = MarketInfo(Symbol(), MODE_TICKVALUE);
if (gi_144) {
switch (AccountType) {
case 0:
gd_248 = NormalizeDouble(gd_136 * AccountEquity() / 100000.0, 0);
break;
case 1:
gd_248 = NormalizeDouble(gd_136 * AccountEquity() / 100000.0, 1);
break;
case 2:
gd_248 = NormalizeDouble(gd_136 * AccountEquity() / 100000.0, 2);
break;
default:
gd_248 = NormalizeDouble(gd_136 * AccountEquity() / 100000.0, 1);
}
} else gd_248 = gd_96;
if (gd_248 ld_88) gd_248 = ld_88;
g_count_204 = 0;
g_count_344 = 0;
for (g_pos_208 = 0; g_pos_208 g_count_204) {
for (g_pos_208 = OrdersTotal(); g_pos_208 >= 0; g_pos_208–) {
OrderSelect(g_pos_208, SELECT_BY_POS, MODE_TRADES);
g_cmd_272 = OrderType();
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_168) {
if (g_cmd_272 == OP_BUY) OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), g_slippage_212, Green);
if (g_cmd_272 == OP_SELL) OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), g_slippage_212, Green);
return (0);
}
}
}
gi_292 = g_count_204;
if (g_count_204 >= gi_124) gi_280 = FALSE;
else gi_280 = TRUE;
if (g_ord_open_price_284 == 0.0) {
for (g_pos_208 = 0; g_pos_208 = gi_152 && Hour() = gi_160 && Hour() 0.0 && l_icustom_24 > l_icustom_32 && l_icustom_56 == l_icustom_40 && (l_imacd_64 > l_imacd_72 && l_imacd_72 0.0 && l_icustom_24 < l_icustom_32 && l_icustom_48 == l_icustom_40 && (l_imacd_64 0.0)) gi_276 = 2;
}
}
gd_296 = 0;
g_ticket_304 = 0;
gi_308 = FALSE;
g_price_312 = 0;
g_ord_lots_320 = 0;
for (g_pos_208 = 0; g_pos_208 < OrdersTotal(); g_pos_208++) {
OrderSelect(g_pos_208, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_168) {
g_ticket_304 = OrderTicket();
if (OrderType() == OP_BUY) gi_308 = FALSE;
if (OrderType() == OP_SELL) gi_308 = TRUE;
g_price_312 = OrderClosePrice();
g_ord_lots_320 = OrderLots();
g_ord_open_price_284 = OrderOpenPrice();
if (gi_308 == FALSE) {
if (OrderClosePrice() OrderOpenPrice()) gd_296 += (OrderClosePrice() – OrderOpenPrice()) * OrderLots() / Point;
}
if (gi_308 == TRUE) {
if (OrderClosePrice() > OrderOpenPrice()) gd_296 -= (OrderClosePrice() – OrderOpenPrice()) * OrderLots() / Point;
if (OrderClosePrice() = 1) g_pips_192 = 0;
if (g_count_204 == 0) g_pips_192 = gd_104;
if (gi_276 == 3) gs_336 = ” | Analyzing…”;
else gs_336 = “”;
Comment(“Account: “, AccountNumber(), ” | Name: “, AccountName(), ” | Laverage: 1:”, AccountLeverage(), ” | Total Balance: “, DoubleToStr(AccountBalance(), 2), ” | Profit: $”, DoubleToStr(AccountProfit(), 2), “+/- “, gs_336,
“\n”, PyramidEA);
if (AccountEquity() > AccountBalance()) {
if ((Hour() > gi_156 && Hour() gi_164) {
if (g_count_204 >= 1) {
OrderClose(g_ticket_304, g_ord_lots_320, g_price_312, g_slippage_212, Green);
gi_280 = FALSE;
return (0);
}
}
if (gi_276 == 2 && l_icustom_16 > 0.0) {
OrderClose(g_ticket_304, g_ord_lots_320, g_price_312, g_slippage_212, Green);
gi_280 = FALSE;
return (0);
}
if (gi_276 == 1 && l_icustom_8 > 0.0) {
OrderClose(g_ticket_304, g_ord_lots_320, g_price_312, g_slippage_212, Green);
gi_280 = FALSE;
return (0);
}
if (gi_276 == 2 && (g_count_204 >= gi_148 && Bid – g_ord_open_price_284 >= gi_120 * Point)) {
OrderClose(g_ticket_304, g_ord_lots_320, g_price_312, g_slippage_212, Green);
gi_280 = FALSE;
return (0);
}
if (gi_276 == 1 && (g_count_204 >= gi_148 && g_ord_open_price_284 – Ask >= gi_120 * Point)) {
OrderClose(g_ticket_304, g_ord_lots_320, g_price_312, g_slippage_212, Green);
gi_280 = FALSE;
return (0);
}
if (gi_276 == 2 && (g_count_204 >= gi_148 && l_icustom_24 > l_icustom_32 && l_icustom_56 == l_icustom_40)) {
OrderClose(g_ticket_304, g_ord_lots_320, g_price_312, g_slippage_212, Green);
gi_280 = FALSE;
return (0);
}
if (gi_276 == 1 && (g_count_204 >= gi_148 && l_icustom_24 = gi_120 * Point || g_count_204 < 1) {
g_bid_240 = Bid;
g_ord_open_price_284 = 0;
if (g_pips_192 == 0.0) g_price_224 = 0;
else g_price_224 = g_bid_240 – g_pips_192 * Point;
if (g_pips_112 == 0.0) g_price_216 = 0;
else g_price_216 = NormalizeDouble(g_bid_240 + g_pips_112 * Point + (gi_124 – g_count_204) * gi_120 * Point, Digits);
if (g_count_204 != 0) {
g_lots_256 = gd_248;
for (g_pos_208 = 1; g_pos_208 = ld_88) g_lots_256 = ld_88;
OrderSend(Symbol(), OP_SELL, g_lots_256, g_bid_240, g_slippage_212, g_price_216, g_price_224, g_comment_180, g_magic_168, 0, Green);
return (0);
}
}
if (gi_276 == 2 && gi_280) {
if (g_ord_open_price_284 – Ask >= gi_120 * Point || g_count_204 < 1) {
g_ask_232 = Ask;
g_ord_open_price_284 = 0;
if (g_pips_192 == 0.0) g_price_224 = 0;
else g_price_224 = g_ask_232 + g_pips_192 * Point;
if (g_pips_112 == 0.0) g_price_216 = 0;
else g_price_216 = NormalizeDouble(g_ask_232 – g_pips_112 * Point – (gi_124 – g_count_204) * gi_120 * Point, Digits);
if (g_count_204 != 0) {
g_lots_256 = gd_248;
for (g_pos_208 = 1; g_pos_208 = ld_88) g_lots_256 = ld_88;
OrderSend(Symbol(), OP_BUY, g_lots_256, g_ask_232, g_slippage_212, g_price_216, g_price_224, g_comment_180, g_magic_168, 0, Green);
return (0);
}
}
return (0);
}
  ..