I'm working on developing a custom indicator in NinjaTrader and I've run into a couple of CS0103 errors stating that the name IsHistorical does not exist in the current context.
Here are the error details:
Error Code: CS0103
File: EnhancedLiquidityIndicator.cs
Line: 72
Column: 21
Description: The name 'IsHistorical' does not exist in the current context
And another similar error:
Error Code: CS0103
File: EnhancedLiquidityIndicator.cs
Line: 123
Column: 17
Description: The name 'IsHistorical' does not exist in the current context
Here are the relevant parts of my code:
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
// Default settings
}
else if (State == State.DataLoaded)
{
// Initialization
vwap = new Series<double>(this);
if (IsHistorical) // Error occurs here
{
string logFilePath = NinjaTrader.Core.Globals.UserDataDir + "LiquidityScores.csv";
System.IO.File.WriteAllText(logFilePath, "DateTime,LiquidityScore\n");
}
}
}
protected override void OnBarUpdate()
{
// Code logic
if (IsHistorical && Bars.IsFirstBarOfSession) // Error occurs here
{
string logFilePath = NinjaTrader.Core.Globals.UserDataDir + "LiquidityScores.csv";
System.IO.File.AppendAllText(logFilePath, $"{Time[0]},{liquidityScore}\n");
}
}
How can I correctly check if the context is historical within the OnStateChange and OnBarUpdate methods?
Is there a specific property or method I should be using instead of IsHistorical?
Any guidance would be greatly appreciated.
Thank you!
António

Comment