For example, on EUR/USD (or other forex charts), you see that databox shows Plot values rounded to 2 decimals, like:
1.23
However, this is very unflexible, and I have to use custom codes to make the Databxo to be adequate to the current chart instrument:
public override string FormatPriceMarker(double price)
{
return price.ToString("N"+ decimals(this));
}
public int decimals(NinjaTrader.NinjaScript.Indicators.Indicator x){
double tickSize = x.Instrument.MasterInstrument.TickSize;
int decimals =0;
if(tickSize ==1) { decimals = 0; }
else if(tickSize ==0.5) { decimals = 1; }
else if(tickSize ==0.25) { decimals = 1; }
else if(tickSize ==0.1) { decimals = 1; }
else if(tickSize ==0.01) { decimals = 2; }
else if(tickSize ==0.001) { decimals = 3; }
else if(tickSize ==0.005) { decimals = 3; }
else if(tickSize ==0.025) { decimals = 3; }
else if(tickSize ==0.03125) { decimals = 3; }
else if(tickSize ==0.0001) { decimals = 4; }
else if(tickSize ==1E-05) { decimals = 5; } //0.00001
else if(tickSize ==5E-05) { decimals = 5; } //0.00005
else if(tickSize ==1E-06) { decimals = 6; } //0.000001
else if(tickSize ==1E-07) { decimals = 7; } //0.0000001
else if(tickSize ==5E-07) { decimals = 7; } //0.0000005
return decimals;
}
and please, do something that NT did that automatiaclly, to choose the correct precision for databox values (i.e. even onto databbox window, there might be some kind of "settings" button to regulate that too).

Comment