هذا هو الكود بالكامل بعد التعديل
[PHP]
#property copyright " - jmeel24@yahoo.com  "
#include <stdlib.mqh>
#include <WinUser32.mqh>
// exported variables
extern string A0=" ------- General Setting --------- ";
extern int Hour41 = 0;
extern double Volume_Lots = 0.1;
extern int MagicNo=4141;
extern string A2=" ------- B U Y Setting ------------ ";
extern int PriceOffset30 = 12;
extern int BuyTakeprofit30 = 10;
extern int BuyStoploss30 = 20;
 int Expiration30 = 1440;
extern string A1=" ------- S E L L Setting ---------- ";
extern int PriceOffset31 = 10;
extern int SellTakeprofit31 = 10;
extern int SellStoploss31 = 20;
 int Expiration31 = 1440;
// 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;
int Today41 = -1;
datetime BarTime25 = 0;
datetime BarTime29 = 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);
    }
    
    OnEveryTick43();
    
}
void OnEveryTick43()
{
    if (true == false && false) PipValue = 10;
    if (true && (NDigits == 3 || NDigits == 5)) PipValue = 10;
    
    CustomCode45();
    AtCertainTime41();
    IfOrderExists12();
    IfOrderExists5();
    
}
void CustomCode45()
{
    
    
}
void AtCertainTime41()
{
    int datetime800 = TimeCurrent();
    int hour0 = TimeHour(datetime800);
    int minute0 = TimeMinute(datetime800);
    if (DayOfWeek() != Today41 && hour0 == Hour41 )
    {
        Today41 = DayOfWeek();
        IfOrderDoesNotExist24();
        IfOrderDoesNotExist28();
        
    }
}
void IfOrderDoesNotExist24()
{
    bool exists = false;
    for (int i=OrdersTotal()-1; i >= 0; i--)
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
    {
        if (OrderType() == OP_SELLSTOP && OrderSymbol() == Symbol() && OrderMagicNumber() == 33)
        {
            exists = true;
        }
    }
    else
    {
        Print("OrderSelect() error - ", ErrorDescription(GetLastError()));
    }
    
    if (exists == false)
    {
        OncePerBar25();
        
    }
}
void OncePerBar25()
{
    
    if (BarTime25 < Time[0])
    {
        // we have a new bar opened
        BarTime25 = Time[0]; // keep the new bar open time
        SellPendingOrder31();
        
    }
}
void SellPendingOrder31()
{
    int expire = TimeCurrent() + 60 * Expiration31;
    double price = NormalizeDouble(Open[0], NDigits) - PriceOffset31*PipValue*Point;
    double SL = price + SellStoploss31*PipValue*Point;
    if (SellStoploss31 == 0) SL = 0;
    double TP = price - SellTakeprofit31*PipValue*Point;
    if (SellTakeprofit31 == 0) TP = 0;
    if (Expiration31 == 0) expire = 0;
    int ticket = OrderSend(Symbol(), OP_SELLSTOP, Volume_Lots, price, 4, SL, TP, "My Expert", 33, expire, Red);
    if (ticket == -1)
    {
        Print("OrderSend() error - ", ErrorDescription(GetLastError()));
    }
    
}
void IfOrderDoesNotExist28()
{
    bool exists = false;
    for (int i=OrdersTotal()-1; i >= 0; i--)
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
    {
        if (OrderType() == OP_BUYSTOP && OrderSymbol() == Symbol() && OrderMagicNumber() == 33)
        {
            exists = true;
        }
    }
    else
    {
        Print("OrderSelect() error - ", ErrorDescription(GetLastError()));
    }
    
    if (exists == false)
    {
        OncePerBar29();
        
    }
}
void OncePerBar29()
{
    
    if (BarTime29 < Time[0])
    {
        // we have a new bar opened
        BarTime29 = Time[0]; // keep the new bar open time
        BuyPendingOrder30();
        
    }
}
void BuyPendingOrder30()
{
    int expire = TimeCurrent() + 60 * Expiration30;
    double price = NormalizeDouble(Open[0], NDigits) + PriceOffset30*PipValue*Point;
    double SL = price - BuyStoploss30*PipValue*Point;
    if (BuyStoploss30 == 0) SL = 0;
    double TP = price + BuyTakeprofit30*PipValue*Point;
    if (BuyTakeprofit30 == 0) TP = 0;
    if (Expiration30 == 0) expire = 0;
    int ticket = OrderSend(Symbol(), OP_BUYSTOP, Volume_Lots, price, 4, SL, TP, "My Expert", 33, expire, Blue);
    if (ticket == -1)
    {
        Print("OrderSend() error - ", ErrorDescription(GetLastError()));
    }
    
}
void IfOrderExists12()
{
    bool exists = false;
    for (int i=OrdersTotal()-1; i >= 0; i--)
    if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY))
    {
        if (OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == 33 && OrderProfit() > 0)
        {
            exists = true;
        }
    }
    else
    {
        Print("OrderSelect() error - ", ErrorDescription(GetLastError()));
    }
    
    if (exists)
    {
        DeletePendingOrder10();
        
    }
}
void DeletePendingOrder10()
{
    
    for (int i=OrdersTotal()-1; i >= 0; i--)
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
    {
        if (OrderType() == OP_SELLSTOP && OrderSymbol() == Symbol() && OrderMagicNumber() == 33)
        {
            bool ret = OrderDelete(OrderTicket(), Red);
            
            if (ret == false)
            {
                Print("OrderDelete() error - ", ErrorDescription(GetLastError()));
            }
        }
    }
    
}
void IfOrderExists5()
{
    bool exists = false;
    for (int i=OrdersTotal()-1; i >= 0; i--)
    if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY))
    {
        if (OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == 33 && OrderProfit() > 0)
        {
            exists = true;
        }
    }
    else
    {
        Print("OrderSelect() error - ", ErrorDescription(GetLastError()));
    }
    
    if (exists)
    {
        DeletePendingOrder9();
        
    }
}
void DeletePendingOrder9()
{
    
    for (int i=OrdersTotal()-1; i >= 0; i--)
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
    {
        if (OrderType() == OP_BUYSTOP && OrderSymbol() == Symbol() && OrderMagicNumber() == 33)
        {
            bool ret = OrderDelete(OrderTicket(), Red);
            
            if (ret == false)
            {
                Print("OrderDelete() error - ", ErrorDescription(GetLastError()));
            }
        }
    }
    
}
int deinit()
{
    if (false) ObjectsDeleteAll();
    
    
    
    
}
[/PHP]