//--- tanımlar
#define BALANCE_PROFIT_WITHDRAWAL 5 // sınayıcıdaki hesaptan çekilecek bakiye kârı değeri
//--- girdi parametreleri
input double InpLots = 0.1; // Lot
input uint InpStopLoss = 50; // Puan cinsinden Zararı Durdur
input uint InpTakeProfit = 150; // Puan cinsinden Kârı Al
sinput ulong InpMagic = 123; // Sihirli sayı
sinput ulong InpDeviation = 5; // Sapma
//--- global değişkenler
CTrade trade; // işlem sınıfı örneği
CSymbolInfo symb; // sembol sınıfı örneği
CAccountInfo account; // işlem hesabı sınıfı örneği
...
double balance_op_sum; // baki̇ye i̇şlemleri̇ni̇n toplam miktarı
uint balance_op_total; // toplam bakiye işlemi sayısı
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
...
//--- başlangıç bakiye değerlerini kaydet
balance_prev=account.Balance();
balance_op_sum=0;
balance_op_total=0;
//--- başarılı başlatma
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//--- mevcut fiyatları güncelle
if(!symb.RefreshRates())
return;
...
//--- bakiye kârı mevcut bakiyeyi BALANCE_PROFIT_WITHDRAWAL makro ikamesinde belirtilen değer kadar aşarsa,
//--- bu para miktarının hesaptan çekilmesi gerekir. TesterWithdrawal() fonksiyonu çağrılır.
//--- bakiye kârının BALANCE_PROFIT_WITHDRAWAL değerini aşıp aşmadığını kontrol et
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());
}
/*
Sonuç:
The account balance has been increased by 21.00 USD. Need to withdraw these funds from the account.
deal #13 balance -21.00 [withdrawal] done
Funds have been withdrawn from the account. Account balance: 10000.00 USD.
Total withdrawals: 1. Amount of withdrawals: 21.00 USD.
*/
}
}
}
//+------------------------------------------------------------------+
//| Tester function |
//+------------------------------------------------------------------+
double OnTester()
{
//--- parasal olarak maksimum bakiye düşüşünü çıktı işleyici değeri olarak ayarla
double ret=TesterStatistics(STAT_BALANCE_DD);
//--- günlükte düşüş, toplam para çekme sayısı ve toplam para çekme miktarı hakkında bir mesaj görüntüle
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());
//--- sonucu geri döndür
return(ret);
/*
Sonuç:
OnTester: Maximum balance drawdown in money: 5188.50 USD. Total withdrawals: 2. Amount of withdrawals: 36.00 USD.
final balance 4867.50 USD
OnTester result 5188.5
*/
}
|