//--- defines #define BALANCE_LOSS_DEPOSIT 100.0 // Wert des Drawdowns des Saldos, zu dem die Geldmittel auf das Konto des Testers eingezahlt werden //--- 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; // Magic-Mummer sinput ulong InpDeviation = 5; // Abweichung //--- globale Variable CTrade trade; // Klasseninstanz von trade CSymbolInfo symb; // Klasseninstanz des Symbols CAccountInfo account; // Klasseninstanz des Kontos ... double balance_dep_summ; // Gesamtbetrag der Kontostanderhöhungen uint balance_dep_total; // Anzahl der Kontostanderhöhungen //+------------------------------------------------------------------+ //| Expert Initialisierungsfunktion | //+------------------------------------------------------------------+ int OnInit() { ... //--- Sichern der Anfangswerte des Saldos balance_prev=account.Balance(); balance_dep_summ=0; balance_dep_total=0; //--- erfolgreiche Initialisierung return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Tick-Funktion des Experten | //+------------------------------------------------------------------+ void OnTick() { //--- update der aktuellen Kurse if(!symb.RefreshRates()) return; ... //--- wenn der Saldo stärker gesunken ist, als in der Makrosubstitution BALANCE_LOSS_DEPOSIT angegeben, //--- ist es notwendig, das Konto aufzuladen und die Funktion TesterDeposit() aufzurufen //--- Prüfung, ob der Saldo um mehr als BALANCE_LOSS_DEPOSIT gesunken ist if(balance_prev!=account.Balance()) { if(account.Balance()<balance_prev-BALANCE_LOSS_DEPOSIT) { double loss=balance_prev-account.Balance(); PrintFormat("The initial balance of %.2f %s decreased by %.2f %s. It is necessary to make a deposit to the account for %.2f %s.",balance_prev,account.Currency(),loss,account.Currency(),loss,account.Currency()); if(TesterDeposit(loss)) { balance_dep_total++; balance_dep_summ+=loss; balance_prev=account.Balance(); PrintFormat("Funds have been deposited into the account. Account balance: %.2f %s.",account.Balance(),account.Currency()); PrintFormat("Total deposits: %lu. Amount of deposits: %.2f %s.",balance_dep_total,balance_dep_summ,account.Currency()); } /* Ergebnis: The initial balance of 10000.00 USD decreased by 116.00 USD. It is necessary to make a deposit to the account for 116.00 USD. deal #45 balance 116.00 [deposit] done Funds have been deposited into the account. Account balance: 10000.00 USD. Total deposits: 1. Amount of deposits: 116.00 USD. */ } } } //+------------------------------------------------------------------+ //| Tester Funktion | //+------------------------------------------------------------------+ double OnTester() { //--- der maximale Drawdown des Saldos in Geldwerten für den Output-Handler festlegen double ret=TesterStatistics(STAT_BALANCE_DD); //--- Anzeige einer Meldung über den Drawdown, die Anzahl der Einzahlungen und deren Gesamtbetrag im Log PrintFormat("%s: Maximum balance drawdown in money: %.2f %s. Total deposits: %lu. Amount of deposits: %.2f %s.",__FUNCTION__,ret,account.Currency(),balance_dep_total,balance_dep_summ,account.Currency()); //--- Ergebnisrückgabe return(ret); /* Ergebnis: OnTester: Maximum balance drawdown in money: 5188.50 USD. Total deposits: 46. Amount of deposits: 5128.50 USD. final balance 4867.50 USD OnTester result 5188.5 */ } |