Errors, bugs, questions - page 1681

 
Karputov Vladimir:
It doesn't make any difference if the quotes are going or standing. You need to control condition prev_calculate==0 in the indicator - this is history swap and the second point - sparing mode of recalculation of changed bars, that is in fact rates_total -prev_calculate+1.

You should read what's written before replying. The code to reproduce the debugger bug! All the data to reproduce it is given.

Here is a script to reproduce the same bug

int Func(){ return(0); }

int Func2()
{
//  return(0); // если расскоментировать и здесь поставить точку останова, то отладчик отработает, как надо  
  return(Func()); // здесь поставить точку останова (F9)
}

void OnStart()
{
  Func2();
}
 
fxsaber:
You should read what is written before answering. Code to reproduce the debugger bug! All data for reproduction is given.

I answered you - you don't care how many times OnCalculate is called. Your task is to provide either full or partial recalculation of the indicator by analyzing two values: rates_total, prev_calculate and the condition when prev_calculate==0.

There is no strict condition that OnCalculate() must be called once or twice. OnCalculate() does not owe anyone anything. But the programmer must control two values: rates_total, prev_calculate and the condition when prev_calculate==0.

 
Karputov Vladimir:
I told you - you do not care how many times OnCalculate is called. Your task is to provide either full or partial recalculation of the indicator, analyzing two values: rates_total, prev_calculate and the condition when prev_calculate==0.

I care how many times the debugger is called and how many times OnCalculate is called. I'm an AWESOME person by nature! And I care about everything.

You are trying to teach me something without understanding the essence of the problem. Thank you, of course. But let's listen to and hear our opponent.

 
fxsaber:

Nah, I'm running it on RTS now, when the kotirs are standing. Figured out that it's called once and the debugger lies, showing as if it's two. Code to play (run on a character where no ticks are going on)

After pressing F5 it will hit a breakpoint. And after a second press on F5 - similarly. While this should not be - as a confirmation, you can shorten that line in the code and try with it.

That's how you can see what's wrong. Watch the value of i at the first and second stops.

int Func(int& i)
{
        i++;
        return 0;
}

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 i = 1;
        return(Func(i)); // здесь поставить точку останова (F9)
}
 
Sergei Vladimirov:

This is how you can see what the problem is. Trace the i value at the first and second stops.

Traced it, that's why I wrote it.

Found out that it's called once, but the debugger is lying, showing it as if it's two.

Why does the debugger return me to the same place after the second press on F5? No such thing happens with return(0), which is correct.

 

It doesn't lie, it stops twice - before calculating the bracketed expression, and after it, just before the return.

By the way, a very handy trick, in my opinion. I need to remember it. No need to put the result in parentheses into a separate variable to check the return value before exit, the debugger itself will stop again.

 
Sergei Vladimirov:

It doesn't lie, it stops twice - before calculating the bracketed expression, and after it, just before the return.

By the way, a very handy trick, in my opinion. I need to remember it.There is no need to put the result in brackets into a separate variable to check the return value before exit, debugger itself will stop for the second time.

I would agree that this is convenient. But how to find out the return result before exit without a variable in the debugger?
 
fxsaber:


Put the code like this:

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 i=1;
   Print("Перед: i ",i,",rates_total ",rates_total,", prev_calculated ",prev_calculated);
   int rezult=Func(i);
   Print("После: i ",i,",rates_total ",rates_total,", prev_calculated ",prev_calculated);
   return(rezult); // здесь поставить точку останова (F9)
  }

and put the indicator on the chart. And then reload the terminal (you do not need to remove the indicator from the chart). You will see that OnCalculate() can be called once or twice or even three times. That is, as I said above - there are no strict rules.

 
Karputov Vladimir:

Put the code like this:

and put the indicator on the chart. And then reload the terminal (you do not need to remove the indicator from the chart). You will see that OnCalculate() can be called once or twice or even three times. That is, as I said above - there are no strict rules.

You force me to complain about you as being completely unwilling to hear what your opponent writes.
 
fxsaber:
I would agree that this is handy. But how can I find out the return result before the exit without a variable in the debugger?

Look in the Func() body to see what it returns before exiting. I'm talking about a special case. If the value will be calculated directly in brackets, of course, you can't.

PS. Although... Why not? At the second stop, look up all arguments return() and calculate the result. )

Reason: