I've always used Bars rather than Time[0], but the principle is exactly the same. The following code in OnTick() will set m_bNewBar true for one tick. This assumes that the code is in a class method and m_bNewBar and m_nLastBars are class members. Alternatively, they could be declared globally, C-fashion.
int nBars=Bars(Symbol(),PERIOD_CURRENT);
if(m_nLastBars!=nBars){m_nLastBars=nBars;m_bNewBar=true;}
else
{m_bNewBar=false;}
No comments:
Post a Comment