TesterWithdrawal

La funzione speciale per emulare il l'operazione di prelievo del denaro nel processo di testing. Può essere utilizzata in alcuni sistemi di gestione del risparmio.

bool  TesterWithdrawal(
   double money      // la somma da prelevare
   );

Parametri

denaro

[in] La somma di denaro che abbiamo bisogno di ritirare (nella valuta di deposito).

Valore restituito

In caso di successo, restituisce true, in caso contrario - false.

Esempio:

//--- define
#define BALANCE_PROFIT_WITHDRAWAL   5  // the value of the balance profit, at which funds are withdrawn from the account in the tester
 
//-- parametri di input
input  double  InpLots        =  0.1;  // Lotti
input  uint    InpStopLoss    =  50;   // Stop loss in punti
input  uint    InpTakeProfit  =  150;  // Take Profit in punti
sinput ulong   InpMagic       =  123;  // Numero Magico
sinput ulong   InpDeviation   =  5;    // Deviazione
//---variabili globali
CTrade      trade;                     // istanza della classe di trading
CSymbolInfo symb;                      // istanza della classe del simbolo
CAccountInfo account;                  // istanza di classe del conto di trading
...
double      balance_op_sum;            // total amount of balance operations
uint        balance_op_total;          // number of balance operations
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   ...
//-- salvare i valori del saldo iniziale
   balance_prev=account.Balance();
   balance_op_sum=0;
   balance_op_total=0;
//-- inizializzazione avvenuta con successo
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//-- aggiornare le quotazioni attuali
   if(!symb.RefreshRates())
      return;
   ...
 
//-- se il profitto del saldo supera il saldo corrente del valore specificato nella macro sostituzione BALANCE_PROFIT_WITHDRAWAL,
//-- è necessario prelevare questi fondi dal conto. Chiamare la funzione TesterWithdrawal().
//-- controllare il profitto del saldo per il superamento di BALANCE_PROFIT_WITHDRAWAL
   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());
           }
         /*
        Risultato:
         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 function                                                  |
//+------------------------------------------------------------------+
double OnTester()
  {
//--- impostare il drawdown massimo del saldo in termini monetari come valore del gestore dell'output
   double ret=TesterStatistics(STAT_BALANCE_DD);
//-- visualizzare un messaggio sul drawdown, il numero di prelievi e il loro importo totale nel registro
   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());
//-- restituire il risultato
   return(ret);
   /*
  Risultato:
   OnTesterMaximum balance drawdown in money5188.50 USDTotal withdrawals2Amount of withdrawals36.00 USD.
   final balance 4867.50 USD
   OnTester result 5188.5
   */
  }