//--- defines
#define BALANCE_LOSS_STOP 100.0 // Wert des Salden-Drawdowns, bei dem die Prüfung beendet wird
#define EQUITY_LOSS_STOP 100.0 // der Wert des Kapital-Drawdown, bei dem der Test beendet wird
//--- Eingabeparameter
input double InpLots = 0.1; // Lots
input uint InpStopLoss = 50; // Stop-Loss in Points
input uint InpTakeProfit = 150; // Take-Profit in Points
sinput ulong InpMagic = 123; // MagicNumber
sinput ulong InpDeviation = 5; // Abweichung
//--- globale Variable
CTrade trade; // Klasseninstanz von trade
CSymbolInfo symb; // Klasseninstanz des Symbols
CAccountInfo account; // Klasseninstanz des Kontos
...
//+------------------------------------------------------------------+
//| Expert Initialisierungsfunktion |
//+------------------------------------------------------------------+
int OnInit()
{
...
//--- erfolgreiche Initialisierung
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Tick-Funktion des Experten |
//+------------------------------------------------------------------+
void OnTick()
{
//--- update der aktuellen Kurse
if(!symb.RefreshRates())
return;
...
//--- wenn der Saldo oder das Kapital stärker gesunken sind als in den Makrosubstitutionen BALANCE_LOSS_STOP und EQUITY_LOSS_STOP angegeben,
//--- gilt der Test als nicht erfolgreich und die Funktion TesterStop() wird aufgerufen
//--- Prüfung auf einen Saldenverlust um mehr als BALANCE_LOSS_STOP
if(balance_prev!=account.Balance())
{
if(account.Balance()<balance_prev-BALANCE_LOSS_STOP)
{
PrintFormat("The initial balance of %.2f %s decreased by %.2f %s, and now has a value of %.2f %s. Stop testing.",balance_prev,account.Currency(),balance_prev-account.Balance(),account.Currency(),account.Balance(),account.Currency());
TesterStop();
/*
Ergebnis:
The initial balance of 10000.00 USD decreased by 100.10 USD, and now has a value of 9899.90 USD. Stop testing.
TesterStop() called on 9% of testing interval
*/
}
}
//--- Prüfung des Kapitalverlusts um mehr als EQUITY_LOSS_STOP
if(equity_prev!=account.Equity())
{
if(account.Equity()<equity_prev-EQUITY_LOSS_STOP)
{
PrintFormat("The initial equity of %.2f %s decreased by %.2f %s, and now has a value of %.2f %s. Stop testing.",equity_prev,account.Currency(),equity_prev-account.Equity(),account.Currency(),account.Equity(),account.Currency());
TesterStop();
/*
Ergebnis:
The initial equity of 10000.00 USD decreased by 100.10 USD, and now has a value of 9899.90 USD. Stop testing.
TesterStop() called on 9% of testing interval
*/
}
}
}
|