I am trying to incorporate the third party QuantumCSI on my strategy. I used the Strategy Builder to see how to use the indicator. It compiles fine; however, when I try to run a backtest thru the Strategy Analyser, I get the following error:
Indicator 'QuantumCSI". Error on calling "OnStageChange" method. Object reference not set to an instance of an object
I appreciate if you could help me to resolve this error.
Thanks,
The following is the sample code
//This namespace holds Strategies in this folder and is required. Do not change it.
namespace NinjaTrader.NinjaScript.Strategies
{
public class STRR : Strategy
{
private QuantumCSI QuantumCSI1;
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"Enter the description for your new custom Strategy here.";
Name = "STRR";
Calculate = Calculate.OnBarClose;
EntriesPerDirection = 1;
EntryHandling = EntryHandling.AllEntries;
IsExitOnSessionCloseStrategy = true;
ExitOnSessionCloseSeconds = 30;
IsFillLimitOnTouch = false;
MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix;
OrderFillResolution = OrderFillResolution.Standard;
Slippage = 0;
StartBehavior = StartBehavior.WaitUntilFlat;
TimeInForce = TimeInForce.Gtc;
TraceOrders = false;
RealtimeErrorHandling = RealtimeErrorHandling.StopCancelClose;
StopTargetHandling = StopTargetHandling.PerEntryExecution;
BarsRequiredToTrade = 20;
// Disable this property for performance gains in Strategy Analyzer optimizations
// See the Help Guide for additional information
IsInstantiatedOnEachOptimizationIteration = true;
}
else if (State == State.Configure)
{
QuantumCSI1 = QuantumCSI(14, 60, true, true, true, true, true, true, true, true);
}
}
protected override void OnBarUpdate()
{
if (CurrentBars[0] < 1)
return;
// Set 1
if (QuantumCSI1.USD[0] > QuantumCSI1.USD[1])
{
EnterLong(Convert.ToInt32(DefaultQuantity), "");
}
}
}
}

Comment