The indicator does not plot on the screen any other signal until I click on the compile - page 2

 

The memory class of "static" defines a static variable. The specifier "static" is declared before a data type.

Example:

int somefunc()
  {
   static int flag=10;
   ....
   return(flag);
  }


Static variables are stored in the permanent memory, their values do not get lost when the function is exited. Any variables in a block, except for formal parameters of the function, can be defined as static. The static variable can be initialized by a constant of the corresponded type, unlike a simple local variable which can be initialized by any expression. If there is no explicit initialization, the static variable is initialized with zero. Static variables are initialized only once before calling of the "init()" function, that is at exit from the function inside which the static variable is declared, the value of this variable not getting lost.

 
zzuegg:

change

   limit=Bars-counted_bars;

to:

 limit=Bars-counted_bars-1;

That would be true if he used the standard
if (counted_bars>0) counted_bars--;
He didn't so the code was correct as is.
 

It’s funny. Some days ago I was checking this indicator again and I realize that it was working well only for the past. When I plot it in real time data the result is irregular and incorrect in the present data.

All already changed the “static” variable like zzuegg suggested, I also tried to transform the Upshift variable to Buffer.

When I did such modifications I only got the reverse result – Past calculus wrong, present calculus correct.

//--------------------------------------------------------------------------------------------------------//
//                 Inicio dos calculos     - FLAG                                                         //
//--------------------------------------------------------------------------------------------------------// 

      if(Close[i+1]>BuyTrailingStop[i+1])
         {
            UpShift[i]=UpShift[i+1]+1;
            DownShift[i]=0;
         }
         else
         {
             UpShift[i]=0;
             DownShift[i]=DownShift[i+1]+1;
         }

I’m a little bit confused at this moment. Anyone knows what is happening?

Reason: