IsFirstTickOfBar

<< Click to Display Table of Contents >>

Navigation:  NinjaScript > Language Reference > Common > OnBarUpdate() >

IsFirstTickOfBar

Previous page Return to chapter overview Next 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 Calculate property is set to Calculate.OnEachTick or Calculate.OnPriceChange.

 

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

 

 

Note: If a bar type is set up to remove the last bar on a chart, IsFirstTickOfBar will automatically be set to True.

 

 

Property Value

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

 

Syntax

IsFirstTickOfBar

 

 

Examples

ns

// On a tick by tick strategy the only way you know when a bar is closed is when
// the IsFirsTickOfBar is true.
protected override void OnBarUpdate()
{
    // Only process entry signals on a bar by bar basis (not tick by tick)
    if (IsFirstTickOfBar)
    {
        if (CCI(20)[1] < -250)
              EnterLong();
        return;
    }
 
    // Process exit signals tick by tick
    if (CCI(20)[0] > 250)
        ExitLong();
}