TesterDeposit

테스트 중에 예금 자금을 모방하는 특수 기능. 일부 자금 관리 시스템에 사용될 수 있습니다.

bool  TesterDeposit(
   double money      // 예치된 합계
   );

매개변수

[in]  예금 통화로 계좌에 입금할 돈

값 반환

성공하면 true를, 그렇지 않으면 false를 반환합니다.

 

예:

//--- 정의
#define BALANCE_LOSS_DEPOSIT  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;                  // 거래 계정 클래스 인스턴스
...
double      balance_dep_summ;          // 잔액 충전 총액
uint        balance_dep_total;         // 잔액 충전 횟수
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   ...
//--- 초기 잔액 값을 저장합니다.
   balance_prev=account.Balance();
   balance_dep_summ=0;
   balance_dep_total=0;
//--- 초기화 성공
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//--- 현재 호가 업데이트
   if(!symb.RefreshRates())
      return;
   ...
 
//--- 잔액이 BALANCE_LOSS_DEPOSIT 매크로 대체에 설정된 것보다 더 많이 떨어진 경우,
//--- 계정을 충전하고 TesterDeposit() 함수를 호출해야 합니다.
//--- BALANCE_LOSS_DEPOSIT 이상의 잔액 손실을 확인
   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());
           }
         /*
         Result:
         The initial balance of 10000.00 USD decreased by 116.00 USDIt is necessary to make a deposit to the account for 116.00 USD.
         deal #45 balance 116.00 [depositdone
         Funds have been deposited into the accountAccount balance10000.00 USD.
         Total deposits1Amount of deposits116.00 USD.
         */
        }
     }
  }
//+------------------------------------------------------------------+
//| Tester function                                                  |
//+------------------------------------------------------------------+
double OnTester()
  {
//--- 재무적 측면에서 최대 잔액 감소를 출력 핸들러 값으로 설정합니다.
   double ret=TesterStatistics(STAT_BALANCE_DD);
//--- 인출, 예금 수 및 총 금액에 대한 메시지를 로그에 표시합니다.
   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());
//--- 결과 반환
   return(ret);
   /*
   Result:
   OnTesterMaximum balance drawdown in money5188.50 USDTotal deposits46Amount of deposits5128.50 USD.
   final balance 4867.50 USD
   OnTester result 5188.5
   */
  }

추가 참조

TesterWithdrawal