Function
bool IsNewBar()
{
bool result = false;
static datetime lastBarTime = NULL;
if (lastBarTime == NULL)
{
lastBarTime = iTime(NULL, 0, 0);
// always return false when the EA first starts
// so as not to falsely trigger buys etc.
result = false;
}
else if (iTime(NULL, 0, 0) != lastBarTime)
{
lastBarTime = iTime(NULL, 0, 0);
result = true;
}
return result;
}
Usage
if ( IsNewBar() ) {
// Insert code to only run when a new bar has formed.
}
You have done good work by publishing this article here. I found this article too informative, and also it is beneficial to enhance our knowledge. Grateful to you for sharing an article like thisforex brokers comparison
ReplyDeleteIt is truly a well-researched content and excellent wording. I got so engaged in this material that I couldn’t wait to read. I am impressed with your work and skill. Thanks. Forex Mt4 Download
ReplyDeleteI really appreciate your work which you have shared here about the Finance. The article you have shared here is very informative and the points you have mentioned are very helpful. Thank you so much.Ethereum Price Eur site.
ReplyDelete