Hallo traderdoc,
kannst du mir bitte nochmal helfen?
Die Berechnung funktioniert jetzt. Zumindest wenn ich es in einem abgespeckten Code teste. Nun bin ich am verzweifeln. Ich bekomme im Tester immer einen "zero divide". Wie bekomme ich den StopLoss in die Berechnung? Muss der vorher noch in ein anderes Format als double geändert werden? Der bringt mir hier bei stopLoss den Fehler:
2021.01.07 12:49:13.902 2020.12.28 00:00:00 EA_EMA510v0.006 EURUSD',H1: zero divide in 'EA_EMA510v0.006.mq4' (138,83)
double lotSize = NormalizeDouble(AccountEquity() * riskPercent / 100 / stopLoss / PV, LS);
HTML-Code:
//+------------------------------------------------------------------+
//| Sell Stop Order |
//+------------------------------------------------------------------+
if(signal=="Verkaufen" && OrdersTotal()==0)
stopLoss=High[LastCandleHigh]+15*_Point;
double PV = MarketInfo(Symbol(), MODE_TICKVALUE);
int LS = (MarketInfo(Symbol(),MODE_LOTSTEP) == 0.1) + 2 * (MarketInfo(Symbol(),MODE_LOTSTEP) == 0.01); //Schrittweite der Lots
double lotSize = NormalizeDouble(AccountEquity() * riskPercent / 100 / stopLoss / PV, LS);
ticket=OrderSend
(
_Symbol, // string symbol
OP_SELLSTOP, // int operation
lotSize, // Volume
Low[1]-5*_Point, // Preis (Bid oder Ask)
10, // Slippage
stopLoss, // SL Low- 1,5 Punkt
Low[1]-TakeProfit/10000, // TP double take profit
"EMA510 Sell 006", // string comment
MagicID, // int magic number
0, // datetime pending order expiration
clrRed // color
);
//+------------------------------------------------------------------+
//| Buy Stop Order |
//+------------------------------------------------------------------+
if(signal=="Kaufen" && OrdersTotal()==0)
stopLoss=Low[LastCandleLow]-5*_Point;
PV = MarketInfo(Symbol(), MODE_TICKVALUE);
LS = (MarketInfo(Symbol(),MODE_LOTSTEP) == 0.1) + 2 * (MarketInfo(Symbol(),MODE_LOTSTEP) == 0.01); //Schrittweite der Lots
lotSize = NormalizeDouble(AccountEquity() * riskPercent / 100 / stopLoss / PV, LS);
ticket=OrderSend
(
_Symbol,
OP_BUYSTOP, // int operation
lotSize, // Volume
High[1]+10*_Point, // Preis (Bid oder Ask)
10, // Slippage
stopLoss, // SL Low- 0,5 Punkt
High[1]+TakeProfit/10000, // TP double take profit
"EMA510 Buy 006", // string comment
MagicID, // int magic number
0, // datetime pending order expiration
clrGreen // color
);