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

 
OneDepo:

No, it won't. You can see in the code that the signal calculation process is controlled (only last bar or given nMax bars) by parameter prevVals[0]. If it is 0, we restore the calculation by nMax bars. The value of prevVals[0] is controlled by another code.

But let's not get sidetracked, let's get to the point. There are two options above, which is faster in the tester? So


How can I know if you don't have all the code. Put it in the EA as it should be there, then there will be a substantive conversation and you can compare performance.
 
Integer:

I may have got the odds wrong, I'll check now, but the principle doesn't change.

I am not talking about coefficients. I mean the EMA gives wrong values during the first n bars but later everything is OK. The Expert Advisor should take it into account. Otherwise we will have problems with values at every connection failure
 
Vinin:

It's not about the coefficients. I mean the EMA does not give the correct value during the first n bars, after that everything is OK. The Expert Advisor should take it into account. Otherwise we will have problems with values at every connection failure

Is that okay?

extern double Alpha = 0.1;

double EMA;

double GetPrice( int Shift )
{
  return(Open[Shift]);
}

void init()
{
  int i = Bars - 1;
  
  EMA = GetPrice(i);
  i--;
  
  while (i > 0)
  {
    EMA = EMA * Alpha + (1 - Alpha) * GetPrice(i);
    i--;
  }
  
  return;
}  

void start()
{
  static int PrevTime = 0;
    
  if (PrevTime == Time[0])
    return;
 
  PrevTime = Time[0];
    
  EMA = EMA * Alpha + (1 - Alpha) * GetPrice(0);
  
  return;  
} 
 
Vinin:

It's not about the ratios. The EMA gives wrong value for the first n bars but later everything is OK. The Expert Advisor should take it into account. Otherwise we will have problems with values every time we break connection.


No problem, the indicator will recalculate after problems getting the data.

The fact that it's crooked on the left, at the start of the chart, isn't really such a problem either, the tester misses the first 1000 bars.

Here, exactly left (in the appendix).

Files:
iema_1.mq4  1 kb
 
Integer:

How can I know if you don't have the whole code. Put it in the EA the way it should be there, then there will be a substantive conversation.
Please, a variant for testing
Files:
bb-ii-08.mq4  11 kb
 
Integer:


There won't be a problem, the indicator will recalculate after problems getting the data.

The fact that it's crooked on the left, at the start of the chart, isn't really such a problem either, the tester misses the first 1000 bars.

Here, exactly left (in appendix).


I was talking about the advisor, not the indicator. I have already seen it. Only I didn't say it all to you, I said it to hrenfx.
 
hrenfx:

Is that okay?


All that remains to be done is to provide for connection interruptions and history bouncing (unfortunately, this happens). The indicator handles it without any problems. But the Expert Advisor does not see it.
 
OneDepo:
Please test option

Not suitable for the advertised nomination. There will be errors after a break in communication, the smaller the timeframe, the more frequent and larger the errors will be.
 
Vinin:

All that remains to be done is to provide for connection interruptions and history bouncing (unfortunately, this happens). The indicator handles it without any problems. But the Expert Advisor does not see it.

In fact, now we are picking on the concept of trading. The Expert Advisor receives data from the indicator here and now. Suddenly, the history changes and the indicator changes its values dramatically. So, what did the Expert Advisor receive before? Let's recall what is being compared. And we are comparing the speed, in case anyone has forgotten. But despite all arguable picks, I will write an Expert Advisor that takes into account the gaps and history paging.
 
hrenfx:

...and suddenly the story changes...

Amazing!