عرض مشاركة واحدة
قديم 17-12-2012, 03:43 PM   المشاركة رقم: 25
الكاتب
jmeel
عضو نشيط
الصورة الرمزية jmeel

البيانات
تاريخ التسجيل: Jul 2012
رقم العضوية: 10231
المشاركات: 401
بمعدل : 0.09 يوميا

الإتصالات
الحالة:
jmeel غير متواجد حالياً
وسائل الإتصال:

كاتب الموضوع : nesma المنتدى : منتدى المؤشرات و الاكسبيرتات
افتراضي رد: لو سمحت اول مره اطلب اكسبريت ممكن حد يساعدني؟

تفضلي الكود بعد التصحيح
[PHP]
#property copyright " jmeel24@yahoo.com "

#include <stdlib.mqh>
#include <WinUser32.mqh>

// exported variables


extern int MagicNo=4141;
extern string A1=" Time Order Setting ";
extern int Hour16 = 22;
extern int Minute16 = 2;

extern string A2=" Sell Order Setting ";
extern double SellLots8 = 0.1;
extern int SellStoploss8 = 20;
extern int SellTakeprofit8 = 10;
extern int PriceOffset8 = 10;

extern string A3=" Buy Order Setting ";
extern double BuyLots17 = 0.1;
extern int BuyStoploss17 = 20;
extern int BuyTakeprofit17 = 10;
extern int PriceOffset17 = 12;


// 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 Expiration17 = 1380;
int Expiration8 = 1380;
int Today16 = -1;
datetime BarTime7 = 0;
datetime BarTime9 = 0;


int deinit()
{
if (false) ObjectsDeleteAll();




}

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);
}

OnEveryTick20();

}

void OnEveryTick20()
{
if (true == false && false) PipValue = 10;
if (true && (NDigits == 3 || NDigits == 5)) PipValue = 10;

CheckLastOrderResult23();

AtCertainTime16();


}



void AtCertainTime16()
{
int datetime800 = TimeLocal();
int hour0 = TimeHour(datetime800);
int minute0 = TimeMinute(datetime800);
if (DayOfWeek() != Today16 && hour0 == Hour16 && minute0 == Minute16)
{
Today16 = DayOfWeek();
IfOrderDoesNotExist15();
IfOrderDoesNotExist14();

}
}

void IfOrderDoesNotExist15()
{
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() == MagicNo)
{
exists = true;
}
}
else
{
Print("OrderSelect() error - ", ErrorDescription(GetLastError()));
}

if (exists == false)
{
OncePerBar7();

}
}

void OncePerBar7()
{

if (BarTime7 < Time[0])
{
// we have a new bar opened
BarTime7 = Time[0]; // keep the new bar open time
SellPendingOrder8();

}
}

void SellPendingOrder8()
{
int expire = TimeCurrent() + 60 * Expiration8;
double price = NormalizeDouble(Open[0], NDigits) - PriceOffset8*PipValue*Point;
double SL = price + SellStoploss8*PipValue*Point;
if (SellStoploss8 == 0) SL = 0;
double TP = price - SellTakeprofit8*PipValue*Point;
if (SellTakeprofit8 == 0) TP = 0;
if (Expiration8 == 0) expire = 0;
int ticket = OrderSend(Symbol(), OP_SELLSTOP, SellLots8, price, 4, SL, TP, "My Expert", MagicNo, expire, Red);
if (ticket == -1)
{
Print("OrderSend() error - ", ErrorDescription(GetLastError()));
}

}

void IfOrderDoesNotExist14()
{
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() == MagicNo)
{
exists = true;
}
}
else
{
Print("OrderSelect() error - ", ErrorDescription(GetLastError()));
}

if (exists == false)
{
OncePerBar9();

}
}

void OncePerBar9()
{

if (BarTime9 < Time[0])
{
// we have a new bar opened
BarTime9 = Time[0]; // keep the new bar open time
BuyPendingOrder17();

}
}

void BuyPendingOrder17()
{
int expire = TimeCurrent() + 60 * Expiration17;
double price = NormalizeDouble(Open[0], NDigits) + PriceOffset17*PipValue*Point;
double SL = price - BuyStoploss17*PipValue*Point;
if (BuyStoploss17 == 0) SL = 0;
double TP = price + BuyTakeprofit17*PipValue*Point;
if (BuyTakeprofit17 == 0) TP = 0;
if (Expiration17 == 0) expire = 0;
int ticket = OrderSend(Symbol(), OP_BUYSTOP, BuyLots17, price, 4, SL, TP, "My Expert", MagicNo, expire, Blue);
if (ticket == -1)
{
Print("OrderSend() error - ", ErrorDescription(GetLastError()));
}

}

void CheckLastOrderResult23()
{
double profit = 0;
datetime lastCloseTime = 0;
int cnt = OrdersHistoryTotal();
for (int i=0; i < cnt; i++)
{
if (!OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)) continue;
if (OrderSymbol() == Symbol() && lastCloseTime < OrderCloseTime())
{
lastCloseTime = OrderCloseTime();
profit = OrderProfit();
}
}
if (profit > 0)

{
DeletePendingOrder19();
DeletePendingOrder18();

}

}

void DeletePendingOrder19()
{

for (int i=OrdersTotal()-1; i <= 0; i++)
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
{
if (OrderType() == OP_SELLSTOP && OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNo)
{
bool ret = OrderDelete(OrderTicket(), Red);

if (ret == false)
{
Print("OrderDelete() error - ", ErrorDescription(GetLastError()));
}
}
}

}

void DeletePendingOrder18()
{

for (int i=OrdersTotal()-1; i <= 0; i++)
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
{
if (OrderType() == OP_BUYSTOP && OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNo)
{
bool ret = OrderDelete(OrderTicket(), Red);

if (ret == false)
{
Print("OrderDelete() error - ", ErrorDescription(GetLastError()));
}
}
}

}




[/PHP]



التوقيع

* Don't work harder, work smarter *

عرض البوم صور jmeel  
رد مع اقتباس
  #25  
قديم 17-12-2012, 03:43 PM
jmeel jmeel غير متواجد حالياً
عضو نشيط
افتراضي رد: لو سمحت اول مره اطلب اكسبريت ممكن حد يساعدني؟

تفضلي الكود بعد التصحيح
[PHP]
#property copyright " jmeel24@yahoo.com "

#include <stdlib.mqh>
#include <WinUser32.mqh>

// exported variables


extern int MagicNo=4141;
extern string A1=" Time Order Setting ";
extern int Hour16 = 22;
extern int Minute16 = 2;

extern string A2=" Sell Order Setting ";
extern double SellLots8 = 0.1;
extern int SellStoploss8 = 20;
extern int SellTakeprofit8 = 10;
extern int PriceOffset8 = 10;

extern string A3=" Buy Order Setting ";
extern double BuyLots17 = 0.1;
extern int BuyStoploss17 = 20;
extern int BuyTakeprofit17 = 10;
extern int PriceOffset17 = 12;


// 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 Expiration17 = 1380;
int Expiration8 = 1380;
int Today16 = -1;
datetime BarTime7 = 0;
datetime BarTime9 = 0;


int deinit()
{
if (false) ObjectsDeleteAll();




}

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);
}

OnEveryTick20();

}

void OnEveryTick20()
{
if (true == false && false) PipValue = 10;
if (true && (NDigits == 3 || NDigits == 5)) PipValue = 10;

CheckLastOrderResult23();

AtCertainTime16();


}



void AtCertainTime16()
{
int datetime800 = TimeLocal();
int hour0 = TimeHour(datetime800);
int minute0 = TimeMinute(datetime800);
if (DayOfWeek() != Today16 && hour0 == Hour16 && minute0 == Minute16)
{
Today16 = DayOfWeek();
IfOrderDoesNotExist15();
IfOrderDoesNotExist14();

}
}

void IfOrderDoesNotExist15()
{
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() == MagicNo)
{
exists = true;
}
}
else
{
Print("OrderSelect() error - ", ErrorDescription(GetLastError()));
}

if (exists == false)
{
OncePerBar7();

}
}

void OncePerBar7()
{

if (BarTime7 < Time[0])
{
// we have a new bar opened
BarTime7 = Time[0]; // keep the new bar open time
SellPendingOrder8();

}
}

void SellPendingOrder8()
{
int expire = TimeCurrent() + 60 * Expiration8;
double price = NormalizeDouble(Open[0], NDigits) - PriceOffset8*PipValue*Point;
double SL = price + SellStoploss8*PipValue*Point;
if (SellStoploss8 == 0) SL = 0;
double TP = price - SellTakeprofit8*PipValue*Point;
if (SellTakeprofit8 == 0) TP = 0;
if (Expiration8 == 0) expire = 0;
int ticket = OrderSend(Symbol(), OP_SELLSTOP, SellLots8, price, 4, SL, TP, "My Expert", MagicNo, expire, Red);
if (ticket == -1)
{
Print("OrderSend() error - ", ErrorDescription(GetLastError()));
}

}

void IfOrderDoesNotExist14()
{
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() == MagicNo)
{
exists = true;
}
}
else
{
Print("OrderSelect() error - ", ErrorDescription(GetLastError()));
}

if (exists == false)
{
OncePerBar9();

}
}

void OncePerBar9()
{

if (BarTime9 < Time[0])
{
// we have a new bar opened
BarTime9 = Time[0]; // keep the new bar open time
BuyPendingOrder17();

}
}

void BuyPendingOrder17()
{
int expire = TimeCurrent() + 60 * Expiration17;
double price = NormalizeDouble(Open[0], NDigits) + PriceOffset17*PipValue*Point;
double SL = price - BuyStoploss17*PipValue*Point;
if (BuyStoploss17 == 0) SL = 0;
double TP = price + BuyTakeprofit17*PipValue*Point;
if (BuyTakeprofit17 == 0) TP = 0;
if (Expiration17 == 0) expire = 0;
int ticket = OrderSend(Symbol(), OP_BUYSTOP, BuyLots17, price, 4, SL, TP, "My Expert", MagicNo, expire, Blue);
if (ticket == -1)
{
Print("OrderSend() error - ", ErrorDescription(GetLastError()));
}

}

void CheckLastOrderResult23()
{
double profit = 0;
datetime lastCloseTime = 0;
int cnt = OrdersHistoryTotal();
for (int i=0; i < cnt; i++)
{
if (!OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)) continue;
if (OrderSymbol() == Symbol() && lastCloseTime < OrderCloseTime())
{
lastCloseTime = OrderCloseTime();
profit = OrderProfit();
}
}
if (profit > 0)

{
DeletePendingOrder19();
DeletePendingOrder18();

}

}

void DeletePendingOrder19()
{

for (int i=OrdersTotal()-1; i <= 0; i++)
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
{
if (OrderType() == OP_SELLSTOP && OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNo)
{
bool ret = OrderDelete(OrderTicket(), Red);

if (ret == false)
{
Print("OrderDelete() error - ", ErrorDescription(GetLastError()));
}
}
}

}

void DeletePendingOrder18()
{

for (int i=OrdersTotal()-1; i <= 0; i++)
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
{
if (OrderType() == OP_BUYSTOP && OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNo)
{
bool ret = OrderDelete(OrderTicket(), Red);

if (ret == false)
{
Print("OrderDelete() error - ", ErrorDescription(GetLastError()));
}
}
}

}




[/PHP]




رد مع اقتباس