> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.ninjatrader.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.ninjatrader.com/_mcp/server.

# IsValidDataPoint()

## Definition

Indicates if the specified input is set at a barsAgo value relative to the current bar. Please also see the **[Reset()](/developer/desktop-sdk/references/common/iseriest/reset)** method for more information.

* If called directly from the instance of the **NinjaScript** object, the value returned corresponds to the Input Series (e.g., Close, High, Low, SMA, etc.)
* When checking a **[Bar](/developer/desktop-sdk/references/common/bars)** or **[PriceSeries](/developer/desktop-sdk/references/common/iseriest/priceseries)**, `IsValidDataPoint()` returns true as long as the barsAgo value falls between 0 and the total count for that series. These are special series which always contain a value set at every slot index for multi-series scripting purposes (e.g., comparing two price series with various session templates, or one series has more ticks than the other)
* For a **[Value](/developer/desktop-sdk/references/optimization-fitness/value)** series or custom **[Series\<t>](/developer/desktop-sdk/references/common/iseriest/seriest)**, `IsValidDataPoint()` returns true or false depending on if you have set a value at that index location

## Method Return Value

A bool value, when true indicates that specified data point is set; otherwise false.

## Syntax

`IsValidDataPoint(int barsAgo)`

`ISeries\<t\>.IsValidDataPoint(int barsAgo)`

* Calling `IsValidDataPoint()` will only work on a MaximumBarsLookBackInfinite series. Attempting to check **IsValidDataPoint()** on MaximumBarsLookBack256 series will throw an error. Please check the Log tab of the Control Center. In addition, since this method references barsAgo data, it cannot be used during **[OnRender (see note 5)](/developer/desktop-sdk/references/common/charts/rendering/onrender)** - instead please use the **[IsValidDataPointAt](/developer/desktop-sdk/references/common/iseriest/isvaliddatapointat)** during OnRender.

## Parameters

| Parameter | Description                                                                                   |
| --------- | --------------------------------------------------------------------------------------------- |
| barsAgo   | An int representing from the current bar the number of historical bars the method will check. |

## Examples

```csharp
protected override void OnBarUpdate()
{
   // only set plot value if hosted indicator is not reset
   if(SMA(20).IsValidDataPoint(0))
     MyPlot[0] = SMA(20)[0];
}
```