TesterStop

프로그램 작업 명령은 테스트할 때 제공합니다.

void  TesterStop();

값 반환

반환 값 없음.

주의

TesterStop() 기능은 예를 들어 지정된 수의 손실 거래 또는 사전 설정된 인출 수준에 도달할 때 테스트 에이전트에서 EA를 정기적으로 조기 종료하도록 고안되었습니다.

TesterStop() 호출은 정상적인 테스트 완료로 간주되므로 OnTester() 함수가 호출되고 전체 누적 거래 통계 및 최적화 기준 값이 전략 테스터에 제출됩니다.

전략 테스터에서 ExpertRemove()을 호출하는 것은 정상적인 테스트 완료를 의미하며 거래 통계를 얻을 수 있지만 EA는 에이전트의 메모리에서 언로드 됩니다. 이 경우 다음 매개변수 집합에서 패스를 수행하려면 프로그램을 다시 로드하는 데 시간이 필요합니다. 따라서 TesterStop()는 테스트의 조기 완료를 위한 기본 옵션입니다.

 

예:

//--- 정의
#define BALANCE_LOSS_STOP  100.0       // 테스트가 중단되는 잔액 감소 값
#define EQUITY_LOSS_STOP   100.0       // 테스트가 중단되는 실시간 잔고 감소 가치
 
//--- 입력 매개변수
input  double  InpLots        =  0.1;  // 랏
input  uint    InpStopLoss    =  50;   // 스탑로스 포인트로
input  uint    InpTakeProfit  =  150;  // 이익 실현 포인트로
sinput ulong   InpMagic       =  123;  // 매직 넘버
sinput ulong   InpDeviation   =  5;    // 편차
//--- 글로벌 변수
CTrade      trade;                     // 거래 클래스 인스턴스
CSymbolInfo symb;                      // 심볼 클래스 인스턴스
CAccountInfo account;                  // 거래 계정 클래스 인스턴스
...
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   ...
//--- 초기화 성공
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//--- 현재 호가 업데이트
   if(!symb.RefreshRates())
      return;
   ...
 
//--- 잔액이나 실시간 잔고사 BALANCE_LOSS_STOP 및 EQUITY_LOSS_STOP 매크로 대체에 표시된 것보다 더 많이 떨어진 경우,
//--- 테스트가 실패한 것으로 간주되고 TesterStop() 함수가 호출됩니다.
//--- 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
         */
        }
     }
//--- 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
         */
        }
     }
  }

추가 참조

프로그램 실행, 트레이딩 전략 테스트, ExpertRemove, SetReturnError