TesterWithdrawal

Eine spezielle Funktion, die während eines Tests Abhebungen emuliert. Sie kann von Geldmanagementsystemen verwendet werden.

bool  TesterWithdrawal(
   double money      // abzuhebende Summe 
   );

Parameter

money

[in]  Geldbetrag in der Kontowährung, der vom Konto abgebucht wird.

Rückgabewert

Liefert bei Erfolg true, ansonsten false.

Beispiel:

//--- defines
#define BALANCE_PROFIT_WITHDRAWAL   5  // der Wert des Saldengewinns, bei dem Mittel vom Konto des Testers abgezogen 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_op_sum;            // Gesamtbetrag der Saldenoperationen
uint        balance_op_total;          // Anzahl der Saldenoperationen
//+------------------------------------------------------------------+
//| Expert Initialisierungsfunktion                                  |
//+------------------------------------------------------------------+
int OnInit()
  {
   ...
//--- Sichern der Anfangswerte des Saldos
   balance_prev=account.Balance();
   balance_op_sum=0;
   balance_op_total=0;
//--- erfolgreiche Initialisierung
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Tick-Funktion des Experten                                       |
//+------------------------------------------------------------------+
void OnTick()
  {
//--- update der aktuellen Kurse
   if(!symb.RefreshRates())
      return;
   ...
 
//--- wenn der Saldengewinn den aktuellen Saldo um den in der Makrosubstitution BALANCE_PROFIT_WITHDRAWAL angegebenen Wert übersteigt,
//--- ist es notwendig, diese Mittel vom Konto abzuheben. Die Funktion TesterWithdrawal() aufrufen.
//--- Den Saldengewinn auf Überschreitung von BALANCE_PROFIT_WITHDRAWAL prüfen
   if(balance_prev!=account.Balance())
     {
      if(account.Balance()>balance_prev+BALANCE_PROFIT_WITHDRAWAL)
        {
         double profit=account.Balance()-balance_prev;
         PrintFormat("The account balance has been increased by %.2f %s. Need to withdraw these funds from the account.",profit,account.Currency());
         if(TesterWithdrawal(profit))
           {
            balance_op_total++;
            balance_op_summ+=profit;
            balance_prev=account.Balance();
            PrintFormat("Funds have been withdrawn from the account. Account balance: %.2f %s.",account.Balance(),account.Currency());
            PrintFormat("Total withdrawals: %lu. Amount of withdrawals: %.2f %s.",balance_op_total,balance_op_summ,account.Currency());
           }
         /*
        Ergebnis:
         The account balance has been increased by 21.00 USDNeed to withdraw these funds from the account.
         deal #13 balance -21.00 [withdrawaldone
         Funds have been withdrawn from the accountAccount balance10000.00 USD.
         Total withdrawals1Amount of withdrawals21.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 Abhebungen und deren Gesamtbetrag im Protokoll
   PrintFormat("%s: Maximum balance drawdown in money: %.2f %s. Total withdrawals: %lu. Amount of withdrawals: %.2f %s.",__FUNCTION__,ret,account.Currency(),balance_op_total,balance_op_summ,account.Currency());
//--- Ergebnisrückgabe
   return(ret);
   /*
  Ergebnis:
   OnTesterMaximum balance drawdown in money5188.50 USDTotal withdrawals2Amount of withdrawals36.00 USD.
   final balance 4867.50 USD
   OnTester result 5188.5
   */
  }

Siehe auch

TesterDeposit