
Instrument.GetInstrument("^VIX"). -- intellisense doesn't show RoundToTickSize as an option, and if I type it in, it doesn't compile ( no definition for RoundToTickSize ).
Feels odd to call it the MasterInstrument when accessing it.

I don't want to round to ES .25 tick size, but ^VIX's .01.
This code does work fine:
namespace NinjaTrader.NinjaScript.Strategies
{
public class RoundtoTickSizeEXA : Strategy
{
static int ES = 0;
static int VIX = 1;
[B]Instrument Instrument_vix;[/B]
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"none";
Name = "RoundtoTickSizeEXA";
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)
{
AddDataSeries("^VIX", Data.BarsPeriodType.Minute, 3);
[B]Instrument_vix = Instrument.GetInstrument("^VIX");
[/B] }
}
protected override void OnBarUpdate()
{
//Add your custom strategy logic here.
if (BarsInProgress != 0)
return;
if (CurrentBars[ES] < 0 || CurrentBars[VIX] < 20)
return;
//Add your custom strategy logic here.
// only process on real-time data
if (State == State.Historical)
return;
Print ( ToTime(Time[0]) +"+VIX SMA(14)="+[B]Instrument_vix.MasterInstrument.RoundToTickSize(SMA(BarsArray[VIX], 14)[0])[/B]
+" ES="+Instrument.MasterInstrument.RoundToTickSize(BarsArray[ES][0])
+" ES SMA(14)="+Instrument.MasterInstrument.RoundToTickSize(SMA(BarsArray[ES],14)[01]));
}

Comment