From the Instrument.GetInstrument() doc I'm trying to display its range with the correct TickSize for CL on the chart with the Instrument.GetInstrument("CL"); and Draw.TextFixed() methods in below snippet
namespace NinjaTrader.NinjaScript.Indicators
{
public class jimsExpiryMethod : Indicator
{
private Series<double> CLSeries;
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
}
else if (State == State.Configure)
{
AddDataSeries(GetCurrentFuture("CL"), BarsPeriodType.Day, 1);
}
else if (State == State.DataLoaded)
{
CLSeries = new Series<double>(this, MaximumBarsLookBack.Infinite);
}
protected override void OnBarUpdate()
{
NinjaTrader.Gui.Tools.SimpleFont myFont = new NinjaTrader.Gui.Tools.SimpleFont("Courier New", 12) { Size = 12, Bold = true };
CLSeries[0] = Highs[1][0]-Lows[1][0];
Print("CLSeries " + CLSeries[0]);
Instrument Crude = Instrument.GetInstrument("CL");
Draw.TextFixed(
this,
"CLSeries",
"CL DR: "+Crude.MasterInstrument.RoundToTickSize(CLSeries[0] / TickSize),
TextPosition.TopRight,
Brushes.White,
myFont,
Brushes.Transparent,
Brushes.Transparent,
0);
The problem is it's returning the TickSize of GC (54.5 (as 0.1 for GC basis point) instead of 544 expected for CL 0.01 Basis point).
How to get it to return the right TickSize (544 instead of 54.4) for CL on the GC chart? Thanks!
Comment