The problem is that the NinjaScript Editor expands EVERY SINGLE class, method, and #region that is collapsed. That means I have to go back through all 2k lines of code and recollapse the 30 different areas.
I can reproduce this by:
1. Create a new strategy and immediately choosing Generate.
2. Delete all lines of code.
3. Copy-paste the code below into that new strategy.
4. Collapse the following areas with the '-' minus sign:
- Line 76 myClass1
- Line 74 #region My Classes
- Line 69 OnBarUpdate
- Line 39 OnStateChange
5. Now, within #region My Methods is public void TestMe()
{
Type string, or int, or even a comment // and watch what happens.
}
6. All the other regions expand as well as OnBarUpdate and OnStateChange.
I'm on Win10 Home 1703 / build 15063.483 and NT 8.0.8.0 64-bit (Standard)
Can anyone else confirm this?
I found that it happens less if the method/class you're working on isn't within a region but it's not guaranteed to stop the behavior.
#region Using declarations
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
using System.Xml.Serialization;
using NinjaTrader.Cbi;
using NinjaTrader.Gui;
using NinjaTrader.Gui.Chart;
using NinjaTrader.Gui.SuperDom;
using NinjaTrader.Gui.Tools;
using NinjaTrader.Data;
using NinjaTrader.NinjaScript;
using NinjaTrader.Core.FloatingPoint;
using NinjaTrader.NinjaScript.Indicators;
using NinjaTrader.NinjaScript.DrawingTools;
#endregion
//This namespace holds Strategies in this folder and is required. Do not change it.
namespace NinjaTrader.NinjaScript.Strategies
{
public class MyCustomStrategy : Strategy
{
#region My Methods
public void TestMe()
{
}
#endregion
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"Enter the description for your new custom Strategy here.";
Name = "MyCustomStrategy";
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)
{
}
}
protected override void OnBarUpdate()
{
//Add your custom strategy logic here.
}
#region My Classes
public class myClass1
{
}
#endregion
}
}


Comment