[ARCHIVE!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Can't go anywhere without you - 4. - page 164

 

There is a function: OrderOpenTime().
You can compare its value for the last opened order with TimeCurrent() before opening a new position.

 
MikeM:
There is a function: TimeCurrent().
When opening a position, remember the value of this function, and when you want to open a new position, check the difference between the current value and the remembered value of this function.
Be more specific. Maybe you want to open a new position after a certain time, e.g: 15 min / 4 hours / 10 hours, 17 minutes and 38 seconds?
 
That is not my wish. It is an answer to your question of 12:08.
 
MikeM:
That is not my wish. It is an answer to your question of 12:08.
Ok. on the post click on "reply" I didn't realise it was an answer to my question. But good advice, I will do as you suggested. Thank you.
 
paladin80:
Ok. Click on "reply" in the post, I didn't realize it was an answer to my question. But the advice is good, I will do as you suggested. Thank you.

My understanding is that if you have more than one EA and there is no overlap in sending trade orders,

you can use this:

if(IsTradeContextBusy())Sleep(5000);//Торговый поток занят. Подождите 5 ceкунд

insert it before OrderSend();

 

Better still, here's a function for opening positions.

//+----------------------------------------------------------------------------+
//|  Автор    : Ким Игорь В. aka KimIV,  http://www.kimiv.ru                   |
//+----------------------------------------------------------------------------+
//|  Версия   : 10.04.2008                                                     |
//|  Описание : Открывает позицию по рыночной цене.                            |
//+----------------------------------------------------------------------------+
//|  Параметры:                                                                |
//|    sy - наименование инструмента   (NULL или "" - текущий символ)          |
//|    op - операция                                                           |
//|    ll - лот                                                                |
//|    sl - уровень стоп                                                       |
//|    tp - уровень тейк                                                       |
//|    mn - MagicNumber                                                        |
//|    co - комментарий                                                        |
//+----------------------------------------------------------------------------+
void OpenPosition(string sy, int op, double ll, double sl=0, double tp=0, int mn=0, string co="") {
  color    clOpen;
  datetime ot;
  double   pp, pa, pb;
  int      dg, err, it, ticket=0;

  if (sy=="" || sy=="0") sy=Symbol();
  if (op==OP_BUY) clOpen=clOpenBuy; else clOpen=clOpenSell;
  if (co=="") co=WindowExpertName()+" "+GetNameTF(Period());
  for (it=1; it<=NumberOfTry; it++) {
    if (!IsTesting() && (!IsExpertEnabled() || IsStopped())) {
      Print("OpenPosition(): Остановка работы функции");
      break;
    }
    while (!IsTradeAllowed()) Sleep(5000);
    RefreshRates();
    dg=MarketInfo(sy, MODE_DIGITS);
    pa=MarketInfo(sy, MODE_ASK);
    pb=MarketInfo(sy, MODE_BID);
    if (op==OP_BUY) pp=pa; else pp=pb;
    pp=NormalizeDouble(pp, dg);
    ot=TimeCurrent();
    if (MarketWatch)
      ticket=OrderSend(sy, op, ll, pp, Slippage, sl, tp, co, mn, 0, clOpen);
    else
      ticket=OrderSend(sy, op, ll, pp, Slippage, sl, tp, co, mn, 0, clOpen);
    if (ticket>0) {
      if (UseSound) PlaySound(SoundSuccess); break;
    } else {
      err=GetLastError();
      if (UseSound) PlaySound(SoundError);
      if (pa==0 && pb==0) Message("Проверьте в Обзоре рынка наличие символа "+sy);
      // Вывод сообщения об ошибке
      Print("Error(",err,") opening position: ",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==2 || err==64 || err==65 || err==133) {
        gbDisabled=True; break;
      }
      // Длительная пауза
      if (err==4 || err==131 || err==132) {
        Sleep(1000*300); break;
      }
      if (err==128 || err==142 || err==143) {
        Sleep(1000*66.666);
        if (ExistPositions(sy, op, mn, ot)) {
          if (UseSound) PlaySound(SoundSuccess); break;
        }
      }
      if (err==140 || err==148 || err==4110 || err==4111) break;
      if (err==141) Sleep(1000*100);
      if (err==145) Sleep(1000*17);
      if (err==146) while (IsTradeContextBusy()) Sleep(1000*11);
      if (err!=135) Sleep(1000*7.7);
    }
  }
  if (MarketWatch && ticket>0 && (sl>0 || tp>0)) {
    if (OrderSelect(ticket, SELECT_BY_TICKET)) ModifyOrder(-1, sl, tp);
  }
}
 
Good day! Question about trawl: I put a trailing stop of 25 pips. In the evening I come home from work, and the deal was not closed, although the day price was 70 pips away.
 
demid61:
Good day! Question about trawl: I put a trailing stop of 25 pips. In the evening I come home from work, and the deal was not closed, although the day price was 70 pips away.

Where is the code? Without the code - here.
 
demid61:

Good day! Question about the trawl. I set a trailing stop of 25 pips.

There's probably a little "and I'm turning off the computer" opus going on here.

 
sergeev:

there's probably a little "and shutting down the computer" opus going on here




:)) I thought it would work without a computer