[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 362

 
Rom1:

Hello! I can't connect MT4 to the server... Who can tell me what to do? I tried to contact support twice, but they were all just like this: turn off firewall, check internet, etc. I'm fine with internet, software was added to firewall exceptions list. In general I tried to disable it and antivirus, but no result.
I've tried setting server parameters manually.

I keep seeing "No connection" on the bottom. I haven't found any answer to this question on forum. By the way, my other traders programs are working fine. Why is MT4 not connecting, what prevents it from doing that? Thanks in advance for the help.

maybe an old version, try reinstalling mt4, from broker's website, if alpari, download, and install in the same folder, it will automatically update to the current build.
 
how to make indicators from different timeframes be taken into account in the tester, and is this even possible?
 
vilard:
how to make indicators from different timeframes be taken into account in the tester, and is this even possible?
What does it mean to consider an indicator in the Strategy Tester? (1) Maybe the indicator of another timeframe should be displayed during visualization, or (2) in the EA code, in the indicator function you should calculate a value for another timeframe?
 
vilard:
how to make indicators from different timeframes be taken into account in the tester, and is this even possible?

possible: https://docs.mql4.com/ru/indicators/icustom

https://docs.mql4.com/ru/constants/timeframes

 

The EA is designed to generate signals on bars with index 1 and 2 (i.e. open and close orders at the opening of a new bar).

In the tester, it alternately generates errors 138 and 4051 (it seems to be swearing at ticket) for OrderClose.

Please help me to solve this problem.

   if(Mas_Ord_New[0][0]!=0)
    {
     if(Signal==2)
      {
        for(i=0; i<=Mas_Ord_New[0][0]; i++)
         {
           ticket=Mas_Ord_New[i][4];
           lts=Mas_Ord_New[i][5];
           Ans=OrderClose(ticket,lts,Bid,5);
           if(Ans==false) 
           Alert("Закрыть BUY ",ticket, " не удалось. Ошибка: ", GetLastError());
         }
      }
     if(Signal==3)
      {
        for(i=0; i<=Mas_Ord_New[0][0]; i++)
         {
           ticket=Mas_Ord_New[i][4];
           lts=Mas_Ord_New[i][5];            
           Ans=OrderClose(ticket,lts,Ask,5);
           if(Ans==false) 
            Alert("Закрыть SELL ",ticket, " не удалось. Ошибка: ", GetLastError());
         }       
      }
    }

 // Функция из учебника

int Terminal()
 {
   int Qnt=0;
   
   ArrayCopy(Mas_Ord_Old, Mas_Ord_New); // Сохранение информации
   Qnt=0; // Обнуление счетчика
   ArrayInitialize(Mas_Ord_New,0);  // Обнуление массива
   ArrayInitialize(Mas_Tip,0);  // Обнуление массива
   
   for (int n=0; n<=OrdersTotal(); n++)
    {
      if ((OrderSelect(n,SELECT_BY_POS)==true) &&
          (OrderSymbol()==Symbol()) && (OrderMagicNumber()==Magic))
       {
         Qnt++;
         Mas_Ord_New[Qnt][1]=OrderOpenPrice();
         Mas_Ord_New[Qnt][2]=OrderStopLoss();
         Mas_Ord_New[Qnt][3]=OrderTakeProfit();
         Mas_Ord_New[Qnt][4]=OrderTicket();
         Mas_Ord_New[Qnt][5]=OrderLots();
         Mas_Tip[OrderType()]++;
         Mas_Ord_New[Qnt][6]=OrderType();
         Mas_Ord_New[Qnt][7]=OrderMagicNumber();
         if (OrderComment()=="")
            Mas_Ord_New[Qnt][8]=0;
         else
            Mas_Ord_New[Qnt][8]=1;
       }
    }
   Mas_Ord_New[0][0]=Qnt;
   return;
 }
 
silhouette:

The EA is designed to generate signals on bars with index 1 and 2 (i.e. open and close orders at the opening of a new bar).

In the tester, it alternately generates errors 138 and 4051 (it seems to be swearing at ticket) for OrderClose.

Please help us solve this problem.

Try the following construction to close the position:

int err;
// ---
if (...) // условие закрытия позиции
{  if (OrdersTotal()>0)
   {  for (int i=OrdersTotal()-1; i>=0; i--)
      {  if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
         {  // фильтрация позиции по текущему символу:
            if (OrderSymbol()!=Symbol()) continue;
            // фильтрация позиции по магик-номеру:
            if (OrderMagicNumber()!=MagNum) continue;
            // ... можно и другие фильтры поставить.
            // --- закрытие позиции Buy.
            if (OrderType()==OP_BUY)
            // перед открытием или закрытием позиции
            // обновляйте котировки с помощью RefreshRates()
            // дабы избежать устаревание запрошенной цены,
            // возможной причины ошибки 138
            {  RefreshRates(); 
               OrderClose(OrderTicket(),OrderLots(),Bid,30);
               err=GetLastError();
               if (err>0)  Alert("Ошибка при закрытии позиции Buy (",err,").");
               if (err==0) Alert("Позиция Buy закрыта успешно.");
               err=0; return(0);
            }
            // --- закрытие позиции Sell.
      else  if (OrderType()==OP_SELL)
            {  RefreshRates();
               OrderClose(OrderTicket(),OrderLots(),Ask,30);
               err=GetLastError();
               if (err>0)  Alert("Ошибка при закрытии позиции Sell (",err,").");
               if (err==0) Alert("Позиция Sell закрыта успешно.");
               err=0; return(0);
            }
   }  }  }
}
 
chief2000:
USDJPY


thanks
 
Roman.:


0.01 - NDD cent account. TR and SL = 0.

Everything is the same everywhere.

On 4th - on currency pairs - without question everything is tested according to the algorithm.

On Alps - gold - tested according to the algorithm.

I would like to add metals to my GRAAL, which works in 4th, so far only on currencies.


So there is no problem with currencies?
 
Vinin:

So there are no problems with currencies?


Yes, there are no problems.

Victor Ivanovich, thank you from the bottom of my heart, I've figured it out on your leading questions.

There are no metals, only currencies on the NDD in 4, that's why error #131 is thrown out during testing - wrong volume. I was not aware of that.

On gold and silver I have already started optimizing the parameters in Alps.

 
paladin80:

To close a position, try this construction:


Thank you, it's working!
Reason: