hab mal versucht zu beginnen. Läuft leider noch nicht. Wo ist der Fehler?
//------------ TakeProfit Modify ---------------------
extern double TakeProfit = 10;
extern double StopLoss = 100;
int Multiplier;
double TPValue;
void OnInit() {
Multiplier = 1;
if(Digits == 3 || Digits == 5) Multiplier = 10;
if(Digits == 6) Multiplier = 100;
if(Digits == 7) Multiplier = 1000;
TakeProfit *= Multiplier;
StopLoss *= Multiplier;
TPValue = NormalizeDouble(TakeProfit * Point, Digits);
}
int start()
{
double sum = 0;
double sumlot = 0;
bool res;
for(int i = 0; i < OrdersTotal(); i++) {
if (OrderSelect(i, SELECT_BY_POS,MODE_TRADES)) {
if (OrderSymbol() == Symbol()) {
sum += OrderOpenPrice() * OrderLots();
sumlot += OrderLots();
if (OrderType() == OP_BUY) res = OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss(), NormalizeDouble(sum + TPValue, Digits), 0, Green);
if (OrderType() == OP_SELL) res = OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss(), NormalizeDouble(sum - TPValue, Digits), 0, Red);
}
}
}
sum /= sumlot;
}
|