Hallo,
der folgende Code ist der vollständige EA um den es geht. Wenn ich beispielsweise den EA auf EURUSD installiere, dann setzt er nur TrailingStops bei EURUSD mit der MagicNumber von 1000, doch warum ignoriert der EA offene Order bei beispielsweise GBPUSD mit MagicNumber 1000? Die MagicNumber ist natürlich immer gleich. Ich lasse die Order mit einer MagicNumber von 1000 jeweils mit ein Buy und Sell - Script eröffnen.
Mit freundlichen Grüßen
Elfenstein
PHP-Code:
#property copyright ""
#property link ""
extern int TrailingStop = 20;
extern int Profit = 80;
extern int TrailingStep = 2;
int MN = 1000;
int i, r;
double stopcal;
int init() {
return(0);
}
int deinit() {
return(0);
}
int start() {
for(i = 0; i < OrdersTotal(); i++) {
r = OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if (OrderMagicNumber() == MN) {
if (OrderType() == OP_BUY) {
if (Ask - OrderOpenPrice() > Profit * Point) {
if (OrderStopLoss() < Ask - (TrailingStop + TrailingStep) * Point) {
stopcal = Ask - (TrailingStop * Point);
if (stopcal > OrderStopLoss()) r = OrderModify(OrderTicket(),OrderOpenPrice(),stopcal,OrderTakeProfit(),0,0);
}
}
}
if (OrderType() == OP_SELL) {
if (OrderOpenPrice() - Bid > Profit * Point) {
if (OrderStopLoss() > Bid + (TrailingStop + TrailingStep) * Point) {
stopcal = Bid + (TrailingStop * Point);
if (stopcal < OrderStopLoss()) r = OrderModify(OrderTicket(),OrderOpenPrice(),stopcal,OrderTakeProfit(),0,0);
}
}
}
}
}
return(0);
}