Un nun der 2. Versuch einen ordendlichen Code hinzulegen. Ich weiss auch nicht was mit meinem iPad los war. Die OrderModify()-Zeile kann ich leider aufgrund der Länge nicht bündig nach rechts schieben.
Code:
RefreshRates();
double ppoint = MarketInfo(OrderSymbol(), MODE_POINT);
int total = OrdersTotal();
double pBid = MarketInfo(OrderSymbol(), MODE_BID);
double pAsk = MarketInfo(OrderSymbol(), MODE_ASK);
double priceNew;
for(int i = 0; i < total; i++) {
if (!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) {
Print("Error = ", GetLastError());
return;
}
OrderPrint();
if (OrderType() == OP_BUYSTOP) {
if (pBid - OrderOpenPrice() > 50*ppoint) {
priceNew = (pBid - 50*ppoint);
OrderModify(OrderTicket(),priceNew,0,OrderStopLoss(),OrderTakeProfit());
Print("ModifiedOrder");
}
}
if (OrderType() == OP_SELLSTOP) {
if (OrderOpenPrice() - pAsk > 50*ppoint) {
priceNew = (pAsk + 50*ppoint);
OrderModify(OrderTicket(),priceNew,0,OrderStopLoss(),OrderTakeProfit());
Print("ModifiedOrder");
}
}
}