|
اخى انت مرمج الاكسبيرت ببرنامجforex generator4
تكرار الضفقات راجع انك لم تعمل الشرط التالى
IfOrderDoesNotExist
للبيع و الشراء
هدا الكود راح يحل مشكل تكرار الصفقات
يكفي دمجة مع اكسبيرتك فقط[PHP]//-------------------------------------------------------------
// 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 BuyLots6 = 0.1;
extern int BuyStoploss6 = 20;
extern int BuyTakeprofit6 = 30;
// 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;
IfOrderDoesNotExist3();
}
void IfOrderDoesNotExist3()
{
bool exists = false;
for (int i=OrdersTotal()-1; i >= 0; i--)
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
{
if (OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == 1)
{
exists = true;
}
}
else
{
Print("OrderSelect() error - ", ErrorDescription(GetLastError()));
}
if (exists == false)
{
IfOrderDoesNotExist2();
}
}
void IfOrderDoesNotExist2()
{
bool exists = false;
for (int i=OrdersTotal()-1; i >= 0; i--)
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
{
if (OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == 1)
{
exists = true;
}
}
else
{
Print("OrderSelect() error - ", ErrorDescription(GetLastError()));
}
if (exists == false)
{
BuyOrder6();
}
}
void BuyOrder6()
{
double SL = Ask - BuyStoploss6*PipValue*Point;
if (BuyStoploss6 == 0) SL = 0;
double TP = Ask + BuyTakeprofit6*PipValue*Point;
if (BuyTakeprofit6 == 0) TP = 0;
int ticket = -1;
if (true)
ticket = OrderSend(Symbol(), OP_BUY, BuyLots6, Ask, 4, 0, 0, "My Expert", 1, 0, Blue);
else
ticket = OrderSend(Symbol(), OP_BUY, BuyLots6, 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()));
}
}
int deinit()
{
if (false) ObjectsDeleteAll();
[/PHP] |
|