OnBarUpdate()
OnBarUpdate()
Definition
An event driven method which is called whenever a bar is updated. The frequency in which OnBarUpdate is called will be determined by the “Calculate” property. OnBarUpdate() is the method where all of your script’s core bar based calculation logic should be contained.
Notes:
- For multi-timeframe and instrument scripts, the OnBarUpdate method is called for each Bars object of a strategy. You MUST filter for the exact bar update events using the “BarsInProgress” property you want your system logic to execute against.
- Hosted indicators will need to be accessed by the hosting script to ensure OnBarUpdate functionality. This can be done by:
- Calling Update on the hosted indicator within the host script,
- Including a plot in the hosted indicator and accessing the plot in the host script,
- Including a plot in the hosted indicator and adding the indicator to the chart with AddChartIndicator (strategies only)
Related Methods and Properties
Method Return Value
This method does not return a value.
Syntax
You must override this method with the following syntax:
protected override void OnBarUpdate()
Tip: The NinjaScript code wizards automatically generates the method syntax for you.
Parameters
This method does not take any parameters.

