Errors, bugs, questions - page 144

 
pronych:

It's always been difficult to manage pending orders. on mt4 too. maybe you could try to get away from that? for example, make virtual pending orders (just store them in variables and open when the price has crossed the market). Time is important now...

I have no time... I just debugged the code.

at least have time to do some testing and tweaking

 
Valmars:
Such single mistakes will not affect the fate of your EA in the championship. But if in the absence of money it will make repeated attempts to open a position generating gigabytes in its log, as it happened in the previous Championships, it will be disqualified.
No, when the pending order is deleted, of course, another one will not be placed if there is no money
 
I have a problem when determining stop levels for pending orders. When the market is calm and we want to place a stop order at a permissible level, the function SymbolInfoInteger(SYMBOL_TRADE_STOPS_LEVEL) works perfectlyand orders are placed and everyone is happy including me. However, if the market moves strongly at the beginning of trading sessions, this function stops working, orders are not placed and the terminal starts generating errors about invalid stops.

I wouldn't want my EA to be excluded from the competition because of this kind of reliance on recommended features. But then how do I know the correct allowed stop level for a given symbol at the moment?

P.S. I would hate to use selection with incremental increase in case of error, and the number of errors in this case will increase.
 
Vladix:
I have a problem in determining stop levels for pending orders. When the market is calm and we want to place a stop order at a permissible level, the function SymbolInfoInteger(SYMBOL_TRADE_STOPS_LEVEL) works perfectly well; the orders are placed and everyone is happy including me. However, if market starts to vibrate strongly at the beginning of a trading session, this function stops working, orders are not placed and the terminal starts generating errors about invalid stops.

I wouldn't want my EA to be excluded from the competition because of this kind of reliance on recommended features. But then how do I know the correct allowed stop level for a given symbol at the moment?

P.S. I would very much hate to use a selection with incremental increase in case of an error, and the number of errors in this case would increase.

For pending orders, the error of invalid stops also occurs when the open price is closer to the current one.

I.e. you have to check not only stops, but also opening price.


 

I believe that there is an error in the HistoryDealsTotal() function , if it is started after HistorySelectByPosition() .

It repeatedly displays the number of deals equal to 0, and this despite having an open position (multicurrency variant).

Here is the code:


void GetDealQuantity(string smbl)
{
long pos_id;
int total, quantity=0;
ulong ticket=0; newticket;
PositionSelect(smbl);
pos_id=PositionGetInteger(POSITION_IDENTIFIER);
bool select=HistorySelectByPosition(pos_id);
total=HistoryDealsTotal();
Print(__FUNCTION__," select=",select," total=",total);
for(int i=HistoryDealsTotal()-1;i>=0;i--)
{
newticket=HistoryOrderGetTicket(i);
if(ticket!=newticket) { quantity++; ticket=newticket; }
}
if(smbl==symbol1) quantity1=quantity;
if(smbl==symbol2) quantity2=quantity;
Print(__FUNCTION__," quantity=",quantity);
}

Prints it into the journal:

2010.01.04 00:20:05 GetDealQuantity select=true total=0
2010.01.04 00:20:05 GetDealQuantity quantity=0
2010.01.04 00:20:05 EURJPY volume=0.1 quantity=0
2010.01.04 00:20:05 GetDealQuantity select=true total=1
2010.01.04 00:20:05 GetDealQuantity quantity=1
2010.01.04 00:20:05 AUDUSD volume=0.1 quantity=1

Документация по MQL5: Стандартные константы, перечисления и структуры / Торговые константы / Свойства позиций
Документация по MQL5: Стандартные константы, перечисления и структуры / Торговые константы / Свойства позиций
  • www.mql5.com
Стандартные константы, перечисления и структуры / Торговые константы / Свойства позиций - Документация по MQL5
 

Try to insert the code correctly in your posts. Try redoing your example like this:

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void GetDealQuantity(string smbl)
  {
   long pos_id;
   int total,quantity=0;
   ulong ticket=0,newticket;
   if(PositionSelect(smbl))
     {
      pos_id=PositionGetInteger(POSITION_IDENTIFIER);
      bool select=HistorySelectByPosition(pos_id);
      if(select)
        {
         total=HistoryDealsTotal();
         Print(__FUNCTION__," select=",select," total=",total,"posID=",pos_id);
         for(int i=total-1;i>=0;i--)
           {
            newticket=HistoryOrderGetTicket(i);
            if(ticket!=newticket) { quantity++; ticket=newticket; }
           }
         if(smbl==symbol1) quantity1=quantity;
         if(smbl==symbol2) quantity2=quantity;
         Print(__FUNCTION__," quantity=",quantity);
        }
      else
        {
        Print("Не удалось выполнить HistorySelectByPosition() для pos_id=",pos_id);
        }

     }
   else
     {
      Print("Позиции не выбрана по символу ",smbl);
     }
  }
//+------------------------------------------------------------------+
MQL5.community - Памятка пользователя
MQL5.community - Памятка пользователя
  • 2010.02.23
  • MetaQuotes Software Corp.
  • www.mql5.com
Вы недавно зарегистрировались и у вас возникли вопросы: Как вставить картинку в сообщение на форуме, как красиво оформить исходный код MQL5, где находятся ваши Личные сообщения? В этой статье мы подготовили для вас несколько практических советов, которые помогут быстрее освоиться на сайте MQL5.community и позволят в полной мере воспользоваться доступными функциональными возможностями.
 
Is there an example script somewhere that writes the last quote to the clipboard or something similar?
 
jmp:
Is there an example script somewhere to write the last quote to the clipboard or something similar?

Windows clipboard?

I have to look in msdn to see which dll the required functions are in...

 
I want to get to the bottom of this. Correct me if I'm wrong. When I studied the documentation for indicators (fractals, I think) I remembered very clearly and still remember that in case of two adjacent (consecutive or separated by a few bars) extremums of the same level the key one is the latest (the newer one to the right). However, the Zig-zag indicator as well as the property of chart objects magnetization (apparently based on that zigzag) are fixed at the first extremum of two candlesticks close to one level, though I still cannot give a definite conclusion as the behavior changes from case to case, in my opinion. As for the Zig-zag - this one builds only on the very first candle. Is it right, comrades? Should it be so? Or there are several "standards" without clear rules and everyone is free to choose if the extremum is judged by the left or rightmost candlestick?
 
There are millions of zigzags. Use the one you feel is right.