TesterStop

Envoie la commande de fin du programme lors d'un test.

void  TesterStop();

Valeur de Retour

Aucune valeur de retour.

Note

La fonction TesterStop() est conçue pour la fin prématurée d'un EA sur un agent de test — par exemple, lorsqu'un nombre spécifié de trades perdants ou un niveau de drawdown sont atteints.

Un appel à TesterStop() est considéré comme étant une fin normale d'un test, la fonction OnTester() est donc appelée et les statistiques complètes de trading ainsi que la valeur du critère d'optimisation sont renvoyées au strategy tester.

Un appel à ExpertRemove() dans le strategy tester signifie également la fin normale du test et permet d'obtenir les statistiques de trading, mais l'EA est enlevé de la mémoire de l'agent. Dans ce cas, effectuer une passe de l'ensemble suivant de paramètres nécéssite plus de temps afin de recharger le programme. TesterStop() est donc l'option préférée pour une fin prématurée d'un test.

Example:

//--- defines
#define BALANCE_LOSS_STOP  100.0       // value of the balance drawdown, at which testing is stopped
#define EQUITY_LOSS_STOP   100.0       // value of the equity drawdown, at which testing is stopped
 
//--- input parameters
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;    // deviation
//--- global variables
CTrade      trade;                     // trade class instance
CSymbolInfo symb;                      // symbol class instance
CAccountInfo account;                  // trading account class instance
...
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   ...
//--- successful initialization
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//--- update current quotes
   if(!symb.RefreshRates())
      return;
   ...
 
//--- if the balance or equity have dropped more than indicated in the BALANCE_LOSS_STOP and EQUITY_LOSS_STOP macro substitutions,
//--- the test is considered unsuccessful and the TesterStop() function is called
//--- check for loss of balance by more than 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();
         /*
         Result:
         The initial balance of 10000.00 USD decreased by 100.10 USDand now has a value of 9899.90 USDStop testing.
         TesterStop() called on 9of testing interval
         */
        }
     }
//--- check the loss of equity by more than 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();
         /*
         Result:
         The initial equity of 10000.00 USD decreased by 100.10 USDand now has a value of 9899.90 USDStop testing.
         TesterStop() called on 9of testing interval
         */
        }
     }
  }

Voir également

Exécution du Programme, Tester des Stratégies de Trading, ExpertRemove, SetReturnError