comot dari forum mt 5
ini coding mq4 hasil decompiler FXParaziteScalper&#.ex4
================
/*
Generated by EX4-TO-MQ4 decompiler V4.0.224.1 []
Website: http://purebeam.biz
E-mail : purebeam@gmail.com
*/
#property copyright "Copyright © 2008, FOREXflash Software Corp."
#property link "http://www.metaquotes.net"
extern int Risk_percent = 5;
extern double minLots = 0.1;
extern double maxLots = 8.0;
extern double StopLoss = 300.0;
extern double TakeProfit = 600.0;
extern bool use_hidden_stop_loss = TRUE;
extern int hidden_sl = 140;
extern bool use_hidden_take_profit = TRUE;
extern int hidden_tp = 200;
extern bool UseTrailingStop = TRUE;
extern int TrailingStop = 30;
extern int UseFastTrail = 1;
extern int Slippage = 2;
extern int OrderRetries = 1;
extern int SleepBetweenTrades = 1000;
extern int MagicNumber = 1803;
extern int iStartTradingHour = 8;
extern int iEndTradingHour = 21;
extern int min_gapsize = 1;
string gs_arial_168 = "Arial";
int g_fontsize_176 = 14;
int g_color_180 = White;
int g_corner_184 = 0;
int g_x_188 = 380;
int g_y_192 = 0;
int g_str_len_196;
string gs_200 = ":...:...:...:...:";
int gi_208 = 0;
int gi_212 = 16711680;
int gi_216 = 255;
int g_color_220 = Green;
int g_color_224 = Yellow;
double gd_228 = 0.1;
int gi_unused_236 = 0;
int gi_240;
int gi_244;
string gs_248;
string gs_256 = "FXParazite by FOREXflash";
int gi_unused_264 = -1;
int g_count_268 = 0;
int g_count_272 = 0;
int gi_276 = 0;
int gi_280 = 0;
int gi_unused_284 = 0;
double gd_unused_288 = 0.0;
double gd_unused_296 = -50.0;
bool gi_304 = TRUE;
bool gi_308 = TRUE;
void hidden_take_profit() {
bool l_ord_close_8;
int l_ord_total_0 = OrdersTotal();
for (int l_pos_4 = l_ord_total_0 - 1; l_pos_4 >= 0; l_pos_4--) {
OrderSelect(l_pos_4, SELECT_BY_POS);
l_ord_close_8 = FALSE;
if (OrderSymbol() == Symbol()) {
if (OrderType() == OP_BUY && OrderOpenPrice() + hidden_tp * Point <= Bid) l_ord_close_8 = OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, Red);
if (OrderType() == OP_SELL && OrderOpenPrice() - hidden_tp * Point >= Ask) l_ord_close_8 = OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 5, Red);
}
}
}
void hidden_stop_loss() {
bool l_ord_close_8;
int l_ord_total_0 = OrdersTotal();
for (int l_pos_4 = l_ord_total_0 - 1; l_pos_4 >= 0; l_pos_4--) {
OrderSelect(l_pos_4, SELECT_BY_POS);
l_ord_close_8 = FALSE;
if (OrderSymbol() == Symbol()) {
if (OrderType() == OP_BUY && OrderOpenPrice() - hidden_sl * Point >= Bid) l_ord_close_8 = OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, Red);
if (OrderType() == OP_SELL && OrderOpenPrice() + hidden_sl * Point <= Ask) l_ord_close_8 = OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 5, Red);
}
}
}
int init() {
g_str_len_196 = StringLen(gs_200);
datetime lt_0 = D'13.01.2029 07:00';
if (TimeCurrent() > lt_0) {
Print("Testing period is over contact forexflash@gmail.com.");
return (0);
}
return (0);
}
int deinit() {
if (ObjectFind("BarTimer") != -1) ObjectDelete("BarTimer");
return (0);
}
int start() {
bool li_52;
bool li_56;
bool li_60;
bool li_64;
bool li_72;
bool li_76;
double ld_92;
double ld_100;
string ls_unused_108;
string ls_unused_116;
string ls_unused_124;
string ls_unused_132;
string ls_unused_140;
string ls_148;
double l_high_156;
double l_low_164;
if (use_hidden_stop_loss) hidden_stop_loss();
if (use_hidden_take_profit) hidden_take_profit();
int li_0 = 0;
int l_index_4 = 0;
int li_8 = 0;
double ld_12 = 0.0;
string l_str_concat_20 = "";
string ls_28 = "";
string ls_36 = "";
if (ObjectFind("BarTimer") == -1) {
ObjectCreate("BarTimer", OBJ_LABEL, 0, 0, 0);
ObjectSet("BarTimer", OBJPROP_XDISTANCE, g_x_188);
ObjectSet("BarTimer", OBJPROP_YDISTANCE, g_y_192);
ObjectSet("BarTimer", OBJPROP_CORNER, g_corner_184);
}
li_8 = TimeCurrent() - Time[0];
li_0 = (g_str_len_196 - 1) * li_8 / (60 * Period());
ld_12 = 100.0 * li_8 / (60 * Period());
if (li_0 > g_str_len_196 - 1) li_0 = g_str_len_196 - 1;
if (li_0 > 0) ls_36 = StringSubstr(gs_200, 0, li_0);
if (li_0 < g_str_len_196 - 1) ls_28 = StringSubstr(gs_200, li_0 + 1, g_str_len_196 - li_0 - 1);
l_str_concat_20 = StringConcatenate(ls_36, "|", ls_28, " ", DoubleToStr(ld_12, 0), "%");
ObjectSetText("BarTimer", l_str_concat_20, g_fontsize_176, gs_arial_168, g_color_180);
bool li_68 = FALSE;
bool li_80 = FALSE;
int li_unused_84 = 0;
int li_unused_88 = 0;
gs_248 = Symbol();
if (UseTrailingStop && OpenTradesForMN(MagicNumber) > 0) MoveTrailingStopsPerMN(MagicNumber, TrailingStop, UseFastTrail);
gi_280 = Time[0];
if (gi_280 == gi_276) {
if (g_count_272 + g_count_268 == 2) return (0);
} else {
gi_276 = gi_280;
g_count_272 = 0;
g_count_268 = 0;
}
if (High[1] <= High[2] && Low[1] >= Low[2] && Close[1] <= Open[1]) li_52 = TRUE;
else li_52 = FALSE;
if (High[1] <= High[2] && Low[1] >= Low[2] && Close[1] > Open[1]) li_56 = TRUE;
else li_56 = FALSE;
if (li_56 == TRUE && Close[2] > Open[2]) li_60 = TRUE;
else li_60 = FALSE;
if (li_52 == TRUE && Close[2] < Open[2]) li_64 = TRUE;
else li_64 = FALSE;
if (Open[1] < Close[1]) ld_92 = Close[1] - (Close[1] - Open[1]) / 3.0;
else ld_92 = Close[1] - (Close[1] - Low[1]) / 3.0;
if (Open[1] > Close[1]) ld_100 = Close[1] + (Open[1] - Close[1]) / 3.0;
else ld_100 = Close[1] + (High[1] - Close[1]) / 3.0;
if (Low[0] <= ld_92 || Hour() >= gi_208 && li_64 == FALSE && li_56 == FALSE) li_72 = TRUE;
else li_72 = FALSE;
if (High[0] >= ld_100 || Hour() >= gi_208 && li_60 == FALSE && li_52 == FALSE) li_76 = TRUE;
else li_76 = FALSE;
if (High[0] > High[1]) li_68 = TRUE;
else li_68 = FALSE;
if (li_68 == TRUE) {
li_0++;
l_high_156 = High[li_0];
while (l_high_156 < High[li_0 + 1]) {
l_high_156 = High[li_0 + 1];
li_0++;
}
}
if (Low[0] < Low[1]) li_80 = TRUE;
else li_80 = FALSE;
if (li_80 == TRUE) {
l_index_4++;
l_low_164 = Low[l_index_4];
while (l_low_164 > Low[l_index_4 + 1]) {
l_low_164 = Low[l_index_4 + 1];
l_index_4++;
}
}
if (li_68 == TRUE) {
Call_MM();
if (gi_304 == FALSE && iVolume(Symbol(), 0, 0) <= 1.0) gi_304 = TRUE;
if (Hour() <= iStartTradingHour || Hour() >= iEndTradingHour) return;
if (li_72 == TRUE) {
if (Low[0] > Low[1] && Low[1] < High[2]) {
if (OpenTradesForMN(MagicNumber) == 0 && g_count_268 == 0) {
gi_240 = OpenAtMarket(gs_248, OP_BUY, gd_228, StopLoss, TakeProfit, gs_256, MagicNumber, 0, gi_212, OrderRetries, SleepBetweenTrades);
gi_304 = FALSE;
if (StringLen(DoubleToStr(gi_240, 0)) == 1) ls_148 = "0" + gi_240;
else ls_148 = gi_240;
gi_unused_264 = 1;
g_count_268++;
}
}
}
}
if (li_80 == TRUE) {
Call_MM();
if (gi_308 == FALSE && iVolume(Symbol(), 0, 0) <= 1.0) gi_308 = TRUE;
if (Hour() <= iStartTradingHour || Hour() >= iEndTradingHour) return;
if (li_76 == TRUE) {
if (High[0] < High[1]) {
if (OpenTradesForMN(MagicNumber) == 0 && g_count_272 == 0) {
gi_244 = OpenAtMarket(gs_248, OP_SELL, gd_228, StopLoss, TakeProfit, gs_256, MagicNumber, 0, gi_216, OrderRetries, SleepBetweenTrades);
gi_308 = FALSE;
gi_unused_264 = 0;
g_count_272++;
}
}
}
}
return (0);
}
void MoveTrailingStopsPerMN(int a_magic_0, int ai_4, int ai_8) {
double l_price_20;
int l_ord_total_16 = OrdersTotal();
for (int l_pos_12 = 0; l_pos_12 < l_ord_total_16; l_pos_12++) {
OrderSelect(l_pos_12, SELECT_BY_POS, MODE_TRADES);
if (OrderType() == OP_SELL && OrderSymbol() == gs_248 && OrderMagicNumber() == a_magic_0) {
if (OrderStopLoss() == 0.0) {
l_price_20 = NormalizeDouble(Ask + Point * ai_4, Digits);
OrderModify(OrderTicket(), OrderOpenPrice(), l_price_20, OrderTakeProfit(), 0, g_color_224);
}
if (ai_8 > 0) {
if (OrderOpenPrice() > Ask && OrderStopLoss() > OrderOpenPrice()) {
if (OrderStopLoss() - Ask > Point * ai_4 + Point) {
l_price_20 = NormalizeDouble(Ask + Point * ai_4, Digits);
if (l_price_20 != 0.0) OrderModify(OrderTicket(), OrderOpenPrice(), l_price_20, OrderTakeProfit(), 0, g_color_224);
}
}
}
if (OrderOpenPrice() - Ask > Point * ai_4) {
if (OrderStopLoss() > Ask + Point * ai_4 + Point) {
l_price_20 = NormalizeDouble(Ask + Point * ai_4, Digits);
OrderModify(OrderTicket(), OrderOpenPrice(), l_price_20, OrderTakeProfit(), 0, g_color_224);
}
}
}
if (OrderType() == OP_BUY && OrderSymbol() == gs_248 && OrderMagicNumber() == a_magic_0) {
if (OrderStopLoss() == 0.0) {
l_price_20 = NormalizeDouble(Bid - Point * ai_4, Digits);
OrderModify(OrderTicket(), OrderOpenPrice(), l_price_20, OrderTakeProfit(), 0, g_color_220);
}
if (ai_8 > 0) {
if (OrderOpenPrice() < Bid && OrderStopLoss() < OrderOpenPrice()) {
if (Bid - OrderStopLoss() > Point * ai_4 + Point) {
l_price_20 = NormalizeDouble(Bid - Point * ai_4, Digits);
if (l_price_20 != 0.0) OrderModify(OrderTicket(), OrderOpenPrice(), l_price_20, OrderTakeProfit(), 0, g_color_220);
}
}
}
if (Bid - OrderOpenPrice() > Point * ai_4) {
if (OrderStopLoss() < Bid - Point * ai_4 - Point) {
l_price_20 = NormalizeDouble(Bid - Point * ai_4, Digits);
OrderModify(OrderTicket(), OrderOpenPrice(), l_price_20, OrderTakeProfit(), 0, g_color_220);
}
}
}
}
}
int OpenTradesForMN(int a_magic_0) {
int l_count_12 = 0;
int l_ord_total_8 = OrdersTotal();
for (int l_pos_4 = 0; l_pos_4 < l_ord_total_8; l_pos_4++) {
OrderSelect(l_pos_4, SELECT_BY_POS, MODE_TRADES);
if (OrderType() <= OP_SELL)
if (OrderMagicNumber() == a_magic_0) l_count_12++;
}
return (l_count_12);
}
int OpenAtMarket(string a_symbol_0, int a_cmd_8, double a_lots_12, int ai_20, int ai_24, string a_comment_28, int a_magic_36, int a_datetime_40, color a_color_44, int ai_48, int ai_52) {
double l_price_64;
double l_price_72;
double l_price_80;
int l_ticket_88;
int l_error_92;
int li_60 = ai_48;
li_60 = ai_48;
if (a_cmd_8 > OP_SELL) {
Print("OpenAtMarket Error: OrderType is a Pending Order!");
return (0);
}
while (li_60 > 0) {
RefreshRates();
if (a_cmd_8 == OP_BUY) {
l_price_64 = NormalizeDouble(Ask, Digits);
l_price_72 = NormalizeDouble(l_price_64 - ai_20 * Point, Digits);
l_price_80 = NormalizeDouble(l_price_64 + ai_24 * Point, Digits);
}
if (a_cmd_8 == OP_SELL) {
l_price_64 = NormalizeDouble(Bid, Digits);
l_price_72 = NormalizeDouble(l_price_64 + ai_20 * Point, Digits);
l_price_80 = NormalizeDouble(l_price_64 - ai_24 * Point, Digits);
}
l_ticket_88 = OrderSend(a_symbol_0, a_cmd_8, a_lots_12, l_price_64, Slippage, l_price_72, l_price_80, a_comment_28, a_magic_36, a_datetime_40, a_color_44);
li_60--;
if (l_ticket_88 == -1) {
l_error_92 = GetLastError();
if (l_error_92 == 4/* SERVER_BUSY */ || l_error_92 == 146/* TRADE_CONTEXT_BUSY */ || l_error_92 == 137/* BROKER_BUSY */ || l_error_92 == 6/* NO_CONNECTION */ || l_error_92 == 128/* TRADE_TIMEOUT */ ||
l_error_92 == 129/* INVALID_PRICE */ || l_error_92 == 136/* OFF_QUOTES */ || l_error_92 == 135/* PRICE_CHANGED */ || l_error_92 == 138/* REQUOTE */) Sleep(ai_52);
else {
li_60 = 0;
Print("OpenAtMarket: OrderSend Error ", l_error_92);
}
} else li_60 = 0;
}
return (l_ticket_88);
}
void Call_MM() {
gd_228 = AccountFreeMargin() / 100000.0 * Risk_percent;
gd_228 = MathMin(maxLots, MathMax(minLots, gd_228));
if (minLots < 0.1) {
gd_228 = NormalizeDouble(gd_228, 2);
return;
}
if (minLots < 1.0) {
gd_228 = NormalizeDouble(gd_228, 1);
return;
}
gd_228 = NormalizeDouble(gd_228, 0);
}
Tidak ada komentar:
Posting Komentar