This forum is in read-only mode now. You may discuss your questions on forums of MQL4.community and MQL5.community

Update only at new bar in indicator?


Back to topics list
avatar
3
Flash52 2004.12.23 14:25 

Why does the following not work in an indicator? The code following "if(prevtime == Time[0]) return(0);" gets executed each tick instead of each bar.

datetime prevtime=0;
...
if(prevtime == Time[0]) return(0);
prevtime = Time[0];
gets executed each tick;
but only want to update at each new bar;
...
avatar
3
Flash52 2004.12.23 14:59 
Variable prevtime was initialized within the indicator start function and therefore reset at each tick.
avatar
4464
Slawa 2004.12.23 15:28 
use static memory

    static datetime prevtime=0;

Back to topics list  
Download MetaTrader 5 (450 Kb, web installer) — a new terminal for financial markets