Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1040

 
Dear colleagues, there is a need to define programmatically at which time interval the optimisation will take place. Can you advise whether there is such a possibility? In OnInit.
 
Anzhela Sityaeva:

The comma doesn't play a role in the formula, you're right, it just separates the value from the type, for ease of understanding nothing more. Grade 5 was a long time ago :), and I've never been good at maths, as it happens. But I do remember the order of operations.

The question is precisely that in both versions of the calculations resultis the same, which option to consider correct?

I daresay you were born when I had already finished not only fifth grade, but some of the next. So it was like yesterday to me... And if you remember the order of operations, why does this question arise in your mind? If the result of the calculations is the same, can one option be more correct than the other? Well it is obvious that there is no difference.
 
Alexey Viktorov:
I daresay you were born when I had already finished not only the fifth grade, but also the next few. So it was like yesterday to me... And if you remember the order of operations, why is there such a question in your mind? If the result of the calculations is the same, can one option be more correct than the other? Well, obviously there's no difference.
It's not customary to ask a girl about her age, and it's irrelevant. I wanted the opinion of someone who is on the subject and besides myself, doubts, you know :)
 
Anzhela Sityaeva:
It's not customary to ask a girl about her age, and it's irrelevant. I wanted the opinion of someone who is on the subject and besides myself, doubts, you know :)

I didn't ask about your age. I only suggested that you are still very young and only pretend you don't remember anything anymore.

 
Decromor:

Hi all...

I'm trying to remove an indicator I added from an EA. I am doing the following:

In Indicator:

Indicator is added, subwindow number and short name is correct, but error when deleting:

2019.05.08 12:01:10.068 2019.04.03 12:39:31 Failed to delete indicator blablabla from window #2. Error code 4014

4014 - "System function is not allowed to be called". Can you please advise what it means, how to remove indicator?

One of the indicators is used by the Expert Advisor for a short period of time, the rest of the time it is not needed and its settings become irrelevant. This is why the first option I considered - to remove the indicator at the time it is not needed and at the right time add it with new settings. But I can't do it for some reason.

Another variant is: Global Variables. Suppose the indicator will always be in the window, but I will change its input parameters through global variables at the necessary moment.

Right? Are there any other variants?

 
Decromor:

One of the indicators is used by the Expert Advisor for a short period of time, the rest of the time it is not needed, and its settings become irrelevant. For this reason, the first option I considered was to remove the indicator at the time when it is not needed and add it at the right time with new settings. But I can't do it for some reason.

Another variant is: Global Variables. Suppose the indicator will always be in the window, but I will change its input parameters through global variables at the necessary moment.

Right? Are there any other variants?

An expert indicator on a chart is like a dog's pivot.

 
Alexey Viktorov:

The indicator on the chart is like a dog's turn.

It's perfect for setting up an expert.

This is how I add it, but I can't remove it.

Forum on trading, automated trading systems and strategy testing

Questions from beginners MQL5 MT5 MetaTrader 5

Decromor, 2019.05.08 09:17

Hi all...

Trying to remove an indicator I added by myself from an EA. I am doing the following:

//Объявляю переменные
int win_ind=-1,
    handle_ind = INVALID_HANDLE;

//Создаю
   handle_ind= iCustom(NULL,0,"ind");
   if(handle_ind== INVALID_HANDLE){
      Print("Не удалось создать индикатор. Код ошибки: ",GetLastError());
      return(false);
   }
   win_ind=(int)ChartGetInteger(0,CHART_WINDOWS_TOTAL); //--- получим номер нового подокна, в которое добавим индикатор 
   if(!ChartIndicatorAdd(0,win_ind,handle_ind)){
      Print("Не удалось добавить индикатор на окно графика. Код ошибки: ",GetLastError());
      return(false);
   }

//Удаляю
   string name = ChartIndicatorName(0, win_ind, 0);
   bool res = ChartIndicatorDelete(0, win_ind, name); 
   if (!res) PrintFormat("Не удалось удалить индикатор %s с окна №%d. Код ошибки %d", name,win_ind,GetLastError());

In indicator:

int OnInit(){
   IndicatorSetString(INDICATOR_SHORTNAME,"blablabla");

Indicator is added, subwindow number and short name is correct, but error when deleting:

2019.05.08 12:01:10.068 2019.04.03 12:39:31 Failed to delete indicator blablabla from window #2. Error code 4014

4014 - "System function is not allowed to be called". Please advise what it means, how to remove indicator?


 
Decromor:

For setting up an expert, that's fine.


That's not an answer to my question. To be more precise, it is a rejoinder. Then I put my thought in the form of a question: Why does the EA need an indicator on the chart?

If we want to refuse from the unused indicator handle, there is another function for this. And the indicator itself on the chart for what purpose?

 
Is there a ready solution so as not to reinvent the wheel?
We need to answer a simple question - how many closed trades (let's call it that) have been in the history (for a specific pair or period is not important, the main thing is the principle). As I understand it is not a trivial task in mql5. I do not even have a name for this entity))
 
Evgeny Dyuka:
Do you have a ready solution without having to re-invent the wheel?
We need to answer a simple question - how many closed trades (let's call it that) have been in the history (for a certain pair or period is not important, the main thing is the principle). As I understand it is not a trivial task in mql5. We do not even have a name for this entity))

Why not?

bool  HistorySelect(
   datetime  from_date,     // с даты
   datetime  to_date        // по дату
   );

And then in a loop we sift out what we need.

Or for a specific position.

bool  HistorySelectByPosition(
   long   position_id     // идентификатор позиции - POSITION_IDENTIFIER
   );
Документация по MQL5: Торговые функции / HistorySelect
Документация по MQL5: Торговые функции / HistorySelect
  • www.mql5.com
Функция HistorySelect() создает в mql5-программе список ордеров и список сделок для дальнейшего обращения к элементам списка посредством соответствующих функций. Размер списка сделок можно узнать с помощью функции HistoryDealsTotal(), размер списка ордеров в истории можно получить с HistoryOrdersTotal(). Перебор элементов списка ордеров лучше...