Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
Analyzer
Collapse
X
-
Analyzer
I have a strategy that I runn successfully in playback mode, but when I run it through the strategy analyzer I get this message: "Error on calling 'OnStateChange' method: Object reference not set to an instance of an object.". Any thoughts? thanksTags: None
-
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"Enter the description for your new custom Indicator here.";
Name = "MyNT8RangeBreakoutV2";
Calculate = Calculate.OnEachTick;
IsOverlay = true;
DisplayInDataBox = true;
DrawOnPricePanel = true;
ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
BandOpacity = 3;
EntriesPerDirection = 1;
EntryHandling = EntryHandling.AllEntries;
IsExitOnSessionCloseStrategy = true;
ExitOnSessionCloseSeconds = 30;
IsFillLimitOnTouch = false;
TraceOrders = true;
BarsRequiredToTrade = 10;
IsInstantiatedOnEachOptimizationIteration = false; // Disable this property for performance gains in Strategy Analyzer optimizations
IsUnmanaged = false;
OrderFillResolution = OrderFillResolution.Standard;
MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix;
Slippage = 0;
StartBehavior = StartBehavior.WaitUntilFlat;
TimeInForce = TimeInForce.Gtc;
RealtimeErrorHandling = RealtimeErrorHandling.StopCancelClose;
StopTargetHandling = StopTargetHandling.PerEntryExecution;
ClearOutputWindow();
}
else if (State == State.Configure)
{
AddDataSeries(BarsPeriodType.Minute, 1); // BarsInProgress 1 ... we use this as a '1 min timer' so that the OnBarUpdate function ... acts like a timer.
baseLine = new Series<double>(this, MaximumBarsLookBack.Infinite);
SetStopLoss(CalculationMode.Ticks, initialStopLevel);
// SetProfitTarget(CalculationMode.Ticks, 400*TickSize);
}
else if (State==State.DataLoaded)
{
instName= Instrument.MasterInstrument.Name;
sessionTxtwithSpacers = sessionTxt;
DirectoryInfo dir = new DirectoryInfo(NinjaTrader.Core.Globals.InstallDir + "sounds");
soundFileDir = dir.ToString()+"\\";
firstPasses = true;
if (runProgram)
{
if (Account.Name != "Sim101" && Account.Name != "Replay101" && Account.Name != "Playback101")
chartBackroundNoTrade = liveColor;
else
chartBackroundNoTrade = originalColor;
ChartControl.Properties.ChartBackground = chartBackroundNoTrade;
}
}
Comment
-
I believe this is happening because of your 'runProgram' if condition. Are you able to run the strategy when that is commented out?
Help Guide - Debugging your NinjaScript codeJosh G.NinjaTrader Customer Service
Comment
-
OK ... so that suggestion cleared up the error. Thank you! But know another issue has arisen. I ran the strategy for the same time period and for the same parameters as I ran in playback mode ... but received very different results. I checked time and time again to make sure all the settings are the same, but I'm clueless why the results are so different. Is there any place you can direct me to that may help me sort this out? Thanks in advance.
Comment
-
Hello pman777,
Thanks for the reply.
Just to confirm, you are running the strategy in Playback mode, and then you are running the strategy through the Strategy Analyzer and comparing the results?
If this is the case, and you are seeing different results, it is likely because you need to turn on Tick Replay in the strategy analyzer, this will process the data as it came in instead of on the close of every bar.
I look forward to assisting further.Chris L.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by johntraderuser2, Today, 02:34 AM
|
0 responses
6 views
0 likes
|
Last Post Today, 02:34 AM | ||
Started by IanS00, 03-27-2024, 11:24 AM
|
2 responses
12 views
0 likes
|
Last Post Today, 02:00 AM | ||
Started by Mariawilcoxi, Today, 01:32 AM
|
0 responses
4 views
0 likes
|
Last Post
by Mariawilcoxi
Today, 01:32 AM
|
||
Started by gleichnerany, Today, 01:17 AM
|
0 responses
5 views
0 likes
|
Last Post
by gleichnerany
Today, 01:17 AM
|
||
Started by WHICKED, 03-27-2024, 12:33 PM
|
4 responses
47 views
0 likes
|
Last Post Today, 12:28 AM |
Comment