Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 316

 
r772ra:
Zto, where to see it, better to download it, retarded though.


here's a thread - on page 9 how to download, if I'm not mistaken.
 
ALXIMIKS:


I found it by scientific method:

Replace limit=Bars-counted_bars-5; by limit=Bars-counted_bars-2;

And put ChartRedraw() in front of all returns.


Yes, the moral is this: the limit should be set exactly so that there are no execution errors, you can't take too much ))))
 
ALXIMIKS:

here's the thread - on page 9 how to download, if I'm not mistaken.


Thanks a lot. Let's have a look.

Yes, article 8 has been found.

 

Can you please tell me how to call the indicator from the EA? (fully call, I need a drawing, not buffers)

And how to allocate space for EA on a chart, similar to the way an indicator is allocated in a separate window?

I would be glad to implement it on both mt4 and mt5 - even if I have to move anywhere.

 
ALXIMIKS:

Can you please tell me how to call the indicator from the EA? (fully call, I need a drawing, not buffers)

And how to allocate space on a chart to an EA, similar to the way an indicator is allocated in a separate window?

I would be glad to implement it both on mt4 and on mt5 - at least where to go.


From the EA only the buffers are visible, if I need more, then just move the logic of the indicator in the EA, or use global variables to transfer them.

And how about to allocate space to the EA on the chart, similar to the way the indicator is allocated in a separate window?

How about this? An EA graphic in a sub-window? Or like here?

 
ALXIMIKS:

Can you please tell me how to call the indicator from the EA? (fully call, I need a drawing, not buffers)

And how to allocate space for EA on a chart, similar to the way an indicator is allocated in a separate window?

I would be glad to implement it both on mt4 and on mt5 - at least where to go.

Library.

 //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
 // 7. ФУНКЦИИ ДЛЯ УПРАВЛЕНИЯ ПРОГРАММАМИ MQL4.
 //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
 // 7.1. Функция удаляет эксперт с указанного графика. В случае успеха функция возвращает TRUE, иначе - FALSE.
 bool ServiceDeleteExpert(int hwndChart); // Системный дескриптор окна графика, удаляемого эксперта.
 //===============================================================================================================================================
 // 7.2. ФУНКЦИЯ удаляет индикаторы по имени из списка загруженных индикаторов.
 void ServiceDeleteIndicatorsByName(int     hwndChart,         // Системный дескриптор окна, куда прикреплен индикатор.
                                    int     nWindow,           // Номер подокна для удаления индикаторов. Если -1, то удаляются индикаторы из всех подокон.
                                    string &asIndicatorName[], // Одномерный массив с именами удаляемых индикаторов.
                                    int     nNumberName);      // Количество имён индикаторов в массиве.
 //===============================================================================================================================================
 // 7.3. Функция удаляет скрипт с указанного графика. В случае успеха функция возвращает TRUE, иначе - FALSE.
 bool ServiceDeleteScript(int hwndChart); // Системный дескриптор окна графика, удаляемого скрипта.
 //===============================================================================================================================================
 // 7.4. Функция управляет диалоговым окном завершения скрипта и возвращает системный дескриптор диалогового окна завершения скрипта, если окно есть,
 //      иначе - NULL. Функция работает только с русской и английской локализациями.
 int ServiceDialogScript(int bInstruction); // Команда для диалогового окна завершения скрипта: TRUE - завершить скрипт, FALSE - не завершать скрипт.
 //===============================================================================================================================================
 // 7.5. Функция получает имена индикаторов из списка загруженных индикаторов.
 //      В случае успеха функция возвращает количество индикаторов в указанных подокнах параметром "nWindow", иначе ноль.
 int ServiceGetNamesIndicators(int     hwndChart,         // Системный дескриптор окна, куда прикреплен индикатор.
                               int     nWindow,           // Номер подграфика. Если -1, то считываются имена индикаторов из всех подокон.
                               string &asIndicatorName[], // Одномерный строковый массив для приёма имён индикаторов.
                                                          // Массив должен быть инициализирован разными значениями в каждой ячейке!
                                                          // Это особенность инициализации строковых массивов в MQL4.
                               int     nNumberName);      // Размер массива "asIndicatorName[]" для приёма имён индикаторов.
 //===============================================================================================================================================
 // 7.6. Функция возвращает TRUE, если окно свойств эксперта открыто, иначе - FALSE.
 bool ServiceIsPropertiesExpert(string sNameExpert); // Имя эксперта, для которого контроллируется открытие окна.
 //===============================================================================================================================================
 // 7.7. Функция открывает окно списка индикаторов. Функция ожидает открытия окна в течении 2,5 секунд. Если окно не появилось в течении этого времени,
 //      функция возвращает FALSE.
 bool ServiceListIndicators(int hwndChart); // Системный дескриптор окна графика, на котором вызывается окно списка индикаторов.
 //===============================================================================================================================================
 // 7.8. Функция загружает на указанный график пользовательский индикатор по его имени.
 void ServiceLoadCustomIndicator(int    hwndChart,      // Системный дескриптор окна графика, куда загружается индикатор.
                                 string sNameIndicator, // Имя загружаемого индикатора.
                                 int    bOK);           // Подтверждение запуска индикатора, при наличии диалогового окна свойств индикатора.
                                                        // TRUE - автонажатие на кнопку "OK" разрешено, FALSE - автонажатие на кнопку "OK" запрещено.
 //===============================================================================================================================================
 // 7.9. Функция загружает на указанный график эксперт по его имени.
 void ServiceLoadExpert(int    hwndChart,   // Системный дескриптор окна графика, куда загружается эксперт.
                        string sNameExpert, // Имя загружаемого эксперта.
                        int    bOK);        // Подтверждение запуска эксперта, при наличии диалогового окна свойств эксперта.
                                            // TRUE - автонажатие на кнопку "OK" разрешено, FALSE - автонажатие на кнопку "OK" запрещено.
 //===============================================================================================================================================
 // 7.10. Функция загружает на указанный график скрипт по его имени.
 void ServiceLoadScript(int    hwndChart,   // Системный дескриптор окна графика, куда загружается скрипт.
                        string sNameScript, // Имя загружаемого скрипта.
                        int    bOK);        // Подтверждение запуска скрипта, при наличии диалогового окна свойств скрипта. Скрипт может не иметь окна свойств!
                                            // При использовании функции для загрузки скрипта из скрипта на текущем графике параметр не работает из-за
                                            // невозможности одновременной работы двух скриптов на одном графике.
                                            // TRUE - автонажатие на кнопку "OK" разрешено, FALSE - автонажатие на кнопку "OK" запрещено.
 //===============================================================================================================================================
 // 7.11. Функция загружает на указанный график стандартный индикатор по его имени.
 void ServiceLoadStdIndicator(int    hwndChart,      // Системный дескриптор окна графика, куда загружается индикатор.
                              string sNameIndicator, // Имя загружаемого индикатора.
                              int    bOK);           // Подтверждение запуска индикатора, при наличии диалогового окна свойств индикатора.
                                                     // TRUE - автонажатие на кнопку "OK" разрешено, FALSE - автонажатие на кнопку "OK" запрещено.
 //===============================================================================================================================================
 

Good evening.

I have this problem...

The EA opens one order at a time during testing and closes it at the right time.

When I run it on a real account, the open orders are not closed, and then I open them the opposite way, as well as in the same direction, and the orders are piled up.

I do not know why it happens.

The Expert Advisor works in this way:

   if (условие на открытие продажи)          
      {                                                                                                                                          
      if (Ticket2 > 0)                                                
         {
         OrderClose(Ticket2, Lot, Bid, 2, Red);   // закрытие покупки          
         Ticket2=0;                                               
         }
      if (Ticket1 == 0)                                        
         Ticket1=OrderSend(Symbol(), OP_SELL, Lot, Bid, 2, 0, 0);   
      }
   if (условие для покупки)            
      {
      if (Ticket1 > 0)                                            
         {
         OrderClose(Ticket1, Lot, Ask, 2, Red);         // закрытие продажи        
         Ticket1=0;                                                
         }
      if (Ticket2 == 0)                                         
         Ticket2_RSI=OrderSend(Symbol(), OP_BUY, Lot, Ask, 2, 0, 0);    
      }
 
waroder:

Good evening.

I have this problem...

The EA opens one order at a time during testing and closes it at the right time.

When I run it on a real account, the open orders are not closed, and then I open them the opposite way, as well as in the same direction, and the orders are piled up.

I do not know why it happens.

The Expert Advisor works in this way:

Is the piece of code where these tickets are made secret?
 
evillive:
Isn't the code fragment where these orders are executed secret?


i just wrote how they are done)

The order can be conditional upon anything, be it an indicator or price reaching a certain level.

On the tester, this is what happens. But on the real one, the orders are not closed and are additionally opened from above.

 
waroder:

Good evening.

I have this problem...

The EA opens one order at a time during testing and closes it at the right time.

When I run it on a real account, the open orders are not closed, and then I open them the opposite way, as well as in the same direction, and the orders are piled up.

I do not know why it happens.

This is the way the EA operates:

In real trading, there are many reasons for not closing your order.

Please check why an order is not closed.

         if(!OrderClose(Ticket2, Lot, Bid, 2, Red)) Alert("Order ",Ticket2," NOT Closed, Error ",GetLastError());   // закрытие покупки      
Although the reason can be seen in the logbook even without that.

In general, the real trade has special functions for opening/closing (the typical OrderClose function can be used, but no guarantee) which keep an order open until it closes/opens.

Reason: