رجاء من الاخوه المبرمجين المساعده في حل مشكله order modify error
السلام عليكم ورحمة الله وبركاته الاكسبيرت التالي قمت بعمله علي برنامج Forex EA Generator وذلك لعدم امتلاكي خبره في البرمجه نهائيا
المشكله التي تحدث هي في اوقات كثيره جدا لا يقوم الاكسبيرت بتعديل الستوب لوز والبروفت تارجت بعد فتح الصفقه .. صراحة لا اعلم هل هي مشكله من البروكو في تنفيذ الاوردر ام هي مشكله من الاكسبيرت
وشكرا جزيلا مقدما
الكود ....
كود PHP:
//-------------------------------------------------------------
// Etasoft Inc. Forex EA and Script Generator version 5.0 EA
//-------------------------------------------------------------
// Keywords: MT4, Forex EA builder, create EA, expert advisor developer
#property copyright "Copyright © 2013, Etasoft Inc. Forex EA Generator v5.0"
#property link "http://www.********erator.com/"
#include <stdlib.mqh>
#include <WinUser32.mqh>
// exported variables
extern int SellStoploss34 = 5;
extern int SellTakeprofit34 = 12;
extern double BalanceRiskPercent34 = 10;
extern int BuyStoploss33 = 5;
extern int BuyTakeprofit33 = 12;
extern double BalanceRiskPercent33 = 10;
// local variables
double PipValue=1; // this variable is here to support 5-digit brokers
bool Terminated = false;
string LF = "\n"; // use this in custom or utility blocks where you need line feeds
int NDigits = 4; // used mostly for NormalizeDouble in Flex type blocks
int ObjCount = 0; // count of all objects created on the chart, allows creation of objects with unique names
int current = 0;
datetime BarTime35 = 0;
int init()
{
NDigits = Digits;
if (false) ObjectsDeleteAll(); // clear the chart
Comment(""); // clear the chart
}
// Expert start
int start()
{
if (Bars < 10)
{
Comment("Not enough bars");
return (0);
}
if (Terminated == true)
{
Comment("EA Terminated.");
return (0);
}
OnEveryNewBar35();
}
void OnEveryNewBar35()
{
PipValue = 1;
if (NDigits == 3 || NDigits == 5) PipValue = 10;
if (BarTime35 < Time[0])
{
// we have a new bar opened
BarTime35 = Time[0]; // keep the new bar open time
TechnicalAnalysis2x28();
TechnicalAnalysis2x27();
TechnicalAnalysis23();
TechnicalAnalysis32();
}
}
void TechnicalAnalysis2x28()
{
if ((iATR(NULL, NULL,30,1) > iATR(NULL, NULL,30,10)) && (Close[1] > Open[1]))
{
TechnicalAnalysis24();
}
}
void TechnicalAnalysis24()
{
if (iMA(NULL, NULL,20,0,MODE_EMA,PRICE_CLOSE,1) > iMA(NULL, NULL,20,0,MODE_EMA,PRICE_CLOSE,5))
{
TechnicalAnalysis22();
}
}
void TechnicalAnalysis22()
{
if (iCustom(NULL,0, "Explosion_Gold",100,40,5,5,1,FALSE,FALSE,FALSE,FALSE,1,2) < iCustom(NULL,0, "Explosion_Gold",100,40,5,5,1,FALSE,FALSE,FALSE,FALSE,2,5))
{
SellOrderRiskFixed34();
}
}
void SellOrderRiskFixed34()
{
double lotsize = MarketInfo(Symbol(),MODE_LOTSIZE) / AccountLeverage();
double pipsize = 0.1 * 10;
double maxlots = AccountBalance() / 100 * BalanceRiskPercent34 / lotsize * pipsize;
if (SellStoploss34 == 0) Print("OrderSend() error - stoploss can not be zero");
double lots = maxlots / SellStoploss34 * 10;
// calculate lot size based on current risk
double lotvalue = 0.001;
double minilot = MarketInfo(Symbol(), MODE_MINLOT);
int powerscount = 0;
while (minilot < 1)
{
minilot = minilot * MathPow(10, powerscount);
powerscount++;
}
lotvalue = NormalizeDouble(lots, powerscount - 1);
if (lotvalue < MarketInfo(Symbol(), MODE_MINLOT)) // make sure lot is not smaller than allowed value
{
lotvalue = MarketInfo(Symbol(), MODE_MINLOT);
}
if (lotvalue > MarketInfo(Symbol(), MODE_MAXLOT)) // make sure lot is not greater than allowed value
{
lotvalue = MarketInfo(Symbol(), MODE_MAXLOT);
}
double SL = Bid + SellStoploss34*PipValue*Point;
if (SellStoploss34 == 0) SL = 0;
double TP = Bid - SellTakeprofit34*PipValue*Point;
if (SellTakeprofit34 == 0) TP = 0;
int ticket = -1;
if (true)
ticket = OrderSend(Symbol(), OP_SELL, lotvalue, Bid, 4, 0, 0, "My Expert", 1, 0, Red);
else
ticket = OrderSend(Symbol(), OP_SELL, lotvalue, Bid, 4, SL, TP, "My Expert", 1, 0, Red);
if (ticket > -1)
{
if (true)
{
OrderSelect(ticket, SELECT_BY_TICKET);
bool ret = OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0, Red);
if (ret == false)
Print("OrderModify() error - ", ErrorDescription(GetLastError()));
}
}
else
{
Print("OrderSend() error - ", ErrorDescription(GetLastError()));
}
}
void TechnicalAnalysis2x27()
{
if ((iATR(NULL, NULL,30,1) > iATR(NULL, NULL,30,10)) && (Close[1] < Open[1]))
{
TechnicalAnalysis25();
}
}
void TechnicalAnalysis25()
{
if (iMA(NULL, NULL,20,0,MODE_EMA,PRICE_CLOSE,1) < iMA(NULL, NULL,20,0,MODE_EMA,PRICE_CLOSE,5))
{
TechnicalAnalysis26();
}
}
void TechnicalAnalysis26()
{
if (iCustom(NULL,0, "Explosion_Gold",100,40,5,5,1,FALSE,FALSE,FALSE,FALSE,0,2) < iCustom(NULL,0, "Explosion_Gold",100,40,5,5,1,FALSE,FALSE,FALSE,FALSE,2,5))
{
BuyOrderRiskFixed33();
}
}
void BuyOrderRiskFixed33()
{
double lotsize = MarketInfo(Symbol(),MODE_LOTSIZE) / AccountLeverage();
double pipsize = 0.1 * 10;
double maxlots = AccountBalance() / 100 * BalanceRiskPercent33 / lotsize * pipsize;
if (BuyStoploss33 == 0) Print("OrderSend() error - stoploss can not be zero");
double lots = maxlots / BuyStoploss33 * 10;
// calculate lot size based on current risk
double lotvalue = 0.001;
double minilot = MarketInfo(Symbol(), MODE_MINLOT);
int powerscount = 0;
while (minilot < 1)
{
minilot = minilot * MathPow(10, powerscount);
powerscount++;
}
lotvalue = NormalizeDouble(lots, powerscount - 1);
if (lotvalue < MarketInfo(Symbol(), MODE_MINLOT)) // make sure lot is not smaller than allowed value
{
lotvalue = MarketInfo(Symbol(), MODE_MINLOT);
}
if (lotvalue > MarketInfo(Symbol(), MODE_MAXLOT)) // make sure lot is not greater than allowed value
{
lotvalue = MarketInfo(Symbol(), MODE_MAXLOT);
}
double SL = Ask - BuyStoploss33*PipValue*Point;
if (BuyStoploss33 == 0) SL = 0;
double TP = Ask + BuyTakeprofit33*PipValue*Point;
if (BuyTakeprofit33 == 0) TP = 0;
int ticket = -1;
if (true)
ticket = OrderSend(Symbol(), OP_BUY, lotvalue, Ask, 4, 0, 0, "My Expert", 1, 0, Blue);
else
ticket = OrderSend(Symbol(), OP_BUY, lotvalue, Ask, 4, SL, TP, "My Expert", 1, 0, Blue);
if (ticket > -1)
{
if (true)
{
OrderSelect(ticket, SELECT_BY_TICKET);
bool ret = OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0, Blue);
if (ret == false)
Print("OrderModify() error - ", ErrorDescription(GetLastError()));
}
}
else
{
Print("OrderSend() error - ", ErrorDescription(GetLastError()));
}
}
void TechnicalAnalysis23()
{
if (Close[1] < iMA(NULL, NULL,20,0,MODE_EMA,PRICE_CLOSE,1))
{
CloseOrder7();
}
}
void CloseOrder7()
{
int orderstotal = OrdersTotal();
int orders = 0;
int ordticket[90][2];
for (int i = 0; i < orderstotal; i++)
{
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if (OrderType() != OP_SELL || OrderSymbol() != Symbol() || OrderMagicNumber() != 1)
{
continue;
}
ordticket[orders][0] = OrderOpenTime();
ordticket[orders][1] = OrderTicket();
orders++;
}
if (orders > 1)
{
ArrayResize(ordticket,orders);
ArraySort(ordticket);
}
for (i = 0; i < orders; i++)
{
if (OrderSelect(ordticket[i][1], SELECT_BY_TICKET) == true)
{
bool ret = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 4, Red);
if (ret == false)
Print("OrderClose() error - ", ErrorDescription(GetLastError()));
}
}
}
void TechnicalAnalysis32()
{
if (Close[1] > iMA(NULL, NULL,20,0,MODE_EMA,PRICE_CLOSE,1))
{
CloseOrder31();
}
}
void CloseOrder31()
{
int orderstotal = OrdersTotal();
int orders = 0;
int ordticket[90][2];
for (int i = 0; i < orderstotal; i++)
{
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if (OrderType() != OP_BUY || OrderSymbol() != Symbol() || OrderMagicNumber() != 1)
{
continue;
}
ordticket[orders][0] = OrderOpenTime();
ordticket[orders][1] = OrderTicket();
orders++;
}
if (orders > 1)
{
ArrayResize(ordticket,orders);
ArraySort(ordticket);
}
for (i = 0; i < orders; i++)
{
if (OrderSelect(ordticket[i][1], SELECT_BY_TICKET) == true)
{
bool ret = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 4, Red);
if (ret == false)
Print("OrderClose() error - ", ErrorDescription(GetLastError()));
}
}
}
int deinit()
{
if (false) ObjectsDeleteAll();
}