Jump to content

break out EA any pair


Recommended Posts

this breakout EA works with any pairs could 1 of forum gurus PLEASE educate as it can only be used for testing + needs a trailing stop addedALSO includes indicators for manual traders TF 15 for more info go to FF http://www.4shared.com/file/9nQbdh7S/BREAKOUT.html

 

Hi Saendee,

 

I think this is educated now. Its Mq4 files now. have you done some backtest or tried to forward test it. Please share result.

Thanks

Link to comment
Share on other sites


/*
Generated by EX4-TO-MQ4 decompiler V4.0.224.1 []
Website: http://purebeam.biz
E-mail : [email protected]
*/
#property copyright "Copyright © 2010, sangmane"
#property link "http://www.forexfactory.com/"

extern double Lots = 0.1;
extern double InitialRiskPct = 1.0;
extern bool UseRiskBasedLots = TRUE;
extern string sDesc1 = "Time Parameters";
extern string extGMTTimeStart = "03:00";
extern string extGMTTimeEnd = "06:00";
extern string extGMTTimeTradeUntil = "19:00";
extern string extGMTTimeFridayClose = "17:00";
extern int extGMTOffset = 2;
extern string sDesc2 = "Price Level: Entry, StopLoss, TakeProfit";
extern double extEntry = 0.27;
extern double extStopLoss = 1.0;
extern double extTakeProfit = 1.27;
extern string Desc3 = "Box Size & Trade Mngmt";
extern double extMinBoxSize = 0.0;
extern double extMaxBoxSize = 50.0;
extern int extMaxTrade = 5;
extern int extMaxLosses = 3;
extern string Desc4 = "Martingale";
extern bool UseMartingale = TRUE;
extern double Multiplier = 2.5;
double gd_224;
double gd_232;
double gd_240;
double g_lotstep_248;
double g_minlot_256;
double g_tickvalue_264;
bool g_bool_272;
bool gi_276;
int g_time_280 = 0;
int gi_284 = 0;
int gi_288 = 0;
int gi_292 = 0;
datetime g_time_296;
int gi_300 = 0;
double g_price_304;
double g_price_312;
double gd_320;
double gd_328;

int init() {
/* if (!IsTesting()) {
Comment("This EA is designed to be used for Strategy Testing Purpose..");
return;
}*/
gd_224 = Point;
if (Digits == 3 || Digits == 5) gd_224 = 10.0 * Point;
gd_232 = MarketInfo(Symbol(), MODE_SPREAD) * Point;
g_tickvalue_264 = MarketInfo(Symbol(), MODE_TICKVALUE);
gd_240 = MarketInfo(Symbol(), MODE_STOPLEVEL) * Point;
g_minlot_256 = MarketInfo(Symbol(), MODE_MINLOT);
g_lotstep_248 = MarketInfo(Symbol(), MODE_LOTSTEP);
gi_276 = FALSE;
g_bool_272 = FALSE;
g_time_280 = Time[0];
g_time_296 = Time[0];
Comment("Simple London Breakout EA, Copyright © 2010, sangmane.\n", "Start Time : ", extGMTTimeStart,
"\n", "End Time : ", extGMTTimeEnd,
"\n", "Trade Until : ", extGMTTimeTradeUntil,
"\n", "Friday Close: ", extGMTTimeFridayClose);
return (0);
}

int start() {
int l_ord_total_0;
int l_shift_4;
int l_shift_8;
double ld_12;
double ld_20;
int li_28;
string l_name_32;
/* if (!IsTesting()) {
Comment("This EA is designed to be used for Strategy Testing Purpose..");
return;
}*/
if (g_time_280 != Time[0]) {
g_time_280 = Time[0];
CloseExpiredOrder();
li_28 = StrToTime(extGMTTimeEnd) + 3600 * extGMTOffset;
if (li_28 < g_time_296) return;
if (Time[0] == li_28) {
gi_288 = li_28;
gi_284 = StrToTime(extGMTTimeStart) + 3600 * extGMTOffset;
if (gi_284 > gi_288) gi_284 -= 86400;
gi_292 = StrToTime(extGMTTimeTradeUntil) + 3600 * extGMTOffset;
gi_300 = StrToTime(extGMTTimeFridayClose) + 3600 * extGMTOffset;
if (gi_292 < gi_288) gi_292 += 86400;
if (gi_300 < gi_288) gi_300 += 86400;
l_shift_4 = iBarShift(NULL, 0, gi_284, TRUE);
l_shift_8 = iBarShift(NULL, 0, gi_288, TRUE);
if (l_shift_4 < 0 || l_shift_8 < 0) {
g_bool_272 = FALSE;
return;
}
g_price_304 = High[iHighest(NULL, 0, MODE_HIGH, l_shift_4 - l_shift_8 + 1, l_shift_8)];
g_price_312 = Low[iLowest(NULL, 0, MODE_LOW, l_shift_4 - l_shift_8 + 1, l_shift_8)];
gd_320 = g_price_304 + extEntry * (g_price_304 - g_price_312);
gd_328 = g_price_312 - extEntry * (g_price_304 - g_price_312);
g_bool_272 = g_price_304 - g_price_312 >= extMinBoxSize * gd_224 && g_price_304 - g_price_312 <= extMaxBoxSize * gd_224;
l_name_32 = "BOX" + gi_284;
if (ObjectFind(l_name_32) < 0) {
ObjectCreate(l_name_32, OBJ_RECTANGLE, 0, gi_284, g_price_304, gi_288, g_price_312);
ObjectSet(l_name_32, OBJPROP_COLOR, DodgerBlue);
if (!g_bool_272) ObjectSet(l_name_32, OBJPROP_COLOR, Gray);
}
gi_276 = TRUE;
}
CreateLevelLine("EDGETOP" + gi_284, gi_288, Time[0], g_price_304);
CreateLevelLine("EDGEBOTTOM" + gi_284, gi_288, Time[0], g_price_312);
CreateLevelLine("ENTRYBUY" + gi_284, gi_288, Time[0], gd_320);
CreateLevelLine("ENTRYSELL" + gi_284, gi_288, Time[0], gd_328);
}
if (g_bool_272) {
if (TimeCurrent() <= gi_292) {
l_ord_total_0 = OrdersTotal();
if (Bid <= g_price_304 && Bid >= g_price_312) gi_276 = TRUE;
else {
if (gi_276) {
if (Bid > gd_320 || Bid < gd_328) {
gi_276 = FALSE;
if (l_ord_total_0 == 0) {
if (TradeCount() < extMaxTrade && LossesCount() < extMaxLosses) {
if (Bid > gd_320) {
ld_12 = NormalizeDouble(g_price_304 - extStopLoss * (g_price_304 - g_price_312), Digits);
ld_20 = NormalizeDouble(g_price_304 + extTakeProfit * (g_price_304 - g_price_312), Digits);
SendOrder(0, GetLot(Ask - ld_12), Ask, ld_12, ld_20);
} else {
ld_12 = NormalizeDouble(g_price_312 + extStopLoss * (g_price_304 - g_price_312) + gd_232, Digits);
ld_20 = NormalizeDouble(g_price_312 - extTakeProfit * (g_price_304 - g_price_312) + gd_232, Digits);
SendOrder(1, GetLot(ld_12 - Bid), Bid, ld_12, ld_20);
}
}
}
}
}
}
}
}
return (0);
}

int SendOrder(int ai_0, double a_lots_4, double a_price_12, double a_price_20, double a_price_28) {
color l_color_36;
if (MathMod(ai_0, 2) == 0.0) l_color_36 = Blue;
else l_color_36 = Red;
int l_ticket_40 = OrderSend(Symbol(), ai_0, a_lots_4, a_price_12, 3, a_price_20, a_price_28, 0, 0, 0, l_color_36);
if (l_ticket_40 < 0) Comment(TimeToStr(Time[0], TIME_DATE|TIME_MINUTES) + ": OrderSend Error ", GetLastError());
return (l_ticket_40);
}

double GetLot(double ad_0) {
double ld_8;
if (UseRiskBasedLots) ld_8 = InitialRiskPct / 100.0 * AccountBalance() / 10.0 * gd_224 / (ad_0 * g_tickvalue_264);
else ld_8 = Lots;
if (UseMartingale) ld_8 = MathPow(Multiplier, AllLossesCount()) * ld_8;
ld_8 = MathFloor(ld_8 / g_lotstep_248) * g_lotstep_248;
ld_8 = MathMax(g_minlot_256, ld_8);
return (ld_8);
}

int TradeCount() {
int l_count_0 = 0;
for (int l_pos_4 = OrdersHistoryTotal() - 1; l_pos_4 >= 0; l_pos_4--) {
OrderSelect(l_pos_4, SELECT_BY_POS, MODE_HISTORY);
if (OrderOpenTime() < gi_288) break;
l_count_0++;
}
return (l_count_0);
}

int LossesCount() {
int l_count_0 = 0;
for (int l_pos_4 = OrdersHistoryTotal() - 1; l_pos_4 >= 0; l_pos_4--) {
OrderSelect(l_pos_4, SELECT_BY_POS, MODE_HISTORY);
if (OrderOpenTime() < gi_288) break;
if (OrderProfit() > 0.0) break;
l_count_0++;
}
return (l_count_0);
}

int AllLossesCount() {
int l_count_0 = 0;
for (int l_pos_4 = OrdersHistoryTotal() - 1; l_pos_4 >= 0; l_pos_4--) {
OrderSelect(l_pos_4, SELECT_BY_POS, MODE_HISTORY);
if (OrderProfit() > 0.0) break;
l_count_0++;
}
return (l_count_0);
}

void CreateLevelLine(string a_name_0, int a_datetime_8, int a_datetime_12, double a_price_16) {
if (!g_bool_272 || a_datetime_12 - gi_284 >= 86400) return;
if (ObjectFind(a_name_0) < 0) {
ObjectCreate(a_name_0, OBJ_TREND, 0, a_datetime_8, a_price_16, a_datetime_12, a_price_16);
ObjectSet(a_name_0, OBJPROP_COLOR, Yellow);
ObjectSet(a_name_0, OBJPROP_RAY, FALSE);
return;
}
ObjectMove(a_name_0, 1, a_datetime_12, a_price_16);
}

void CloseExpiredOrder() {
int li_4;
for (int l_count_0 = 0; l_count_0 < OrdersTotal(); l_count_0++) {
OrderSelect(0, SELECT_BY_POS);
if (OrderType() <= OP_SELL) {
if (TimeDayOfWeek(Time[0]) == 5) li_4 = gi_300;
else li_4 = gi_284 + 86400;
if (TimeCurrent() >= li_4) OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 3, CLR_NONE);
}
}
}
[/Code]

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...