Hi Alistair
Time[0] is the time the current bar started, so I use a variable to record the time a new bar appears and check it against Time[0], which will update when a new bar appears.
For example,
datetime ThisBarTime; // the time of the current bar int init() { ThisBarTime = Time[0]; // or ThisBarTime = Time[1]; to suit your purpose } int start() { //---------------------------------------------------------------------------------------------- // New bar checks if( ThisBarTime != Time[0] ) { // if it's a new bar ThisBarTime = Time[0]; // stuff to do when it's a new bar... } // more stuff... }
Hwlp!!
Noob Alert! I am trying to identify when a bar crosses an indicator line. I thought if i checked each time a new bar starts to be drawn - and used iClose, iHigh and iLow, i could some how measure when a bar has crossed over and indicator line and do some calculaion with that data.
Any help would be appreciated
Thanks
Alistair
Hwi!
with iBars() you have the number of bars (or candles) so if iBars() increases you are on a new candle. Then effectively, you can use iClose with the appropriate shift to compare with your indicator based on that same shift.
Hwlp!!
Noob Alert! I am trying to identify when a bar crosses an indicator line. I thought if i checked each time a new bar starts to be drawn - and used iClose, iHigh and iLow, i could some how measure when a bar has crossed over and indicator line and do some calculaion with that data.
Any help would be appreciated
Thanks
Alistair
Thanks Jaques366 and JellyBean for your Help - Most Helpfull.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hwlp!!
Noob Alert! I am trying to identify when a bar crosses an indicator line. I thought if i checked each time a new bar starts to be drawn - and used iClose, iHigh and iLow, i could some how measure when a bar has crossed over and indicator line and do some calculaion with that data.
Any help would be appreciated
Thanks
Alistair