Changing the TF is a problem - page 7

 
Vasyl Nosal:

Genius.

Have you tried switching to a pair with no history and then switching to another TF?

Yeah, I admit my mistake. The code shows what to do if Close[i] > Close[i+1] and what to do if Close[i] < Close[i+1]. But it does not specify what to do if Close[i] == Close[i+1]. These are the bars where these single arrows are falling out.

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 nStartBar = rates_total - MathMax(prev_calculated, 2);

   for(int i = nStartBar; i >= 0; i--)
   {
      if(Close[i] >= Close[i+1])
      {
         up_arr[i] = Low[i] - arrow_indent * _Point; //up arrow
         down_arr[i] = 0;
      }
         
      if(Close[i] < Close[i+1])
      {
         up_arr[i] = 0;
         down_arr[i] = High[i] + arrow_indent * _Point; //down arrow
      }
   }

   return(rates_total);
}
 
Karputov Vladimir:

You know, let's do this: take code 1.43 from this post and comment out the lines:

and look at the result when scrolling the graph to the back of the story and making sure the story is loaded.

Well, I did. Realising, though, the pointlessness of this action. :) The result is expected - the indicator works without interruption.
 
Vasyl Nosal:

Genius.

Have you tried switching to a pair with no history and then switching to another TF?

What do you mean by "no history"?
 
Sergei Vladimirov:

Uh-huh, I admit a bug. The code specifies what to do if Close[i] > Close[i+1], and what to do if Close[i] < Close[i+1]. But it does not specify what to do if Close[i] == Close[i+1]. These are the bars where these single arrows are falling out.

That's good.
 
Alexey Viktorov:
What do you mean "where there is no history"?
Where a currency pair's chart has not opened or has opened for a very long time.
 
Sergei Vladimirov:

WHAT IS THIS?


It's so there are no outs if anything.
 
Vasyl Nosal:
It's so there are no outs if anything.
Who are they? ))
 
Sergei Vladimirov:
Who are they? ))
Array out of range
 
Vasyl Nosal:
Array out of range
Why do you need such a large margin, as much as 20 bars? Is it by eye? )) In the general case, you can't go beyond [rates_total-1], and in this code - beyond [rates_total-2] because the previous bar is called in the loop's body. So, we need to start calculation from bar [rates_total-2].
 
Sergei Vladimirov:
And why take such a large margin - 20 bars? Is it by eye? )) In the general case, we cannot go beyond [rates_total-1], and in this code - beyond [rates_total-2] because the previous bar is called in the loop's body. So, we need to start calculation from bar [rates_total-2].

I understand. The next thing will be how many bars total to count and how many to recalculate.

Someone will enter more bars than there are bars. It'll be an out.

Yeah, by eye.