NinjaScript > Language Reference > Data >

FirstTickOfBar

Print this Topic Previous pageReturn to chapter overviewNext page

Definition

Indicates if the incoming tick is the first tick of a new bar. This property is only of value in scripts that run tick by tick which is when the CalculateOnBarClose property is set to false.

 

NOTE: This property should NOT be accessed outside of the OnBarUpdate() method.

 

Property Value

This property returns true if the incoming tick is the first tick of a new bar; otherwise, false.

 

Syntax

FirstTickOfBar

 

 

Examples

// On a tick by tick strategy the only way you know when a bar is closed is when
// the FirsTickOfBar is true.
protected override void OnBarUpdate()
{
    // Only process entry signals on a bar by bar basis (not tick by tick)
    if (FirstTickOfBar)
    {
        if (CCI(20)[1] < -250)
              EnterLong();

 
        return;
    }
 
    // Process exit signals tick by tick
    if (CCI(20)[0] > 250)
         ExitLong();
}