最后由 naowei 于 2021-10-7 10:41 编辑
这个EA只能测试,但模拟实盘和真实账户均不开单。联系其QQ,难以回答验证问题。在网上查了一下,只找到一个线索:要加载wininet.dll的动态链接库,怎样加载,没有说明。有请高手帮忙解决这个EA实盘不开单的问题。能解决这个问题或者修改源码使EA能实盘开单者,请将解决问题后的EA源码发至本人邮箱。重谢!
源码于下:
//QQ:1778332087 #property copyright "2019,COMBO PLAN EA." #property link "http://www.snipersuite.com/"
#import "wininet.dll" int InternetOpenA(string a0, int a1, string a2, string a3, int a4); int InternetOpenUrlA(int a0, string a1, string a2, int a3, int a4, inta5); int InternetReadFile(int a0, string a1, int a2, int& a3[]); int InternetCloseHandle(int a0);
#import intg_datetime_84; extern int SL = 40; extern int TP = 8; extern int Cls = 3; extern bool MM = TRUE; extern double Risk = 1.0; extern double ManLot = 0.01; extern int OpenHour = 21; extern int CloseHour = 12; extern int Slippage = 3; extern int MaxSpread = 3; extern int Friday = 65; extern int Monday = 5; extern bool CloseBy = TRUE; extern int FilterD = 5; extern int FilterV = 10; extern int FilterC = 20; extern int FilterDS = 5; extern int FilterVS = 10; extern int FilterCS = 20; extern int gi_88; extern int gi_92; extern int gi_96 = 0; extern int gi_100 = 1; extern int gi_104 = 13; extern double FX = 3.5; extern double FXS = 3.5; extern int Magic = 7895123;
string s0 = "=== 茵彘腓磴 橡铘栩?==============================================================================="; extern bool TrailingProf_Use = TRUE; extern int TrailingProfStart = 8; extern int TrailingProf = 11; bool gi_232 = TRUE; double gd_unused_236 = 100.0; double gd_unused_244 = 0.01; int gi_252 = 1; bool gi_256; double g_ask_260; double g_bid_268; int g_datetime_276 = 0; int g_datetime_280 = 0; int g_datetime_284 = 0; int g_datetime_288 = 0;
double setpoint() { double ld_ret_0; if(Digits <= 3) ld_ret_0 = 0.01; else ld_ret_0 = 0.0001; return (ld_ret_0); } intinit () {
} int start() {
Comment(""); if(CloseBy) CloseProfit(); if(Friday > 0) { if (TimeDayOfWeek(TimeCurrent()) == 5) { if (TimeCurrent() > 86400 * (TimeCurrent() / 86400) + 86400 - 60 *Friday) { fOrderCloseMarket(); return (0); } } } if(Monday > 0) { if (TimeDayOfWeek(TimeCurrent()) == 1) if (TimeCurrent() < 86400 * (TimeCurrent() / 86400) + 60 * Monday)return (0); } if(Ask - Bid <= MaxSpread * setpoint()) { if (TradingTime() == 1) { if (gi_232) { g_ask_260 = Ask; g_bid_268 = Bid; gi_232 = FALSE; return (0); } if (MathAbs(Open[0] - Open[FilterD]) <= FilterV * setpoint()) { if (g_bid_268 - Bid >= FX * setpoint() && Close[0] <=Open[0] && !(MathAbs(Close[0] - Open[0]) > setpoint() * FilterC)) { OrderSend(Symbol(), OP_BUY,Lots(), Ask, Slippage, Ask - SL * setpoint(), Ask + TP * setpoint(), "QQ:1778332087",Magic, 0, DarkGreen); Print(GetLastError(), "ASK=", Ask, " SL=", Ask - SL * setpoint(), " TP=", Ask+ TP * setpoint()); Sleep(500); RefreshRates(); } } if (MathAbs(Open[0] - Open[FilterDS]) <= FilterVS * setpoint()) { if (Ask - g_ask_260 >= FXS * setpoint() && Close[0] >=Open[0] && !(MathAbs(Close[0] - Open[0]) > setpoint() * FilterCS)) { OrderSend(Symbol(), OP_SELL,Lots(), Bid, Slippage, Bid + SL * setpoint(), Bid - TP * setpoint(), "QQ:1778332087",Magic, 0, DeepPink); Print(GetLastError(), "BID=", Bid, " SL=", Bid + SL * setpoint(), " TP=", Bid- TP * setpoint()); Sleep(500); RefreshRates(); } } } } g_ask_260 = Ask; g_bid_268 = Bid; if(TrailingProf_Use) fTrailingProfWithStart(); return (0); }
void CloseProfit() { int li_unused_0 = 0; int li_unused_4 = 0; double ld_unused_8 = 0; if(OrdersTotal() > 0) { for (int l_pos_16 = OrdersTotal() + 1; l_pos_16 >= 0; l_pos_16--) { if (OrderSelect(l_pos_16, SELECT_BY_POS, MODE_TRADES)) { if (OrderSymbol() == Symbol()) { if (OrderMagicNumber() == Magic){ if (OrderCloseTime() == 0) { if (OrderType() == OP_BUY){ RefreshRates(); if (Bid >OrderOpenPrice() + Cls * setpoint()) { Print("del"); del(OrderTicket()); } } if (OrderType() ==OP_SELL) { RefreshRates(); if (Ask <OrderOpenPrice() - Cls * setpoint()) { Print("del"); del(OrderTicket()); } } } } } } } } }
void del(int a_ticket_0) { int l_error_4; string l_symbol_8; double l_bid_16; for (int l_count_24 = 0; l_count_24 < 1; l_count_24++) { GetLastError(); OrderSelect(a_ticket_0, SELECT_BY_TICKET, MODE_TRADES); l_symbol_8 = OrderSymbol(); if (OrderType() == OP_BUY) { RefreshRates(); l_bid_16 = MarketInfo(l_symbol_8, MODE_BID); if (!OrderClose(a_ticket_0, OrderLots(), l_bid_16, 3, Green)) l_error_4= GetLastError(); } if (OrderType() == OP_SELL) { RefreshRates(); l_bid_16 = MarketInfo(l_symbol_8, MODE_ASK); if (!OrderClose(a_ticket_0, OrderLots(), l_bid_16, 3, Green)) l_error_4= GetLastError(); } if (l_error_4 == 0/* NO_ERROR */) { PlaySound("expert.wav"); return; } if (l_error_4 != 0/* NO_ERROR */) { PlaySound("timeout.wav"); Print("Error for Close Funtion =", l_error_4); } while (!IsTradeAllowed()) Sleep(5000); if (l_error_4 == 146/* TRADE_CONTEXT_BUSY */) while(IsTradeContextBusy()) Sleep(11000); } }
int TradingTime() { gi_256 = FALSE; if(TimeHour(TimeCurrent()) >= OpenHour || TimeHour(TimeCurrent()) <CloseHour) gi_256 = TRUE; return (gi_256); }
double Lots() { double ld_ret_0; int li_8; double ld_12 = NormalizeDouble(MarketInfo(Symbol(), MODE_LOTSTEP), 2); double ld_20 = NormalizeDouble(MarketInfo(Symbol(),MODE_MARGINREQUIRED), 4); double ld_28 = 100.0 * (ld_20 + 5.0); if(ld_12 == 0.01) li_8 = 2; else li_8 = 1; gi_252 = li_8; if(MM == TRUE) ld_ret_0 = NormalizeDouble(AccountFreeMargin() / (ld_28 / Risk) -0.05, gi_252); else ld_ret_0 = ManLot; double ld_36 = NormalizeDouble(MarketInfo(Symbol(), MODE_MINLOT), 2); double ld_44 = NormalizeDouble(MarketInfo(Symbol(), MODE_MAXLOT), 2); if(gi_252 == 2) ld_36 = 0.01; if(ld_ret_0 < ld_36) ld_ret_0 = ld_36; if(ld_ret_0 > ld_44) ld_ret_0 = ld_44; return (ld_ret_0); }
int fOrderCloseMarket(bool ai_0 = TRUE,bool ai_4 = TRUE) { int l_error_8; int li_ret_12 = 0; for (int l_pos_16 = OrdersTotal() - 1; l_pos_16 >= 0; l_pos_16--) { if (OrderSelect(l_pos_16, SELECT_BY_POS, MODE_TRADES)) { if (OrderSymbol() == Symbol()) { if (ai_0) { if (OrderType() == OP_BUY) { RefreshRates(); if (!IsTradeContextBusy()) { if(!OrderClose(OrderTicket(), OrderLots(), ND(Bid), 3, CLR_NONE)) { l_error_8 =GetLastError(); Print("Error closeBUY " + OrderTicket() + " " + l_error_8); li_ret_12 = -1; } } else { if (TimeCurrent() >g_datetime_276 + 20) { g_datetime_276 =TimeCurrent(); Print("Need closeBUY " + OrderTicket() + ". Trade Context Busy"); } return (-2); } } } if (ai_4) { if (OrderType() == OP_SELL) { RefreshRates(); if (!IsTradeContextBusy()) { if(!OrderClose(OrderTicket(), OrderLots(), ND(Ask), 3, CLR_NONE)) { l_error_8 =GetLastError(); Print("Error closeSELL " + OrderTicket() + " " + l_error_8); li_ret_12 = -1; } } else { if (TimeCurrent() >g_datetime_280 + 20) { g_datetime_280 =TimeCurrent(); Print("Need closeSELL " + OrderTicket() + ". Trade Context Busy"); } return (-2); } } } } } } return (li_ret_12); }
double ND(double ad_0) { return (NormalizeDouble(ad_0, Digits)); }
void fTrailingProfWithStart() { double l_price_0; int l_error_8; for (int l_pos_12 = 0; l_pos_12 < OrdersTotal(); l_pos_12++) { if (OrderSelect(l_pos_12, SELECT_BY_POS, MODE_TRADES)) { if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic) { if (OrderType() == OP_BUY) { RefreshRates(); if (ND(Bid - OrderOpenPrice())<= ND((-setpoint()) * TrailingProfStart)) { l_price_0 = ND(Bid +setpoint() * TrailingProf); if (ND(OrderTakeProfit())> l_price_0 || ND(OrderTakeProfit()) == 0.0) { if (!IsTradeContextBusy()){ if(!OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss(), l_price_0, 0,CLR_NONE)) { l_error_8 =GetLastError(); Print("Errortrailingprofit BUY " + OrderTicket() + " - " + l_error_8); } } else { if (g_datetime_284 + 15< TimeCurrent()) { g_datetime_284 =TimeCurrent(); Print("Needtrailingprofit BUY " + OrderTicket() + ". Trade Context Busy"); } } } } } if (OrderType() == OP_SELL) { RefreshRates(); if (ND(OrderOpenPrice() - Ask)<= ND((-setpoint()) * TrailingProfStart)) { l_price_0 = ND(Ask - setpoint() *TrailingProf); if (!IsTradeContextBusy()) { if (ND(OrderTakeProfit())< l_price_0) { if(!OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss(), l_price_0, 0,CLR_NONE)) { l_error_8 =GetLastError(); Print("Errortrailingprofit SELL " + OrderTicket() + " - " + l_error_8); } } } else { if (g_datetime_288 + 15< TimeCurrent()) { g_datetime_288 =TimeCurrent(); Print("Needtrailingprofit SELL " + OrderTicket() + ". Trade Context Busy"); } } } } } } } } |