//+------------------------------------------------------------------+ //| intraday_beta.mq4 | //| Generated by EX4 Decompile Service | //| http://ex4mq4.com | //+------------------------------------------------------------------+ #property copyright "Copyright © 2007, Dariuske" #property link "" extern int SMAPeriod = 50; extern double Angle = 0.22; extern int CountBars = 500; extern int TakeProfit = 14; extern int StopLoss = 15; extern int MaxTradesDay = 3; extern double lotsize = 0.1; extern int MagicNumber = 1; extern bool UseAlert = TRUE; double gda_unused_120[]; double gda_unused_124[]; double gda_136[]; double gda_140[]; string gs_148 = ""; int g_datetime_156; int g_time_160 = 0; int init() { string ls_unused_0; return (0); } void DoAlert(string as_0) { if (!NewBar() || !UseAlert) return; Alert(Symbol(), " ", Period(), " Phil Nel EA ", as_0); } int NewBar() { if (g_time_160 != Time[0]) { g_time_160 = Time[0]; return (1); } return (0); } int start() { string l_symbol_12; int li_20; double l_point_24; int l_ticket_44; int l_ord_total_48; int l_count_56; double l_ima_60; double l_ima_68; double l_ima_76; double l_icustom_84; double lda_92[]; double l_ima_96; double l_ima_104; double ld_112; double ld_120; int li_128; double l_bid_132; double l_ask_140; int li_8 = IndicatorCounted(); if (li_8 > 0) li_8--; int li_32 = Bars - li_8; for (int li_4 = CountBars; li_4 >= 0; li_4--) { l_ima_60 = iMA(NULL, 0, 10, 0, MODE_EMA, PRICE_CLOSE, li_4); l_ima_68 = iMA(NULL, 0, 21, 0, MODE_EMA, PRICE_CLOSE, li_4); l_ima_76 = iMA(NULL, 0, 50, 0, MODE_SMA, PRICE_CLOSE, li_4); l_icustom_84 = iCustom(NULL, 0, "SMAAngle", SMAPeriod, 0.15, 2, 0, 0, li_4); l_ima_96 = iMA(NULL, 0, 10, 0, MODE_EMA, PRICE_CLOSE, li_4); l_ima_104 = iMA(NULL, 0, 10, 0, MODE_EMA, PRICE_CLOSE, li_4 + 1); gda_136[li_4] = 0; gda_140[li_4] = 0; l_symbol_12 = Symbol(); li_128 = CanTrade(l_symbol_12, MagicNumber, MaxTradesDay); if (l_icustom_84 <= (-Angle) && l_ima_60 < l_ima_68 && l_ima_68 < l_ima_76 && (Close[li_4] > l_ima_60 && Close[li_4] < l_ima_68) || (Open[li_4] > l_ima_60 && Open[li_4] < l_ima_68)) { if (li_4 < 2 && l_ima_96 > l_ima_104) { l_count_56 = 0; l_ord_total_48 = OrdersTotal(); for (int l_pos_52 = 0; l_pos_52 < l_ord_total_48; l_pos_52++) { OrderSelect(l_pos_52, SELECT_BY_POS, MODE_TRADES); if (OrderMagicNumber() == MagicNumber) l_count_56++; } if (l_count_56 < 1 && li_128) { li_20 = MarketInfo(l_symbol_12, MODE_DIGITS); if (li_20 == 0) li_20 = 4; l_point_24 = MarketInfo(l_symbol_12, MODE_POINT); if (NormalizeDouble(l_point_24, li_20) == 0.0) l_point_24 = Point; l_bid_132 = MarketInfo(l_symbol_12, MODE_BID); l_ticket_44 = OrderSend(Symbol(), OP_SELL, lotsize, l_bid_132, 0, _sl(1, Symbol(), StopLoss), _tp(1, Symbol(), TakeProfit), "Sell Order", MagicNumber, 0, Red); Print("I sell", Bid, ld_112, ld_120); gs_148 = "DOWN. "; DoAlert(gs_148); g_datetime_156 = iTime(Symbol(), PERIOD_M5, 0); if (l_ticket_44 < 0) Print("OrderSend failed with error #", GetLastError()); } } } if (l_icustom_84 >= Angle && l_ima_60 > l_ima_68 && l_ima_68 > l_ima_76 && (Close[li_4] < l_ima_60 && Close[li_4] > l_ima_68) || (Open[li_4] < l_ima_60 && Open[li_4] > l_ima_68)) { if (li_4 < 2 && l_ima_96 < l_ima_104) { l_count_56 = 0; l_ord_total_48 = OrdersTotal(); for (l_pos_52 = 0; l_pos_52 < l_ord_total_48; l_pos_52++) { OrderSelect(l_pos_52, SELECT_BY_POS, MODE_TRADES); if (OrderMagicNumber() == MagicNumber) l_count_56++; } if (l_count_56 < 1 && li_128) { li_20 = MarketInfo(l_symbol_12, MODE_DIGITS); if (li_20 == 0) li_20 = 4; l_point_24 = MarketInfo(l_symbol_12, MODE_POINT); if (NormalizeDouble(l_point_24, li_20) == 0.0) l_point_24 = Point; l_ask_140 = MarketInfo(l_symbol_12, MODE_ASK); l_ticket_44 = OrderSend(Symbol(), OP_BUY, lotsize, l_ask_140, 0, _sl(0, Symbol(), StopLoss), _tp(0, Symbol(), TakeProfit), "Buy Order", MagicNumber, 0, Blue); Print("I buy", Ask, ld_112, ld_120); g_datetime_156 = iTime(Symbol(), PERIOD_M5, 0); gs_148 = " UP. "; DoAlert(gs_148); if (l_ticket_44 < 0) Print("OrderSend failed with error #", GetLastError()); } } } } return (0); } double _sl(int ai_0, string a_symbol_4, int ai_12) { if (ai_0 == 0) { if (ai_12 > 0) return (MarketInfo(a_symbol_4, MODE_BID) - ai_12 * MarketInfo(a_symbol_4, MODE_POINT)); return (0.0); } if (ai_0 == 1) { if (ai_12 > 0) return (MarketInfo(a_symbol_4, MODE_ASK) + ai_12 * MarketInfo(a_symbol_4, MODE_POINT)); return (0.0); } return (0.0); } double _tp(int ai_0, string a_symbol_4, int ai_12) { if (ai_0 == 0) { if (ai_12 > 0) return (MarketInfo(a_symbol_4, MODE_BID) + ai_12 * MarketInfo(a_symbol_4, MODE_POINT)); return (0.0); } if (ai_0 == 1) { if (ai_12 > 0) return (MarketInfo(a_symbol_4, MODE_ASK) - ai_12 * MarketInfo(a_symbol_4, MODE_POINT)); return (0.0); } return (0.0); } int CanTrade(string a_symbol_0, int a_magic_8, int ai_unused_12) { int l_count_16 = 0; int l_datetime_20 = iTime(a_symbol_0, PERIOD_D1, 0); for (int l_pos_24 = OrdersHistoryTotal() - 1; l_pos_24 >= 0; l_pos_24--) { if (OrderSelect(l_pos_24, SELECT_BY_POS, MODE_HISTORY)) { if (OrderSymbol() == a_symbol_0) { if (OrderMagicNumber() == a_magic_8) { if (OrderOpenTime() >= l_datetime_20) { l_count_16++; if (MaxTradesDay > 0) if (l_count_16 >= MaxTradesDay) return (0); } } } } else Print("OrderSelect() error - ", GetLastError()); } return (1); }