[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 634

 
artmedia70:

One more thing...

When testing, I removed all the indulgences that are automatically loaded from the template (the template is named after an EA and is automatically loaded when testing) from the chart window.

In the tester's journal it is constantly written about successful loading of a custom indulgence and immediately follows with a record of its deletion. And so it goes on during the whole testing...

Is it normal or is it a bad thing?

How can I fix it?


I may be late to reply, but I have faced such a situation myself. It's not good :)

I have such records in the magazine, when calling a custom indicator through iCustom(), I forgot to pass one of the parameters by mistake. The compiler doesn't track these errors, even during the test since the indicator name is correct, MT writes that everything is loaded successfully, but the number of parameters is not checked, and since the parameters are specified incorrectly, an error occurs in the indicator and it is unloaded immediately. I have noticed that the test runs slowly and the log is the same:

01:11:13 2000.01.03 02:00 EMMA_Update_2 EURUSD,M15: loaded successfully

01:11:13 2000.01.03 02:00 EMMA_Update_2 EURUSD,M15: removed

01:11:13 2000.01.03 02:01 EMMA_Update_2 EURUSD,M15: loaded successfully

01:11:13 2000.01.03 02:01 EMMA_Update_2 EURUSD,M15: removed

I started to look into it and found such a problem because of my inattention, I tried to put/remove indicator from it "on the fly", I didn't see any "animation" in the log on this occasion, the problem was with iCustom(), so check it just in case :)

 

ToLik_SRGV:

all the problem was with iCustom(), so check just in case :)

That's right. it was due to wrong number of arguments.
 

Give advice on how to set the expiry date of a pending order.

Somehow it doesn't seem to want to work for me, and there is not much information about it in the handbook.

If you can give me an example.

Thank you in advance.

 
ToLik_SRGV:

Late reply, probably, but I've come across this myself. This is not good :)

I have such records in the journal, when calling a custom indicator through iCustom(), I forgot to pass one of the parameters by mistake. The compiler doesn't track these errors, even during the test since the indicator name is correct, MT writes that everything is loaded successfully, but the number of parameters is not checked, and since the parameters are specified incorrectly, an error occurs in the indicator and it is unloaded immediately. I have noticed that the test runs slowly and the log is the same:

01:11:13 2000.01.03 02:00 EMMA_Update_2 EURUSD,M15: loaded successfully

01:11:13 2000.01.03 02:00 EMMA_Update_2 EURUSD,M15: removed

01:11:13 2000.01.03 02:01 EMMA_Update_2 EURUSD,M15: loaded successfully

01:11:13 2000.01.03 02:01 EMMA_Update_2 EURUSD,M15: removed

I started to look into it and found such a problem because of my inattention, I tried to put/remove indicator from it "on the fly", I didn't see any "animation" in the log on this occasion, the problem was with iCustom(), so check it just in case :)

No, not too late... Just right, thank you.
 
kwadrad:

Give advice on how to set the expiry date of a pending order.

Somehow it doesn't seem to want to work for me, and there is not much information about it in the handbook.

If you can give me an example.

Thank you in advance.

Here. That's what I do...

   double   tp,PriceOpn,PriceTake;
   string   sy=Symbol();
   double pa=MarketInfo(sy, MODE_ASK);
   double pb=MarketInfo(sy, MODE_BID);
   double po=MarketInfo(sy, MODE_POINT);

   Magic=511;
   Lots_New=NormalizeLot(Lots/2, False, NULL);
         
   PriceOpn  = NormalizePrice(pa+DistORD*po, NULL);
   PriceTake = NormalizePrice(pa+(DistORD+tp)*po, NULL);
 //------------------------------------------------------------------
   SetOrder(NULL, OP_BUYSTOP, Lots_New, PriceOpn, 0, PriceTake, Magic, TimeCurrent()+12*60); // 12 часов срок его жизни...
 //------------------------------------------------------------------
//==============================================================================================

//+----------------------------------------------------------------------------+
//|  Автор    : Ким Игорь В. aka KimIV,  http://www.kimiv.ru                   |
//+----------------------------------------------------------------------------+
//|  Версия   : 02.08.2008                                                     |
//|  Описание : Установка ордера.                                              |
//+----------------------------------------------------------------------------+
//|  Параметры:                                                                |
//|    sy - наименование инструмента   (NULL или "" - текущий символ)          |
//|    op - операция                                                           |
//|    ll - лот                                                                |
//|    pp - цена                                                               |
//|    sl - уровень стоп                                                       |
//|    tp - уровень тейк                                                       |
//|    mn - Magic Number                                                       |
//|    co - комментарий                                                        |
//|    ex - Срок истечения                                                     |
//+----------------------------------------------------------------------------+
void SetOrder(string sy, int op, double ll, double pp,
              double sl=0, double tp=0, int mn=0, string co="", datetime ex=0) {
  color    cl=IIFc(op==OP_BUYLIMIT || op==OP_BUYSTOP, clOpenBuy, clOpenSell);
  datetime ot;
  double   pa, pb, mp;
  int      err, it, ticket, msl;

  if (sy=="" || sy=="0") sy=Symbol();
  msl=MarketInfo(sy, MODE_STOPLEVEL);
  if (co=="") co=WindowExpertName()+" "+GetNameTF(Period());
  if (ex>0 && ex<TimeCurrent()) ex=0;
  for (it=1; it<=NumberOfTry; it++) {
    if (!IsTesting() && (!IsExpertEnabled() || IsStopped())) {
      Print("SetOrder(): Остановка работы функции");
      break;
    }
    while (!IsTradeAllowed()) Sleep(5000);
    RefreshRates();
    ot=TimeCurrent();
    ticket=OrderSend(sy, op, ll, pp, Slippage, sl, tp, co, mn, ex, cl);
    if (ticket>0) {
      if (UseSound) PlaySound(SoundSuccess); break;
    } else {
      err=GetLastError();
      if (err==128 || err==142 || err==143) {
        Sleep(1000*66);
        if (ExistOrders(sy, op, mn, ot)) {
          if (UseSound) PlaySound(SoundSuccess); break;
        }
        Print("Error(",err,") set order: ",ErrorDescription(err),", try ",it);
        continue;
      }
      if (UseSound) PlaySound(SoundError);
      mp=MarketInfo(sy, MODE_POINT);
      pa=MarketInfo(sy, MODE_ASK);
      pb=MarketInfo(sy, MODE_BID);
      if (pa==0 && pb==0) Message("SetOrder(): Проверьте в обзоре рынка наличие символа "+sy);
      Print("Error(",err,") set order: ",ErrorDescription(err),", try ",it);
      Print("Ask=",pa,"  Bid=",pb,"  sy=",sy,"  ll=",ll,"  op=",GetNameOP(op),
            "  pp=",pp,"  sl=",sl,"  tp=",tp,"  mn=",mn);
      // Неправильные стопы
      if (err==130) {
        // Корректировка ценовых уровней
        if (modeSetOrders==1) {
          Sleep(1000*5.3);
          switch (op) {
            case OP_BUYLIMIT:
              if (pp>pa-msl*mp) pp=pa-msl*mp;
              if (sl>pp-(msl+1)*mp) sl=pp-(msl+1)*mp;
              if (tp>0 && tp<pp+(msl+1)*mp) tp=pp+(msl+1)*mp;
              break;
            case OP_BUYSTOP:
              if (pp<pa+(msl+1)*mp) pp=pa+(msl+1)*mp;
              if (sl>pp-(msl+1)*mp) sl=pp-(msl+1)*mp;
              if (tp>0 && tp<pp+(msl+1)*mp) tp=pp+(msl+1)*mp;
              break;
            case OP_SELLLIMIT:
              if (pp<pb+msl*mp) pp=pb+msl*mp;
              if (sl>0 && sl<pp+(msl+1)*mp) sl=pp+(msl+1)*mp;
              if (tp>pp-(msl+1)*mp) tp=pp-(msl+1)*mp;
              break;
            case OP_SELLSTOP:
              if (pp>pb-msl*mp) pp=pb-msl*mp;
              if (sl>0 && sl<pp+(msl+1)*mp) sl=pp+(msl+1)*mp;
              if (tp>pp-(msl+1)*mp) tp=pp-(msl+1)*mp;
              break;
          }
          Print("SetOrder(): Скорректированы ценовые уровни");
          continue;
        }
        // Вход по текущим ценам
        if (modeSetOrders==2) {
          Print("SetOrder(): Вход по текущим ценам");
          if (op==OP_BUYLIMIT || op==OP_BUYSTOP) OpenPosition(sy, OP_BUY, ll, sl, tp, mn, co);
          if (op==OP_SELLLIMIT || op==OP_SELLSTOP) OpenPosition(sy, OP_SELL, ll, sl, tp, mn, co);
          break;
        }
      }
      // Блокировка работы советника
      if (err==2 || err==64 || err==65 || err==133) {
        gbDisabled=True; break;
      }
      // Длительная пауза
      if (err==4 || err==131 || err==132) {
        Sleep(1000*300); break;
      }
      // Слишком частые запросы (8) или слишком много запросов (141)
      if (err==8 || err==141) Sleep(1000*100);
      if (err==139 || err==140 || err==148) break;
      // Ожидание освобождения подсистемы торговли
      if (err==146) while (IsTradeContextBusy()) Sleep(1000*11);
      // Обнуление даты истечения
      if (err==147) {
        ex=0; continue;
      }
      if (err!=135 && err!=138) Sleep(1000*7.7);
    }
  }
}
 
artmedia70:

Here. That's what I do...




О. Thank you.

You have to understand, this is the time frame in minutes from the opening?

 
kwadrad:


О. Thank you.

I should understand this is the time frame in minutes from the opening?

Yes, in the example of the 12 hour life span... 12*60 minutes
 

I know it may seem to be OffTop, but for me, as a beginner in writing EA (and programming in general, not considering my experience of assembler programming for Spectrum twenty years ago), my question, but rather.... come on, it's just a question, would be right on point:

While testing EA on a two year history, I noticed months where there is a very strong drawdown. This is a question for old timers: what methods of dealing with drawdowns are available as such, what can be advised in your opinion the most effective.

I'm from my own vantage point, I see two methods so far:

1. Freeze all trading when equity drawdown exceeds by a certain number of percent and
1.1 for each position. After its break-even point, connect a trailing stop and fix the stop at a small distance from Ask/Bid, thereby securing a small profit and then pull stops after the price, partially closing positions (to release funds) when a certain number of points are gained.
1.2. After the equity has risen by a certain percentage, slowly start trading...

2. On the contrary, having disabled the main trade, we have to use the half lot, but with a large amount of orders, strictly following the trend with a small trailing stop after the break-even point.

I think the first way will prevent from further big decrease of equity but you have to wait a long time for the market to approach the orders
the second way will eat margin but in case of short-term positions you can quickly add some to the money...

So far I see only two such opposite ways.

What do you advise, my comrades? Any, even the most, at first glance "crazy-nonsense" thoughts and suggestions are welcome...

Thanks in advance :)

 
Doesn't the tester allow you to test on more than the daily?
 
artmedia70:
Does the tester not allow you to test on more than the daily?


Ы

Are you preparing an EA for the interbank?

Reason: