哪位大侠看看这个EA修改哪里可以实现反向开仓
这个EA在USEMACD为true时是稳定亏损,本人对代码不感冒,不知道可不可以实现反向开仓呢?望大侠们能指点一二 extern double Lots = 0.1; extern int TakeProfit = 30; extern int StopLoss = 0; extern bool ConstantStop = FALSE; extern int Step1 = 30; extern int TP1 = 30; extern int Step2 = 30; extern int TP2 = 30; extern int Step3 = 30; extern int TP3 = 30; extern int Step4 = 30; extern int TP4 = 30; extern int Step5 = 30; extern int TP5 = 30; extern int Step6 = 30; extern int TP6 = 30; extern int Step7 = 30; extern int TP7 = 30; extern int Step8 = 30; extern int TP8 = 30; extern int Step9 = 30; extern int TP9 = 30; extern int Step10 = 30; extern int TP10 = 30; extern int Slippage = 3; int gi_180 = 2; extern int StartHour = 0; extern int EndHour = 24; extern int Magic = 111; extern bool CloseAllNow = FALSE; extern bool UseMACD = FALSE; extern int BrokerMode = 1; extern bool MM_advisor = FALSE; extern int FridayCloseTime = 10; int gi_216 = D'01.01.2008 08:00'; int gi_220 = D'04.12.2019 08:00'; int init() { // if (!IsDemo()) { // Comment("Invalid Account. Please contact EA Provider"); // return (-1); // } return (1); } int start() { int li_28; int li_32; int l_ticket_36; double l_price_72; double l_price_80; double l_price_88; double l_lots_96; double l_pips_160; double l_pips_168; double l_price_208; double l_price_216; double l_price_224; bool l_bool_320; // if (!IsDemo()) return (-1); if (CloseAllNow == TRUE) { 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() || BrokerMode == 3 && OrderMagicNumber() == Magic) { if (OrderType() == OP_BUY || OrderType() == OP_SELL) OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 5, CLR_NONE); if (OrderType() != OP_BUY && OrderType() != OP_SELL) OrderDelete(OrderTicket()); } } return (0); } int l_ticket_4 = 0; int l_ticket_8 = 0; int l_ticket_12 = 0; int l_ticket_16 = 0; int l_ticket_20 = 0; int l_ticket_24 = 0; double ld_40 = 0; double ld_48 = 0; double l_ord_open_price_56 = 0; double l_ord_open_price_64 = 0; double l_ord_takeprofit_104 = 0; double l_ord_takeprofit_112 = 0; double l_ord_lots_120 = 0; double l_ord_lots_128 = 0; double l_ord_lots_136 = 0; double l_ord_lots_144 = 0; double ld_176 = 0; double ld_184 = 0; double l_ord_lots_192 = 0; double l_ord_lots_200 = 0; string ls_232 = ""; string ls_240 = ""; string ls_248 = ""; string ls_256 = ""; string ls_264 = ""; string ls_272 = ""; string ls_280 = ""; string ls_288 = ""; string ls_296 = ""; string ls_304 = ""; string ls_312 = ""; if (MM_advisor == TRUE) li_32 = 100; else li_32 = 1; if (iMACD(NULL, 0, 14, 26, 9, PRICE_CLOSE, MODE_MAIN, 0) > iMACD(NULL, 0, 14, 26, 9, PRICE_CLOSE, MODE_MAIN, 1)) li_28 = 2; if (iMACD(NULL, 0, 14, 26, 9, PRICE_CLOSE, MODE_MAIN, 0) < iMACD(NULL, 0, 14, 26, 9, PRICE_CLOSE, MODE_MAIN, 1)) li_28 = 1; for (int l_pos_324 = 0; l_pos_324 < OrdersTotal(); l_pos_324++) { OrderSelect(l_pos_324, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() == Symbol() || BrokerMode == 3 && OrderMagicNumber() == Magic) { if (OrderType() == OP_BUY && OrderLots() > ld_40) { ld_40 = OrderLots(); l_ord_open_price_56 = OrderOpenPrice(); l_ticket_4 = OrderTicket(); l_ord_takeprofit_112 = OrderTakeProfit(); } if (OrderType() == OP_BUY) { if (OrderLots() < l_ord_lots_192 || l_ord_lots_192 == 0.0) { l_ord_lots_192 = OrderLots(); ld_176 = OrderOpenPrice() - StopLoss * Point; } } if (OrderType() == OP_SELL && OrderLots() > ld_48) { ld_48 = OrderLots(); l_ord_open_price_64 = OrderOpenPrice(); l_ticket_8 = OrderTicket(); l_ord_takeprofit_104 = OrderTakeProfit(); } if (OrderType() == OP_SELL) { if (OrderLots() < l_ord_lots_200 || l_ord_lots_200 == 0.0) { l_ord_lots_200 = OrderLots(); ld_184 = OrderOpenPrice() + StopLoss * Point; } } if (OrderType() == OP_BUYLIMIT) { l_ticket_12 = OrderTicket(); l_ord_lots_136 = OrderLots(); } if (OrderType() == OP_SELLLIMIT) { l_ticket_16 = OrderTicket(); l_ord_lots_144 = OrderLots(); } if (OrderType() == OP_BUYSTOP) { l_ticket_20 = OrderTicket(); l_ord_lots_120 = OrderLots(); } if (OrderType() == OP_SELLSTOP) { l_ticket_24 = OrderTicket(); l_ord_lots_128 = OrderLots(); } } } if (l_ticket_4 == 0 && l_ticket_12 != 0) OrderDelete(l_ticket_12); if (l_ticket_4 == 0 && l_ticket_12 == 0) { if (TimeCurrent() >= gi_216 && TimeCurrent() EndHour && TimeHour(TimeCurrent()) >= StartHour || TimeHour(TimeCurrent()) < EndHour)) { if (DayOfWeek() != 5 || Hour() < FridayCloseTime) { if ((li_28 == 2 && l_ticket_8 == 0) || UseMACD == FALSE) { if (AccountFreeMarginCheck(Symbol(), OP_SELL, Lots * li_32) >= 0.0) { if (BrokerMode != 2 && BrokerMode != 3) OrderSend(Symbol(), OP_SELL, Lots, Ask, Slippage, l_price_80, l_price_88, "Magic = " + Magic, Magic, 0, CLR_NONE); else { l_ticket_36 = OrderSend(Symbol(), OP_SELL, Lots, Ask, Slippage, 0, 0, "Magic = " + Magic, Magic, 0, CLR_NONE); if (l_ticket_36 > 0) { l_bool_320 = OrderModify(l_ticket_36, OrderOpenPrice(), l_price_80, l_price_88, 0, CLR_NONE); if (l_bool_320 == FALSE) Print("Error modifying BUY order : ", GetLastError()); } } } else { if (AccountFreeMarginCheck(Symbol(), OP_BUY, Lots) >= 0.0) ls_296 = "we recommend you to decrease your start lot or increase deposit"; else ls_248 = "BUY, " + DoubleToStr(Lots, 2) + " lots. "; } } } } } else ls_240 = gs_224; } if (l_ticket_8 == 0 && l_ticket_16 != 0) OrderDelete(l_ticket_16); if (l_ticket_8 == 0 && l_ticket_16 == 0) { if (TimeCurrent() >= gi_216 && TimeCurrent() EndHour && TimeHour(TimeCurrent()) >= StartHour || TimeHour(TimeCurrent()) < EndHour)) { if (DayOfWeek() != 5 || Hour() < FridayCloseTime) { if ((li_28 == 1 && l_ticket_4 == 0) || UseMACD == FALSE) { if (AccountFreeMarginCheck(Symbol(), OP_BUY, Lots * li_32) >= 0.0) { if (BrokerMode != 2 && BrokerMode != 3) OrderSend(Symbol(), OP_BUY, Lots, Bid, Slippage, l_price_80, l_price_88, "Magic = " + Magic, Magic, 0, CLR_NONE); else { l_ticket_36 = OrderSend(Symbol(), OP_BUY, Lots, Bid, Slippage, 0, 0, "Magic = " + Magic, Magic, 0, CLR_NONE); if (l_ticket_36 > 0) { l_bool_320 = OrderModify(l_ticket_36, OrderOpenPrice(), l_price_80, l_price_88, 0, CLR_NONE); if (l_bool_320 == FALSE) Print("Error modifying SELL order : ", GetLastError()); } } } else { if (AccountFreeMarginCheck(Symbol(), OP_SELL, Lots) >= 0.0) ls_296 = "we recommend you to decrease your start lot or increase deposit"; else ls_256 = "SELL, " + DoubleToStr(Lots, 2) + " lots. "; } } } } } else ls_240 = gs_224; } if (l_ticket_4 != 0 && l_ticket_12 != 0) { if (AccountFreeMarginCheck(Symbol(), OP_BUY, l_ord_lots_136) < 0.0) { ls_280 = "BUYLIMIT, " + DoubleToStr(l_ord_lots_136, 2) + " lots. "; OrderDelete(l_ticket_12); } } if (l_ticket_4 != 0 && l_ticket_12 == 0) { if (AccountFreeMarginCheck(Symbol(), OP_BUY, 2.0 * ld_40) >= 0.0) { l_pips_168 = FinalStep(NormalizeDouble(ld_40 / l_ord_lots_192, 0)); l_pips_160 = FinalTP(NormalizeDouble(ld_40 / l_ord_lots_192, 0)); l_price_72 = l_ord_open_price_56 - l_pips_168 * Point; if (ConstantStop == FALSE) l_price_80 = l_price_72 - StopLoss * Point; else l_price_80 = ld_176; if (StopLoss = 0.0) { l_pips_168 = FinalStep(NormalizeDouble(ld_48 / l_ord_lots_200, 0)); l_pips_160 = FinalTP(NormalizeDouble(ld_48 / l_ord_lots_200, 0)); l_price_72 = l_ord_open_price_64 + l_pips_168 * Point; if (ConstantStop == FALSE) l_price_80 = l_price_72 + StopLoss * Point; else l_price_80 = ld_184; if (StopLoss |
打赏
最新创建圈子
- 新闻EA运行效果图圈 2019-05-05
圈主:admin 帖子:1