Understanding OnTick()

Back to topics list To post a new topic, please log in or register
avatar
85
cryptex 2015.06.13 10:49
 

Hello everyone,

I was little clarity on how OnTick()  works. I am trying to check if a new bar is forming 

void OnTick()
  {
//---
  int m_nLastBars=0;
  int m_bNewBar;
  int nBars=Bars(Symbol(),PERIOD_M15);
if(m_nLastBars!=nBars)
  {
   m_nLastBars=nBars;
   m_bNewBar=true;
   
//////run my logic hereafter

 

avatar
Moderator
3206
angevoyageur 2015.06.13 10:55 #
 
cryptex:

Hello everyone,

I was little clarity on how OnTick()  works. I am trying to check if a new bar is forming 

 

OnTick() is run each time a tick is received, what do you want to understand ?

To detect a new bar don't rely on Bars, always use time.

avatar
85
cryptex 2015.06.13 11:33 #
 
angevoyageur:

OnTick() is run each time a tick is received, what do you want to understand ?

To detect a new bar don't rely on Bars, always use time.

Could you throw some more light on this? I thought that by using bars i could avoid any mismatch in time. Can you kindly suggest how you propose on doing it using time?
avatar
Moderator
3206
Back to topics list  

To add comments, please log in or register