When does it make sense to keep part of the robot code in an indicator? - page 23

 
Vinin:

The EMA value at break in communication is taken incorrectly. It is taken as the last one calculated. But this is incorrect. As a result, the function will work incorrectly not on n bars but on a much larger number of bars. If values are saved, of course

Apparently they didn't get into the code. Commented:

// Комментирую для такого случая. Крайний известный M1-бар был в 14:00.
// Произошел разрыв связи на 10 минут после чего происходит вызов start.
void start()
{
  EMA = GetEMA();
  
  return;  
}

double GetEMA()
{
  static int PrevTime = 0;
  
  if (PrevTime == Time[0]) // Выпонится, когда история за крайние 10 минут подгрузится.
                           // Если истории не было, например, сутки, то может произойти ошибка.
                           // Но мы говорим про РЕАЛ, т.е. адекватность человека.
                           // Т.к. если нет связи сутки, советник оставлять нельзя.
    return(EMA);

  int i = iBarShift(Symbol(), Period(), PrevTime) - 1; // Здесь мы получим номер бара в 14:01.

  PrevTime = Time[0]; // запомним текущее время 14:10
  
// Производим расчет текущего EMA с учетом полученных 10 баров.
  while (i >= 0)
  {
    EMA = EMA * Alpha + (1 - Alpha) * GetPrice(i);
    
    i--;
  }
  
  return(EMA);
} 
 
When I said error and adequacy, I didn't mean that this applies only to the "all-in-one" case, but also to the "with indicator" case.
 
hrenfx:
When I said error and adequacy, I meant the applicability of this not only to the "all-in-one" case, but also to the "with indicator" case.


The conversation does not work, apparently someone does not want to hear a little criticism.

We can conclude that this branch is useless

 
Vinin:


I am not having a conversation, apparently someone does not want to hear a little criticism.

One might conclude that this thread is useless

Look, there's no need to quibble. I even commented on your code. What's not to like? Do you think that the example of a 10-minute gap causes an error? I've made it very clear. You're saying there's an error, so you see where it is. Then don't be lazy, just show me where it is. You've already identified it.

P.S. You're the second person to stall. And don't say I don't understand. Show me clearly where the mistake is. If I'm wrong, I'll admit it. It won't do me any good.

 
hrenfx:

Look, there's no need to be evasive. I even commented on your code. What's not to like? You think the 10-minute gap example I gave you causes an error? I've been very specific on my part. You're saying there's an error, so you see where it is. Then don't be lazy, just show me where it is. You've already identified it.

P.S. You're the second person to stall. And don't say I don't understand. Show me clearly where the mistake is. If I'm wrong, I'll admit it. It won't do me any good.


Someone just doesn't want to think. I can't make them, and I don't want to.
 
Vinin:

Just someone doesn't want to think. I can't force them to, and I don't want to.


Fucking hell, no one has elaborated. Water again. Several people (I know MT4+MQL4 very well) tell me that my code will work with an error but I can't give a specific example-argument (I've asked for it several times). And this in a code of only 10 lines.

Why don't you put the Integer code and my code in a separate thread and ask MQL4 programmers what is wrong in the code. And you, as a moderator, make sure there is no flooding. In this case, the code is not even found.

I think it will be useful for MQL4 community.

 
hrenfx:

Look, there's no need to quibble. I even commented back to you on the code. What's not to like?

The price will come first. Then the bars will come. By the time the bars arrive, they will have been 'sort of' processed, but in fact are unaccounted for because they were not present when they were processed.

This is the second time I've said it.

 
TheXpert:

The price will come first. Then the bars will come. By the time the bars arrive, they will be "sort of" processed, but in fact they will not be considered because they were not available at the moment of processing.

Yes, the price will arrive first but the condition if (PrevTime == Time[0]) will be triggered all the time until there is a new bar.

You understand that if a new bar arrives, without any paging for the last 10 minutes, the EA with the indicator will receive wrong EMA values before the history paging. As a result, the EA will do anything.
 
hrenfx:


Geez, no one has elaborated on it. Water again. Several people (MT4+MQL4 know very well) tell me that my code will work with errors but they cannot give a specific example-argument (I've asked for it several times). And this in a code of only 10 lines.

Maybe you could put the Integer code and my code in a separate thread and ask MQL4 programmers what is wrong in the code. And you, as a moderator, make sure there is no flooding. In this case, the code is not even found.

I think it will be useful for MQL4 community.


I provided the logic for a workable algorithm. It didn't work. I'm sorry I didn't get through.
 
hrenfx:
Yes, the price will come first, but until there is a new bar, the condition if (PrevTime == Time[0]) will be triggered all the time.
No, the price will be on a new bar. This can be clearly seen when the terminal is switched on. In the beginning the bar looks like a point.