قم بإلغاء هذا السطر من الكوداقتباس:
السلام عليكم مبرمجين واعضاء ومشرفين المنتدى
هذا الاكسبيرت يعطي تنبية للشراء والبيع
لكنه لا يدخل صفقات . الرجاء توضيح كيف الغي التنبية واجعلة يدخل صفقات
وكذلك به تنبية modify order . اريد ان الغي التنبيهات واحولها لاوامر تنفيذ
بارك الله فيكم جميعا
كود:#property copyright "Abukareem"
#property link "abukareem"
//#include <Debug.mqh>
extern int MaxSL = 1100;
extern int MinSL = 400;
extern int MinMoveValue = 200;
extern double BBMaxOpenOrderDeviation = 1.5;
extern double BBSLDeviation = 1.0;
extern double BBScalpingDeviation = 3.0;
extern int SEFCPeriod = 12;
int buys=0;
int sells=0;
int ticket = -1; // valid when one ticket is opened
double orderSL;
double orderTP;
#define SLIPPAGE 2
#define ORDER_COMMENT "FPSS"
bool CalculateOpenOrders(string symbol) {
buys=0;
sells=0;
for (int i=0; i<OrdersTotal(); i++) {
if (!OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) break;
if (OrderCloseTime() != 0) continue;
if (StringFind(OrderComment(), ORDER_COMMENT) < 0) continue;
// if for tester only, all orders are ours
if (OrderSymbol()==Symbol()) {
if (OrderType()==OP_BUY) buys++;
if (OrderType()==OP_SELL) sells++;
ticket = OrderTicket();
orderSL = OrderStopLoss();
orderTP = OrderTakeProfit();
}
}
if (buys > 0 && sells > 0) {
Print("WARNING: opened both buy and sell orders");
ticket = -1;
}
return (buys>0 || sells>0);
}
datetime lastOrderCandle = 0;
void DoOpenOrder(int type, string typeS, double price, double sl, double tp) {
if (lastOrderCandle == Time[0]) {
return; // to protect Order/SL, Order/SL during one candle
}
lastOrderCandle = Time[0];
Alert("Trend change signalized, open "+typeS+" order, symbol: "+Symbol()+", price: "+price+", stoploss: "+sl, ", tp: "+tp + ", Comment: "+ORDER_COMMENT);
if (!IsTesting()) return;
int ot = OrderSend(Symbol(), type, MarketInfo(Symbol(), MODE_MINLOT), price, SLIPPAGE, sl, tp, ORDER_COMMENT, 0, 0, Yellow);
if (ot < 0) Print(GetLastError());
}
void DoCloseOrder(int type, string typeS, double price) {
static datetime lastCloseCandle = 0;
static int lastCloseTicket = -1;
if (Time[0] == lastCloseCandle && lastCloseTicket == ticket) return;
lastCloseTicket = ticket;
lastCloseCandle = Time[0];
lastOrderCandle = 0;
Alert("Trend change signalized, close "+typeS+" orders. Close price: "+price);
if (!IsTesting()) return;
for (int i=0; i<OrdersTotal(); i++) {
if (!OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) break;
if (OrderType() == type) {
if (!OrderClose(OrderTicket(), OrderLots(), price, SLIPPAGE, Orange)) {
Print("OrderClose", GetLastError());
}
}
}
}
void DoModifyOrder(int type, string typeS, double sl, double tp) {
//Debug("Modif1", ticket, type, sl, tp, orderSL, orderTP);
if (ticket < 0) return;
double minMove = Point*MinMoveValue;
if (MathAbs(sl-orderSL) < minMove && MathAbs(tp-orderTP) < minMove) return;
// if (lastOrderCandle == Time[0]) return; // do not modify in order period, ne have higher TP when (Ask/Bid+deviation)
// lastOrderCandle = Time[0]; // modify SL/TP once per period ??
Alert("Modify order: ", typeS, ", Move SL: ", sl, ", TP: ", tp);
if (!IsTesting()) return;
bool res = OrderModify(ticket, OrderOpenPrice(), sl, tp, 0, Yellow);
//Debug("Modify", type, ticket, sl, tp, res);
}
int init() {
//DebugOpen("", "FPS.dbg");
return(0);
}
void deinit() {
//DebugClose();
}
int start() {
if (Bars<100) {
return(0); // not enough data
}
// test for signal arrow, current signal, indicator has Signal=1 to draw arrows
int BBBuySignal = 0;
int BBSellSignal = 0;
double sl;
sl = iCustom(Symbol(), Period(), "BBand Stop Alert", BBSLDeviation, 2 /*buy arrow*/, 1);
if (sl != EMPTY_VALUE) { // buy arrow is at the lower band
BBBuySignal++;
// and the trend go on at leas in one sample, i.e. filter case when close price won't reach previous one a tall
if (Close[0] > Close[1]) {
BBBuySignal++;
}
} else {
sl = iCustom(Symbol(), Period(), "BBand Stop Alert", BBSLDeviation, 3 /*sell arrow*/, 1);
if (sl != EMPTY_VALUE) {
BBSellSignal++;
if (Close[0] < Close[1]) {
BBSellSignal++;
}
}
}
if (sl == EMPTY_VALUE) {
sl = iCustom(Symbol(), Period(), "BBand Stop Alert", BBSLDeviation, 0 /*buffer*/, 1); // previous sample not to be so strict
if (sl == EMPTY_VALUE) {
sl = iCustom(Symbol(), Period(), "BBand Stop Alert", BBSLDeviation, 1 /*buffer*/, 1);
}
}
double middle = iCustom(Symbol(), Period(), "BBand Stop Alert", BBSLDeviation, 6 /*middle trend */, 0);
double bbWidth = iCustom(Symbol(), Period(), "BBand Stop Alert", BBSLDeviation, 7 /*width */, 0);
// double tp = MathMax(BBScalpingDeviation*bbWidth, Point*MaxSL);
double tp = BBScalpingDeviation*bbWidth;
//Debug("middle/stp", sells, buys, BBBuySignal, BBSellSignal, Bid, middle, bbWidth, sl, tp, MathAbs(Bid-sl), MathAbs(Bid-sl) <= Point*MaxSL, MathAbs(Bid-sl) >= Point*MinSL, MathAbs(Bid-middle)<= BBMaxOpenOrderDeviation*bbWidth);
// trend detection may be anothe criterion
bool Bullish = iCustom(Symbol(), Period(), "SEFC084", SEFCPeriod, 1/* bull*/, 1) > 0; // is not bull then must be bear
if (CalculateOpenOrders(Symbol())) {
if ((Bid > sl /* in tester is applied on SL but has effect in manual mode */|| BBBuySignal >0) && sells > 0) {
DoCloseOrder(OP_SELL, "SELL", Ask);
sells = 0;
}
if ((Bid < sl || BBSellSignal >0) && buys > 0) {
DoCloseOrder(OP_BUY, "BUY", Bid);
buys = 0;
}
double sl2;
if (buys == 1) {
if (MathAbs(Bid-sl) < Point*MinSL) {
sl2 = orderSL;
}
else {
sl2 = MathMax(orderSL, sl);
}
DoModifyOrder(OP_BUY, "BUY", sl2, middle + tp);
}
if (sells == 1) {
if (MathAbs(Bid-sl) < Point*MinSL) {
sl2 = orderSL;
}
else {
sl2 = MathMin(orderSL, sl+Ask-Bid);
}
DoModifyOrder(OP_SELL, "SELL", sl2, middle - tp + Ask-Bid);
}
}
if (MathAbs(Bid-sl) <= Point*MaxSL && // do not open order when deviation is too high and price is already far from band
MathAbs(Bid-sl) >= Point*MinSL && // price is back in channel or channel is too narrow
MathAbs(Bid-middle)<= BBMaxOpenOrderDeviation*bbWidth // price is not too far, bounce danger
) {
if (BBBuySignal>1 && Bullish && buys == 0) {
DoOpenOrder(OP_BUY, "BUY", Ask, sl, middle + tp);
} else if (BBSellSignal>1 && !Bullish && sells == 0) {
DoOpenOrder(OP_SELL, "SELL", Bid, sl + Ask-Bid, middle - tp + Ask-Bid);
}
}
return(0);
}
كود PHP:if (!IsTesting()) return;

