Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1136

 
Artyom Trishkin:

No. I explained above what the frost level is.

Thank you Artem, I'll look into it tomorrow.

 
Artyom Trishkin:

SL and TP are orders. "Levels" - because these are the levels at which these orders are set. You may also call them indent or distance in pips. This does not make them orders.

I am willing to accept that this is how it works, but what I don't understand is if SL and TP are orders, then why they aren't in the list of orders, for example OrdersTotal() orHistoryOrdersTotal();

 
Fast235:

Thank you Artem, I'll look into it tomorrow.

I understand that ))))


 

1) What is the difference between a script and a service?

2) Is it possible to run the indicator on any desired window from the EA without using templates?

 
Alexandr Sokolov:

1) What is the difference between a script and a service?

2) Is it possible to run the indicator from an EA on any desired window without using templates?

here is the function - from the EA https://www.mql5.com/ru/docs/chart_operations/chartindicatoradd

//+------------------------------------------------------------------+
//| Функция проверки и добавления индикатора на график               |
//+------------------------------------------------------------------+
bool AddIndicator()
  {
//--- выводимое сообщение
   string message;
//--- проверим на совпадение символ индикатора и символ графика
   if(_Symbol!=_Symbol)
     {
      message="Демонстрация использования функции Demo_ChartIndicatorAdd():";
      message=message+"\r\n";
      message=message+"Нельзя на график добавить индикатор, рассчитанный на другом символе.";
      message=message+"\r\n";
      message=message+"Укажите в свойствах эксперта символ графика - "+_Symbol+".";
      Alert(message);
      //--- досрочный выход, не будем добавлять индикатор на график
      return false;
     }
//--- проверим на совпадение таймфрейм индикатора и таймфрейм графика
   if(_Period!=_Period)
     {
      message="Нельзя на график добавить индикатор, рассчитанный на другом таймфрейме.";
      message=message+"\r\n";
      message=message+"Укажите в свойствах эксперта таймфрейм графика - "+EnumToString(_Period)+".";
      Alert(message);
      //--- досрочный выход, не будем добавлять индикатор на график
      return false;
     }
//--- все проверки прошли, символ и период индикатора соответствуют графику
   if(indicator_handle==INVALID_HANDLE)
     {
      Print(__FUNCTION__,"  Создаем индикатор");
      indicator_handle=iCustom(_Symbol,_Period,InpIndi_name);
      if(indicator_handle==INVALID_HANDLE)
        {
         Print("Не удалось создать индикатор. Код ошибки ",GetLastError());
        }
     }
//--- сбросим код ошибки
   ResetLastError();
//--- накладываем индикатор на график
   Print(__FUNCTION__,"  Добавляем индикатор на график");
   Print("Индикатор построен на ",_Symbol,"/",EnumToString(_Period));
//--- получим номер нового подокна, в которое добавим индикатор
   int subwindow=(int)ChartGetInteger(0,-1);
   PrintFormat("Добавляем индикатор на окно %d графика",subwindow);
   if(!ChartIndicatorAdd(0,subwindow,indicator_handle))
     {
      PrintFormat("Не удалось добавить индикатор на окно %d графика. Код ошибки  %d",
                  subwindow,GetLastError());
     }
//--- добавление индикатора на график прошло успешно
   return(true);
  }
//+------------------------------------------------------------------+
Документация по MQL5: Операции с графиками / ChartIndicatorAdd
Документация по MQL5: Операции с графиками / ChartIndicatorAdd
  • www.mql5.com
//| Expert initialization function                                   |                                                                                       ); "Внимание! %s: Попробуем добавить индикатор MACD(%s/%s) на график %s/%s. Получим ошибку 4114"                         subwindow...
 
Alexsandr San:

here is the function - from the advisor https://www.mql5.com/ru/docs/chart_operations/chartindicatoradd

Thank you!

 
Alexandr Sokolov:

1) What is the difference between a script and a service?

the script is bound to a chart, the service is not

the script is started "manually", the service is started by the terminal

I don't know any other differences, there is no information about services

 
Igor Makanu:

the script is bound to a chart, the service is not

the script is started "manually", the service is started by the terminal

I don't know any more distinctions, there is no information about the services

Do I get it right? running indicators and advisors after closing the terminal have the properties of the service, but the script does not, i.e. if a script, an indicator and an advisor were running and the terminal was closed, when opening the terminal, only the indicator and the advisor will be loaded to the window, while the script will not?

 
Valeriy Yastremskiy:

Do I get it right? Run indicators and advisors after closing the terminal have the properties of the service, but the script does not, i.e. if there were running script, indicator and advisor and the terminal was closed, when you open the terminal, only indicator and advisor will be loaded into the window, but not the script?

no

the most important thing in MQL is "the chart".

all of them - indicators, Expert Advisors and scripts - are bound to the chart

But the service is not bound to anything - it starts with the terminal and has no chart, i.e. it can't check anything as usual... Well, _Symbol, _Digits - nothing at all that we are used to using, this data is all given by chart


It makes no difference for indicators and EA whether to close the chart or the entire terminal, as far as the service is concerned, if you close all charts, it will work until you close the terminal

If you close the EA by closing the chart, then after the restart of the terminal, there will be no miracle - no chart, no EA, and the service always starts when you start the chart


it's like this, on my fingers ))))

yesterday i did an example of the service,https://www.mql5.com/ru/forum/170952/page173#comment_16044829

i don't know yet what to do with them.


ZS: if we are talking about a script, EA and indicator - what is the difference, the indicator can not trade, but it can draw indicator buffers, the script can do the same thing as EA, but it works "once" and unloads, so it does not unload - infinite loop, but still the terminal when you switch TFs will unload the script


I can't explain it any easier, just look through the first chapters, it's all there

 

Igor Makanu:

but the service is not bound to anything, it starts with the terminal and has no chart, i.e. it can't find out anything as usual... well _Symbol, _Digits - nothing at all that we're used to using, that's all data given by the chart

Who told you that? Using _Symbol or _Digits specifically, can't, but it's easy to get those values. All that is on the chart all you can get from the service. I was not particularly interested in them, but in the light of recent changes I use the service to remove the arrows and lines of closed positions I hate. I start the terminal, run the service and delete all these marks on all charts without touching those created manually or by other programs.

Reason: