السلام عليكم جميعا
شكرا لصاحب الموضوع على مجهوداته , والموضوع شيق الصراحة ولو إني بواجه صعوبات كثير رغم محاولاتي إلا إني بفشل في كل مرة
, فياريت أحد الأخوة يساعدني أكمل الإكسبرت إلي بديت برمجته , وبحمل الكود وانتو شوفو ونبهوني ع الأخطاء
//-------------------------------------------------------------
// Etasoft Inc. Forex EA and Script Generator version 4.1 EA
//-------------------------------------------------------------
// Keywords: MT4, Forex EA builder, create EA, expert advisor developer
#property copyright "Copyright © 2011, Etasoft Inc. Forex EA Generator v4.1"
#property link "http://www.forexgenerator.com/"
#include <stdlib.mqh>
#include <WinUser32.mqh>
// exported variables
extern double BuyLots3 = 0.1;
extern int BuyStoploss3 = 20;
extern int BuyTakeprofit3 = 30;
extern int PriceOffset3 = 8;
extern double SellLots4 = 0.1;
extern int SellStoploss4 = 20;
extern int SellTakeprofit4 = 30;
extern int PriceOffset4 = -8;
// 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 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);
}
OnEveryTick1();
}
void OnEveryTick1()
{
if (true == false && false) PipValue = 10;
if (true && (NDigits == 3 || NDigits == 5)) PipValue = 10;
TechnicalAnalysis2x2();
}
void TechnicalAnalysis2x2()
{
if ((0 > iMACD(NULL, NULL,5,35,10,PRICE_OPEN,MODE_SIGNAL,0)) && (1 > iMACD(NULL, NULL,5,35,10,PRICE_OPEN,MODE_SIGNAL,0)))
{
IfOrderDoesNotExist6();
IfOrderDoesNotExist7();
}
}
void IfOrderDoesNotExist6()
{
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() == 1)
{
exists = true;
}
}
else
{
Print("OrderSelect() error - ", ErrorDescription(GetLastError()));
}
if (exists == false)
{
BuyPendingOrder3();
}
}
void BuyPendingOrder3()
{
int expire = TimeCurrent() + 60 * 60;
double price = NormalizeDouble(Ask, NDigits) + PriceOffset3*PipValue*Point;
double SL = price - BuyStoploss3*PipValue*Point;
if (BuyStoploss3 == 0) SL = 0;
double TP = price + BuyTakeprofit3*PipValue*Point;
if (BuyTakeprofit3 == 0) TP = 0;
if (60 == 0) expire = 0;
int ticket = OrderSend(Symbol(), OP_BUYSTOP, BuyLots3, price, 20, SL, TP, "My Expert", 1, expire, Blue);
if (ticket == -1)
{
Print("OrderSend() error - ", ErrorDescription(GetLastError()));
}
}
void IfOrderDoesNotExist7()
{
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() == 1)
{
exists = true;
}
}
else
{
Print("OrderSelect() error - ", ErrorDescription(GetLastError()));
}
if (exists == false)
{
SellPendingOrder4();
}
}
void SellPendingOrder4()
{
int expire = TimeCurrent() + 60 * 60;
double price = NormalizeDouble(Bid, NDigits) - PriceOffset4*PipValue*Point;
double SL = price + SellStoploss4*PipValue*Point;
if (SellStoploss4 == 0) SL = 0;
double TP = price - SellTakeprofit4*PipValue*Point;
if (SellTakeprofit4 == 0) TP = 0;
if (60 == 0) expire = 0;
int ticket = OrderSend(Symbol(), OP_SELLSTOP, SellLots4, price, 20, SL, TP, "My Expert", 1, expire, Red);
if (ticket == -1)
{
Print("OrderSend() error - ", ErrorDescription(GetLastError()));
}
}
int deinit()
{
if (false) ObjectsDeleteAll();
}