I've a strategy running with the below format. If I've a strategy with multiple data series. Inside else if (State == State.DataLoaded) do I need to call the indicator with the below example1 or example 2?
Example 1: CurrentDayOHL1 = CurrentDayOHL(Close);
Example 2: CurrentDayOHL1 = CurrentDayOHL(Closes[0]);
I've attached a small portion of the script with 2 options highlighted in red. Option 1 shows without the "s[0]", and Option 2 with it. All the indicators that I've are on the Primary Data Series, so my assumption is that all of them will be one way or the other.
Option 1:
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"Enter the description for your new custom Strategy here.";
Name = "Name";
Calculate = Calculate.OnEachTick;
EntriesPerDirection = 3;
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)
{
AddVolumetric(Instrument.FullName, BarsPeriodType.Minute, 1440, VolumetricDeltaType.BidAsk, 1);
AddDataSeries(Data.BarsPeriodType.Tick, 1);
}
else if (State == State.DataLoaded)
{
ClearOutputWindow();
VOL1 = VOL(Close);
VolumeUpDown1 = VolumeUpDown(Close);
CurrentDayOHL1 = CurrentDayOHL(Close);
VWAP11 = VWAP1(Close, 1);
CumDelta1 = CumDelta(Close, Brushes.Red, Brushes.LimeGreen, Brushes.Black, 1, 0, false);
}
}
protected override void OnBarUpdate()
{
if (CurrentBars[0] < 60 || (BarsInProgress == 1 && BarsArray[1] == null))
return;
NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe barsType1 = BarsArray[1].BarsType as NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe;
if (barsType1 == null)
return;
try
{
// Condition
}
catch{}
Option 2:
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"Enter the description for your new custom Strategy here.";
Name = "Name";
Calculate = Calculate.OnEachTick;
EntriesPerDirection = 3;
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)
{
AddVolumetric(Instrument.FullName, BarsPeriodType.Minute, 1440, VolumetricDeltaType.BidAsk, 1);
AddDataSeries(Data.BarsPeriodType.Tick, 1);
}
else if (State == State.DataLoaded)
{
ClearOutputWindow();
VOL1 = VOL(Closes[0]);
VolumeUpDown1 = VolumeUpDown(Closes[0]);
CurrentDayOHL1 = CurrentDayOHL(Closes[0]);
VWAP11 = VWAP1(Closes[0], 1);
CumDelta1 = CumDelta(Closes[0], Brushes.Red, Brushes.LimeGreen, Brushes.Black, 1, 0, false);
}
}
protected override void OnBarUpdate()
{
if (CurrentBars[0] < 60 || (BarsInProgress == 1 && BarsArray[1] == null))
return;
NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe barsType1 = BarsArray[1].BarsType as NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe;
if (barsType1 == null)
return;
try
{
// Condition
}
catch{}
Comment