Retard the alert several seconds - page 3

 
GumRai:

What is your point?

Why not? There is nothing wrong with using Time[0] to detect a new bar.

My code is ok. He wants 3 second after start of bar.

 

Sometimes wnen history updates Time[0] will not work. 

 https://forum.mql4.com/ru/65066/page6#1016370

(rus) 

 
omissamf:
Hi guys, you are great !!!
I do not know how to thank you for your cooperation.
The code posted eevviill works very well, that's what I meant.
The GumRai code instead makes repaint and give the signal whenever the RSI crosses the 30/70 levels.
I insert the working code according to eevviill suggestions, hoping that it will serve some more.

Thanks for everything, Massimo.


My pleasure.
 
Hello eevviill, just a curiosity: what did you mean with:
P.S. Do not use Time [0], use Bars?
It is possible to change the coodice who posted GumRai?
that's just my curiosity, because I'm trying to understand and study the language.
Thanks, Max.
 
eevviill: P.S. Do not use Time[0], use Bars 
Do not use bars, can change on a refresh (new downloaded history.) Do not use volume (you can miss ticks) Always use time.
 
omissamf:
Hello eevviill, just a curiosity: what did you mean with:
P.S. Do not use Time [0], use Bars?
It is possible to change the coodice who posted GumRai?
that's just my curiosity, because I'm trying to understand and study the language.
Thanks, Max.

In my code Bars. You can chek it.

To detect new bar use only Bars.

 
WHRoeder:
Do not use bars, can change on a refresh (new downloaded history.) Do not use volume (you can miss ticks) Always use time.

And? Bars stays the same?

You are wrong. 

 
omissamf:
The GumRai code instead makes repaint and give the signal whenever the RSI crosses the 30/70 levels.


You are referring to this example that I posted?

   static datetime BarStart=0;
   static bool check=false;
   if(BarStart!=Time[0])
     {
      BarStart=Time[0];
      check=true;
     }
   if(check && TimeCurrent()>=Time[0]+3)
     {
      check=false;
      //Check Condition
     }

I don't believe that this will cause any repainting or additional signals

It must be your code. Possibly you placed code to check conditions and alert outside of the

   if(check && TimeCurrent()>=Time[0]+3)
     {
      check=false;
      //Check Condition
     }

block.

 
eevviill:

And? Bars stays the same?

You are wrong. 

If new history is received, bars changes. However that does not indicate to the EA that a new bar has formed.

 
WHRoeder:

If new history is received, bars changes. However that does not indicate to the EA that a new bar has formed.



If history of chart will be updated and number of bars incrases, than Bars will not changes????

 

I have edited the last 2 posts. Please stop the bickering, it achieves nothing.

I will continue to use Time[0] to detect a new bar as I have never had any problems with it.

To be honest, I don't know what happens when Bars reaches the maximum in history, so I will not use Bars. If eevviil prefers to use Bars, it is up to him. WHRoeder is an extremely experienced and valuable contributor to this forum and anything that he says should not be dismissed lightly.

Reason: