//--- tanımlar
#define BALANCE_LOSS_STOP 100.0 // testin durdurulduğu bakiye düşüşünün değeri
#define EQUITY_LOSS_STOP 100.0 // testin durdurulduğu varlık düşüşünün 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
...
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
...
//--- başarılı başlatma
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//--- mevcut fiyatları güncelle
if(!symb.RefreshRates())
return;
...
//--- bakiye veya varlık BALANCE_LOSS_STOP ve EQUITY_LOSS_STOP makro ikamelerinde belirtilenden daha fazla düşmüşse,
//--- test başarısız olarak kabul edilir ve TesterStop() fonksiyonu çağrılır
//--- BALANCE_LOSS_STOP değerinden daha fazla bakiye kaybı olup olmadığını kontrol et
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();
/*
Sonuç:
The initial balance of 10000.00 USD decreased by 100.10 USD, and now has a value of 9899.90 USD. Stop testing.
TesterStop() called on 9% of testing interval
*/
}
}
//--- EQUITY_LOSS_STOP değerinden daha fazla varlık kaybı olup olmadığını kontrol et
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();
/*
Sonuç:
The initial equity of 10000.00 USD decreased by 100.10 USD, and now has a value of 9899.90 USD. Stop testing.
TesterStop() called on 9% of testing interval
*/
}
}
}
|