#property copyright "705085" #property link "http://www.fxordersystem.com/" #include extern int Slippage = 3; extern int MagicNumber = 1000; extern double lots = 0.1; extern int TakeProfit = 0; extern int StopLoss = 0; int g_bars_100 = 0; extern int Torend_Length = 6; extern int Torend_Method = 0; extern int Torend_Smoothing = 19; extern int Torend_Filter = 5; extern int MaMetod = 0; extern int MaPeriod = 16; extern bool usePrice = TRUE; bool gi_132 = TRUE; extern string Mail_Subject = "InfinitySystem"; extern bool MailSwitch = TRUE; int g_datetime_148; int g_datetime_152; int g_datetime_156; int g_datetime_160; int gi_164 = 0; int gi_168 = 0; int g_bars_172 = 0; int gi_176 = 0; int init() { SignalAlertAndMail(Mail_Subject, MagicNumber, 1, 0, MailSwitch); g_bars_172 = Bars; return (0); } int deinit() { return (0); } int start() { int li_0 = 705085; string ls_4 = "GBPJPY"; if (AccountNumber() != li_0) { Alert("アカウントが違います " + li_0 + "専用です"); return (0); } if (Symbol() != ls_4) { Alert("このEAは" + ls_4 + "専用です"); return (0); } int l_pos_20 = -1; for (int l_pos_12 = 0; l_pos_12 < OrdersTotal(); l_pos_12++) { OrderSelect(l_pos_12, SELECT_BY_POS); if (OrderMagicNumber() == MagicNumber) { if (OrderSymbol() == Symbol()) { l_pos_20 = l_pos_12; if (OrderType() == OP_BUY) gi_176 = 1; if (OrderType() == OP_SELL) gi_176 = 2; } } } if (gi_132 == FALSE) MainSystem(l_pos_20, MagicNumber); else { if (gi_132 == TRUE && g_bars_172 != Bars) { if (g_bars_100 != Bars || gi_164 == TRUE) { MainSystem(l_pos_20, MagicNumber); g_bars_100 = Bars; } } } SignalAlertAndMail(Mail_Subject, MagicNumber, 0, 0, MailSwitch); return (0); } int MainSystem(int a_pos_0, int a_magic_4) { int l_ticket_8; int l_ord_close_12; double l_price_16; double l_price_24; int l_error_32; if (a_pos_0 == -1) { if ((Signal() == 1 && gi_176 == 0 || gi_176 == 2) || (gi_164 == TRUE && gi_168 == 1)) { if (StopLoss != 0) l_price_16 = Ask - StopLoss * Point; else l_price_16 = 0; if (TakeProfit != 0) l_price_24 = Ask + TakeProfit * Point; else l_price_24 = 0; l_ticket_8 = OrderSend(Symbol(), OP_BUY, lots, Ask, Slippage, l_price_16, l_price_24, "Buy", a_magic_4, 0, Blue); if (l_ticket_8 == -1) { l_error_32 = GetLastError(); Print("注文がキャンセルされましたので、再注文しました error(", l_error_32, "): ", ErrorDescription(l_error_32)); gi_164 = TRUE; gi_168 = 1; } else { VariableReset(); gi_176 = 1; gi_164 = FALSE; } } else { if ((Signal() == 2 && gi_176 == 0 || gi_176 == 1) || (gi_164 == TRUE && gi_168 == 2)) { if (StopLoss != 0) l_price_16 = Bid + StopLoss * Point; else l_price_16 = 0; if (TakeProfit != 0) l_price_24 = Bid - TakeProfit * Point; else l_price_24 = 0; l_ticket_8 = OrderSend(Symbol(), OP_SELL, lots, Bid, Slippage, l_price_16, l_price_24, "Sell", a_magic_4, 0, Red); if (l_ticket_8 == -1) { l_error_32 = GetLastError(); Print("注文がキャンセルされましたので、再注文しました error(", l_error_32, "): ", ErrorDescription(l_error_32)); gi_164 = TRUE; gi_168 = 2; } else { VariableReset(); gi_176 = 2; gi_164 = FALSE; } } } } else { OrderSelect(a_pos_0, SELECT_BY_POS); if (OrderSymbol() == Symbol()) { if (OrderType() == OP_BUY) { if (Signal() == 2) { l_ord_close_12 = OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, Green); if (l_ord_close_12 == 0) Print("決済が失敗しました CloseTicket = ", l_ord_close_12); VariableReset(); if (StopLoss != 0) l_price_16 = Bid + StopLoss * Point; else l_price_16 = 0; if (TakeProfit != 0) l_price_24 = Bid - TakeProfit * Point; else l_price_24 = 0; l_ticket_8 = OrderSend(Symbol(), OP_SELL, lots, Bid, Slippage, l_price_16, l_price_24, "Sell", a_magic_4, 0, Red); if (l_ticket_8 == -1) { l_error_32 = GetLastError(); Print("注文がキャンセルされましたので、再注文しました error(", l_error_32, "): ", ErrorDescription(l_error_32)); gi_164 = TRUE; gi_168 = 2; } } } if (OrderType() == OP_SELL) { if (Signal() == 1) { l_ord_close_12 = OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, Green); if (l_ord_close_12 == 0) Print("決済が失敗しました CloseTicket = ", l_ord_close_12); VariableReset(); if (StopLoss != 0) l_price_16 = Ask - StopLoss * Point; else l_price_16 = 0; if (TakeProfit != 0) l_price_24 = Ask + TakeProfit * Point; else l_price_24 = 0; l_ticket_8 = OrderSend(Symbol(), OP_BUY, lots, Ask, Slippage, l_price_16, l_price_24, "Buy", a_magic_4, 0, Blue); if (l_ticket_8 == -1) { l_error_32 = GetLastError(); Print("注文がキャンセルされましたので、再注文しました error(", l_error_32, "): ", ErrorDescription(l_error_32)); gi_164 = TRUE; gi_168 = 1; } } } } } return (0); } int Signal() { if (TorendSignal() == 1) if (HeikenAshiConfirmationSignal() == 1) return (1); if (TorendSignal() == 2) if (HeikenAshiConfirmationSignal() == 2) return (2); return (0); } int VariableReset() { return (0); } int TorendSignal() { double l_icustom_0; double l_icustom_8; if (gi_132 == TRUE) { l_icustom_0 = iCustom(NULL, 0, "DealingsSignal", Torend_Length, Torend_Method, Torend_Smoothing, Torend_Filter, 3, 1); l_icustom_8 = iCustom(NULL, 0, "DealingsSignal", Torend_Length, Torend_Method, Torend_Smoothing, Torend_Filter, 4, 1); } else { if (gi_132 == FALSE) { l_icustom_0 = iCustom(NULL, 0, "DealingsSignal", Torend_Length, Torend_Method, Torend_Smoothing, Torend_Filter, 3, 0); l_icustom_8 = iCustom(NULL, 0, "DealingsSignal", Torend_Length, Torend_Method, Torend_Smoothing, Torend_Filter, 4, 0); } } if (l_icustom_0 != EMPTY_VALUE) return (1); if (l_icustom_8 != EMPTY_VALUE) return (2); return (0); } int HeikenAshiConfirmationSignal() { double l_icustom_0; double l_icustom_8; if (gi_132 == FALSE) { l_icustom_0 = iCustom(NULL, 0, "StrengthSignal", MaMetod, MaPeriod, usePrice, 2, 0); l_icustom_8 = iCustom(NULL, 0, "StrengthSignal", MaMetod, MaPeriod, usePrice, 3, 0); } else { l_icustom_0 = iCustom(NULL, 0, "StrengthSignal", MaMetod, MaPeriod, usePrice, 2, 1); l_icustom_8 = iCustom(NULL, 0, "StrengthSignal", MaMetod, MaPeriod, usePrice, 3, 1); } if (l_icustom_8 >= l_icustom_0) return (1); if (l_icustom_8 <= l_icustom_0) return (2); return (0); } int SignalAlertAndMail(string as_0, int a_magic_8, int ai_12, int ai_16, int ai_20) { int l_datetime_36; int l_datetime_40; int l_datetime_44; int l_datetime_48; int l_pos_52; int l_pos_56; int l_pos_60; int l_pos_64; double l_ord_open_price_76; double l_ord_lots_84; double l_ord_open_price_92; double l_ord_lots_100; string ls_108; double ld_116; int li_unused_28 = 0; int li_unused_32 = 0; double ld_124 = 1; if (MarketInfo(Symbol(), MODE_MINLOT) < 0.1) ld_124 = 2; if (IsTesting() == FALSE) { for (int l_ord_total_24 = OrdersTotal(); l_ord_total_24 >= 0; l_ord_total_24--) { OrderSelect(l_ord_total_24, SELECT_BY_POS); if (OrderMagicNumber() == a_magic_8 && OrderSymbol() == Symbol()) { if (OrderType() == OP_BUY) { l_datetime_36 = OrderOpenTime(); l_pos_52 = l_ord_total_24; l_ord_open_price_76 = OrderOpenPrice(); l_ord_lots_84 = OrderLots(); break; } } } for (l_ord_total_24 = OrdersTotal(); l_ord_total_24 >= 0; l_ord_total_24--) { OrderSelect(l_ord_total_24, SELECT_BY_POS); if (OrderMagicNumber() == a_magic_8 && OrderSymbol() == Symbol()) { if (OrderType() == OP_SELL) { l_datetime_44 = OrderOpenTime(); l_pos_56 = l_ord_total_24; l_ord_open_price_92 = OrderOpenPrice(); l_ord_lots_100 = OrderLots(); break; } } } for (l_ord_total_24 = OrdersHistoryTotal(); l_ord_total_24 >= 0; l_ord_total_24--) { OrderSelect(l_ord_total_24, SELECT_BY_POS, MODE_HISTORY); if (OrderMagicNumber() == a_magic_8 && OrderSymbol() == Symbol()) { if (OrderType() == OP_BUY) { l_datetime_40 = OrderCloseTime(); l_pos_60 = l_ord_total_24; break; } } } for (l_ord_total_24 = OrdersHistoryTotal(); l_ord_total_24 >= 0; l_ord_total_24--) { OrderSelect(l_ord_total_24, SELECT_BY_POS, MODE_HISTORY); if (OrderMagicNumber() == a_magic_8 && OrderSymbol() == Symbol()) { if (OrderType() == OP_SELL) { l_datetime_48 = OrderCloseTime(); l_pos_64 = l_ord_total_24; break; } } } if (ai_12 == 0) { if (g_datetime_152 < l_datetime_40) { OrderSelect(l_pos_60, SELECT_BY_POS, MODE_HISTORY); if (g_datetime_156 >= l_datetime_44) { ls_108 = "Close Buy Position"; ld_116 = (OrderClosePrice() - OrderOpenPrice()) / Point; if (ai_16 == 1) Alert(ls_108); if (ai_20 == 1) { SendMail(as_0, TimeToStr(TimeLocal()) + "\n\n" + Symbol() + "\n\n" + DoubleToStr(OrderLots(), ld_124) + "Lots\n\n" + DoubleToStr(OrderClosePrice(), Digits) + "\n\n" + "損益 " + DoubleToStr(ld_116, 0) + "pips" + "\n\n" + "買いポジションを決済しました。"); } } else { if (g_datetime_156 < l_datetime_44) { ls_108 = "Close Buy Position & Open Sell Position"; ld_116 = (OrderClosePrice() - OrderOpenPrice()) / Point; if (ai_16 == 1) Alert(ls_108); if (ai_20 == 1) { SendMail(as_0, TimeToStr(TimeLocal()) + "\n\n" + Symbol() + "\n\n" + DoubleToStr(OrderLots(), ld_124) + "Lots\n\n" + DoubleToStr(OrderClosePrice(), Digits) + "\n\n" + "損益 " + DoubleToStr(ld_116, 0) + "pips" + "\n\n" + "買いポジションを決済しました。" + "\n\n\n\n" + Symbol() + "\n\n" + DoubleToStr(l_ord_lots_100, 1) + "Lots\n\n" + DoubleToStr(l_ord_open_price_92, Digits) + "\n\n" + "売りポジションを取得しました。"); } } } } if (g_datetime_160 < l_datetime_48) { OrderSelect(l_pos_64, SELECT_BY_POS, MODE_HISTORY); if (g_datetime_148 >= l_datetime_36) { ls_108 = "Close SEll Position"; ld_116 = (OrderOpenPrice() - OrderClosePrice()) / Point; if (ai_16 == 1) Alert(ls_108); if (ai_20 == 1) { SendMail(as_0, TimeToStr(TimeLocal()) + "\n\n" + Symbol() + "\n\n" + DoubleToStr(OrderLots(), ld_124) + "Lots\n\n" + DoubleToStr(OrderClosePrice(), Digits) + "\n\n" + "損益 " + DoubleToStr(ld_116, 0) + "pips" + "\n\n" + "売りポジションを決済しました。"); } } else { if (g_datetime_148 < l_datetime_36) { ls_108 = "Close SEll Position & Open Buy Position"; ld_116 = (OrderOpenPrice() - OrderClosePrice()) / Point; if (ai_16 == 1) Alert(ls_108); if (ai_20 == 1) { SendMail(as_0, TimeToStr(TimeLocal()) + "\n\n" + Symbol() + "\n\n" + DoubleToStr(OrderLots(), ld_124) + "Lots\n\n" + DoubleToStr(OrderClosePrice(), Digits) + "\n\n" + "損益 " + DoubleToStr(ld_116, 0) + "pips" + "\n\n" + "売りポジションを決済しました。" + "\n\n\n\n" + Symbol() + "\n\n" + DoubleToStr(l_ord_lots_84, 1) + "Lots\n\n" + DoubleToStr(l_ord_open_price_76, Digits) + "\n\n" + "買いポジションを取得しました。"); } } } } if (g_datetime_148 < l_datetime_36 && g_datetime_160 >= l_datetime_48) { OrderSelect(l_pos_52, SELECT_BY_POS); ls_108 = "Open Buy Position"; if (ai_16 == 1) Alert(ls_108); if (ai_20 == 1) { SendMail(as_0, TimeToStr(TimeLocal()) + "\n\n" + Symbol() + "\n\n" + DoubleToStr(OrderLots(), ld_124) + "Lots\n\n" + DoubleToStr(OrderOpenPrice(), Digits) + "\n\n" + "買いポジションを取得しました。"); } } if (g_datetime_156 < l_datetime_44 && g_datetime_152 >= l_datetime_40) { OrderSelect(l_pos_56, SELECT_BY_POS); ls_108 = "Open Sell Position"; if (ai_16 == 1) Alert(ls_108); if (ai_20 == 1) { SendMail(as_0, TimeToStr(TimeLocal()) + "\n\n" + Symbol() + "\n\n" + DoubleToStr(OrderLots(), ld_124) + "Lots\n\n" + DoubleToStr(OrderOpenPrice(), Digits) + "\n\n" + "売りポジションを取得しました。"); } } } g_datetime_148 = l_datetime_36; g_datetime_152 = l_datetime_40; g_datetime_156 = l_datetime_44; g_datetime_160 = l_datetime_48; } return (0); }