السلام عليكم
الله يبارك فيك يا استاذ اسامه
عندي كد الحالي و واجهت بعض المشاكل عند تفعيل الصفقات بحيث يظهر عندي خطاء التالي في الجورنال: 4051
2011.04.26 05:25:44 EA EURCAD,H1: Error in putting on order!! -- 4051
2011.04.26 05:25:44 EURCAD,H1: invalid lots amount for OrderSend function
بحثت في النت و لقيت طريقة ازالته وحسب الشرح الموجود على الرابط كانه راجع الى وجود اشكال في دالة الفانكشن
http://f o r u m.mql4.com/27120
طبعا حاولت في تغيير حجم الصفقات و لكن لم ينفع و الاحجام المستخدمه هي 1 2 4 8 16 32 على حساب 100 الف دولار و هي ليست مايكرو حتى الاشكال يرجع اليها
ثم حسب شرح المبرمج على الرابط المشار اليه يجب استبدال بعض الاكواد باكواد اخرى:
raplace
Print("Lots: ", lot);
to
Print("Lots: ", lot," minlot - ",MarketInfo(Symbol(),MODE_MINLOT));
and
replace:
if(lot_min<0 lot_max<=0.0 lot_step<=0.0)
to
if(lot_min<=0 lot_max<=0.0 lot_step<=0.0)
add after:
LotsRisk=NormalizeDouble(LotsRisk/lot_step,0)*lot_step;
if(LotsRisk<lot_min) LotsRisk=lot_min;
if(LotsRisk>lot_max) LotsRisk=lot_max;
this string:
Print("LotsRisk - ",LotsRisk);
و لكن المشكله لا ادري في اي دالة يجب استبدال و اضافة الكد المطلوب في كد التالي:
ياريت اخي محمود اذا لديك حل لمشكلة خطاء 4051 فارجوا المساعده فيه او اتباع خطوات الاعلى حسب شرح المبرج
كود PHP:
int safeShortOrder(int ai_0, int ai_4, double a_lots_8, int a_magic_16, string a_comment_20) {
int l_error_32 = -1;
int l_count_36 = 0;
double l_price_40 = Bid + ai_0 * Point;
double l_price_48 = Bid - ai_4 * Point;
if (ai_0 <= 0) l_price_40 = 0;
if (ai_4 <= 0) l_price_48 = 0;
int l_ticket_28 = OrderSend(Symbol(), OP_SELL, a_lots_8, NormalizeDouble(Bid, Digits), 3, 0, 0, a_comment_20, a_magic_16, 0, Blue);
if (l_ticket_28 < 1) {
for (l_count_36 = 0; l_count_36 < 10; l_count_36++) {
l_error_32 = GetLastError();
Print("Error in putting on order!! -- ", l_error_32);
if (handleError(l_error_32) == 3) {
Alert("Fatal Error -- Can Not Put On Order! Haulting Trading...");
return (-2);
}
Print("Saveable error..trying again..(#" + l_count_36 + " of 10");
Sleep(2000);
Rates();
l_price_40 = Bid + ai_0 * Point;
l_price_48 = Bid - ai_4 * Point;
if (ai_0 <= 0) l_price_40 = 0;
if (ai_4 <= 0) l_price_48 = 0;
l_ticket_28 = OrderSend(Symbol(), OP_SELL, a_lots_8, NormalizeDouble(Bid, Digits), 3, 0, 0, a_comment_20, a_magic_16, 0, Blue);
if (l_ticket_28 > 0) break;
}
if (l_ticket_28 < 1) {
Alert("Could not put on order! Haulting Trading...");
return (-2);
}
}
OrderModify(l_ticket_28, OrderOpenPrice(), l_price_40, l_price_48, 0, CLR_NONE);
return (l_ticket_28);
}
int safeLongOrder(int ai_0, int ai_4, double a_lots_8, int a_magic_16, string a_comment_20) {
int l_error_32 = -1;
int l_count_36 = 0;
double l_price_40 = Ask - ai_0 * Point;
double l_price_48 = Ask + ai_4 * Point;
if (ai_0 <= 0) l_price_40 = 0;
if (ai_4 <= 0) l_price_48 = 0;
Print("Stop Loss -- ", l_price_40);
Print("Take Profit --", l_price_48);
int l_ticket_28 = OrderSend(Symbol(), OP_BUY, a_lots_8, NormalizeDouble(Ask, Digits), 3, 0, 0, a_comment_20, a_magic_16, 0, Blue);
if (l_ticket_28 < 1) {
for (l_count_36 = 0; l_count_36 < 10; l_count_36++) {
l_error_32 = GetLastError();
Print("Error in putting on order!! -- ", l_error_32);
if (handleError(l_error_32) == 3) {
Alert("Fatal Error -- Can Not Put On Order! Haulting Trading...");
return (-2);
}
Print("Saveable error..trying again..(#" + l_count_36 + " of 10");
Sleep(2000);
Rates();
l_price_40 = Ask - ai_0 * Point;
l_price_48 = Ask + ai_4 * Point;
if (ai_0 <= 0) l_price_40 = 0;
if (ai_4 <= 0) l_price_48 = 0;
l_ticket_28 = OrderSend(Symbol(), OP_BUY, a_lots_8, NormalizeDouble(Ask, Digits), 3, 0, 0, a_comment_20, a_magic_16, 0, Blue);
if (l_ticket_28 > 0) break;
}
if (l_ticket_28 < 1) {
Alert("Could not put on order! Haulting Trading...");
return (-2);
}
}
OrderModify(l_ticket_28, OrderOpenPrice(), l_price_40, l_price_48, 0, CLR_NONE);
return (l_ticket_28);
}
int totalOrders(string a_symbol_0, int a_magic_8) {
int l_count_12 = 0;
for (int l_pos_16 = 0; l_pos_16 < OrdersTotal(); l_pos_16++) {
OrderSelect(l_pos_16, SELECT__POS, MODE_TRADES);
if (OrderSymbol() == a_symbol_0 && OrderMagicNumber() == a_magic_8) l_count_12++;
}
return (l_count_12);
}