Here's my OnStateChange section:
if (State == State.SetDefaults)
{
Description = @"Enter the description for your new custom Indicator here.";
Name = "MyNT8FractalLimit";
Calculate = Calculate.OnEachTick;
IsOverlay = true;
DisplayInDataBox = true;
DrawOnPricePanel = true;
ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
EntriesPerDirection = 99999;
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 = true;
IsAutoScale = false;
OrderFillResolution = OrderFillResolution.Standard;
MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix;
Slippage = 0;
StartBehavior = StartBehavior.WaitUntilFlat;
TimeInForce = TimeInForce.Gtc;
RealtimeErrorHandling = RealtimeErrorHandling.StopCancelClose;
StopTargetHandling = StopTargetHandling.PerEntryExecution;
// // Disable this property for performance gains in Strategy Analyzer optimizations
// IsInstantiatedOnEachOptimizationIteration = false;
smallFont = new Gui.Tools.SimpleFont("Courier New", smallFontSize);
mediumFont = new Gui.Tools.SimpleFont("Courier New", mediumFontSize);
largeFont = new Gui.Tools.SimpleFont("Courier New", largeFontSize);
AddPlot(new Stroke(Brushes.Blue, 2), PlotStyle.Line, "AlligatorJaw");
AddPlot(new Stroke(Brushes.Red, 2), PlotStyle.Line, "AlligatorTeeth");
AddPlot(new Stroke(Brushes.Green, 2), PlotStyle.Line, "AlligatorLip");
Fast = 5;
Slow = 35;
Smooth = 1;
} //State == State.SetDefaults
else if (State == State.Configure)
{
AL1_baseLine = new Series<double>(this, MaximumBarsLookBack.Infinite);
if (outputTab == 1) PrintTo = PrintTo.OutputTab1; else PrintTo = PrintTo.OutputTab2;
ClearOutputWindow();
} //State == State.Configure
else if (State==State.DataLoaded)
{
instName= Instrument.MasterInstrument.Name;
sessionTxtwithSpacers = sessionTxt;
DirectoryInfo dir = new DirectoryInfo(NinjaTrader.Core.Globals.InstallDir + "sounds");
soundFileDir = dir.ToString()+"\";
AL1_firstPasses = true;
MyNT8ZeroLagMACD1 = MyNT8ZeroLagMACD(Close, 12, 26, 9);
VOL1 = VOL(Close);
ATR1 = ATR(Close, ATRperiod);
shortTrades = shortButtonTrades;
longTrades = longButtonTrades;
smoothSma = new Series<double>(this);
smaFast = SMA(Fast);
smaSlow = SMA(Slow);
smaSmooth = SMA(smoothSma, Smooth);
entryStopPrice = new Series<double>(this);
// parameter edits go here:
}
// ************************************************** ****
} //State==State.DataLoaded
else if(State==State.Historical)
{
AddButtonToToolbar();
} //State==State.Historical
else if(State==State.Terminated)
{
if(IsToolBarButtonAdded) DisposeCleanUp();
} //State==State.Terminated
else if (State == State.Realtime)
{
// one time only, as we transition from historical convert any old historical order object references to the new live order submitted to the real-time account
if (longLimitOrder1 != null) longLimitOrder1 = GetRealtimeOrder(longLimitOrder1);
if (longLimitOrder2 != null) longLimitOrder2 = GetRealtimeOrder(longLimitOrder2);
if (longLimitOrder3 != null) longLimitOrder3 = GetRealtimeOrder(longLimitOrder3);
if (shortLimitOrder1 != null) shortLimitOrder1 = GetRealtimeOrder(shortLimitOrder1);
if (shortLimitOrder2 != null) shortLimitOrder2 = GetRealtimeOrder(shortLimitOrder2);
if (shortLimitOrder3 != null) shortLimitOrder3 = GetRealtimeOrder(shortLimitOrder3);
if (stopOrder1 != null) stopOrder1 = GetRealtimeOrder(stopOrder1);
if (stopOrder2 != null) stopOrder2 = GetRealtimeOrder(stopOrder2);
if (stopOrder3 != null) stopOrder3 = GetRealtimeOrder(stopOrder3);
if (targetOrder1 != null) targetOrder1 = GetRealtimeOrder(targetOrder1);
if (targetOrder2 != null) targetOrder2 = GetRealtimeOrder(targetOrder2);
if (targetOrder3 != null) targetOrder3 = GetRealtimeOrder(targetOrder3);
}//State==State.Realtime
}
Comment