OnBarUpdate()
Previous Topic  Next Topic 

Definition
The OnBarUpdate() method is called whenever a bar is updated. If the "CalculateOnBarClose" property is set to true, it is only called on the close of each bar, otherwise it is called on each incoming tick. This is the method where all of your strategy or indicator core calculation logic should be contained.




Method Return Value

This method does not return a value.


Syntax
See example below. The NinjaScript indicator and strategy wizards automatically generate the method syntax for you.


Method Of

Custom Indicator, Custom Strategy


Examples

protected override void OnBarUpdate()
{
    if (CurrentBar < 1)
        return;

    // Compares the current bar to the prior bar
    if (Low[0] > Low[1])
        Print("The current bar's low price is greater");
}