Machine learning in trading: theory, models, practice and algo-trading - page 506

 
Mihail Marchukajtes:

Hi all!!! Guys, tell me how to delay the calculation of the indicator. A new bar opened and the indicator needs to be calculated after 30 seconds!!!!!

I can't find it in the system, I don't know where it's written.

What is a delay for?

 
Vitaly Muzichenko:

Why is there a delay?


The data from SME are loaded with a delay of 30 seconds. And sometimes the indicator is calculated and then the data is loaded, then I recompile the indicator and it changes the direction, because the data is loaded completely, in contrast to the first 5 seconds of the bar life. As a rule, 30 seconds is enough. Is it possible to do this with the indicator? I mean the delay.....

 
Mihail Marchukajtes:

The data from SME are loaded with a delay of 30 seconds. And sometimes the indicator is calculated and then the data is loaded, then I recompile the indicator and it changes the direction, because the data is loaded completely, in contrast to the first 5 seconds of the bar life. As a rule, 30 seconds is enough. Is it possible to do this with the indicator? I mean the delay.....

Either you create a one-time timer event,
Or you can do it yourself: the time of a new bar is memorized and every tick will check if 30 seconds have passed.
 
Aleksey Terentev:
Either create a one-time timer event,
Or make it yourself: a new bar time is memorized and each tick is checked if 30 seconds have passed.

Exactly the timer function is not quite clear. According to the previous advice I made the following function and now the calculation of the bar is without delay. (without it it did not count at all until you switch the TF)

void OnTimer()
{
   int bars = Bars(_Symbol, _Period);
   if (bars <= 0) return;
   
   datetime T[];
   int res = CopyTime(_Symbol, _Period, 0, bars, T);
   if (res <= 0) return;
   
   // unused params
   double d[];
   long l[];
   int i[];
   OnCalculate(bars, bars - 1, T, d, d, d, d, l, l, i);
   ChartRedraw();
}

What's the best way to organize it, could you suggest????

 
Mihail Marchukajtes:

The data from SME are loaded with a delay of 30 seconds. And sometimes the indicator is calculated and then the data is loaded, then I recompile the indicator and it changes the direction, because the data is loaded completely, in contrast to the first 5 seconds of the bar life. As a rule, 30 seconds is enough. Is it possible to do this with the indicator? I mean the delay.....

The first thing that came:

 int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
 // здесь ваши расчёты 
 int limit=rates_total-prev_calculated;
  if(limit>0) { 
  ...
  }

 // задержим на 30 сек
 if(time[0] > TimeCurrent()-30)
   return(rates_total-1);

 // остальной код
   ...
 
Vitaly Muzichenko:

The first thing that came in:


Interesting!!! Inserted your code into the turkey, I'll see what's up. But I thought that such a delay should be described in onTimer, no?

Thanks anyway!!!
 
Mihail Marchukajtes:

Hi all!!! Guys, tell me how to delay the calculation of the indicator. A new bar opened and the indicator needs to be calculated after 30 seconds!!!!!

Or tell me where it is written or an example, I searched all over, I can not find :-(

Why 30 seconds? - Do at once for 60 seconds - i.e. count not on the 1st bar, but on the 2nd. I.e. you have a new zero bar, you still have to wait 30 seconds for the first one, but the 2nd one is ready.

In addition to that you must optimize and test by opening prices.

 
Review of Econometric Models Applicable to Hedge Fund Returns Capturing Serial Correlation and Illiquidity by Ludovic Dubrana :: SSRN
  • papers.ssrn.com
Hedge Fund returns are often highly serially correlated mainly due to illiquidity exposures given that investments in such securities tend to be inactively traded and associated market prices are not always readily available. Following that, observed returns of such alternative investments tend to be smoother than “true” unobserved returns...
 
elibrarius:

Why 30 seconds? - Do it immediately for 60 seconds - i.e. do not count by the 1st bar, but by the 2nd. I.e. came out a new 0-th bar, the first still have to wait 30 seconds, but the 2nd is ready.

And you probably also optimize and test by opening prices.


I do so with BO! But with the main strategy this will not work, it means the decision bar should be shifted back, which is contrary to the basic strategy, so not an option....

Reason: