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

 

Here is the correct code with time measurement. Dimitri needs to scoop it up with an indicator and post it here so you can compare it.


extern double Alpha = 0.1;

double EMA;

double GetPrice()
{
  return(Open[0]);
}

void init()
{
  EMA = GetPrice();
  
  return;
}

void start()
{
  static int PrevTime = 0;
  int start = GetTickCount();
  
  if (PrevTime == Time[0])
    return;
 
  PrevTime = Time[0];
    
  for(int i = 0; i != 100000; i++)
      EMA = EMA * Alpha + (1 - Alpha) * GetPrice();
  Print("Calculation Time", GetTickCount()-start,"ms");

  return;  
}
 
hrenfx:

For comparison, I have slightly modified the indicator (iema.mq4):

and EA:


Don't tell me it's my code
 
hrenfx:
Don't be cheeky, the code is in the appendices on page 11.
There's no timing there, the code is incomplete.
 
Andrei01:

Here is the correct code with time measurement.

Who says it's correct?
 
TheXpert:
Who says he's right?
The code fully satisfies the problem - measuring the EMA calculation time in the EA.
 
Andrei01:

Here is the correct code with time measurement. Dimitri should scoop it up through his tool and post it here so you can compare.

You've got a lot of nerve, calling such bullshit a proper code and hinting that it has something to do with me.

 
Andrei01:

Here is the correct code with time measurement. Dimitri needs to scoop it up through an indicator and post it here so you can compare it.

Completely incorrect. You're obviously in a hurry to get into the code. There are not too many strings.

You do the following: you generate price BP and calculate the running time of "all in one" and "with indicator" variants.

 
I'm leaving the branch for good.
 
hrenfx:

You do this: you generate a price BP and calculate the running times of the all-in-one and indicator variants.


BP at the first stage is not necessary, you can simply compare the speed of this code fragment. The result as such is not important, it is only calculation time that is important.

In a more complex case, we can loop the start function instead of the internal loop.

 
Integer:

You've got a lot of nerve, calling such heresy a proper code and hinting that it has something to do with me.

Read carefully the terms of the competition before you rude, you demanded a code for comparison - here's the code.

Now go ahead and attach it to the indicator, just like you were going to.