For example if I take the built in indicator "Bar Timer", and let's say I want the remaining time to be painted always near the current price instead of the default bottom right.
So I changed / added the following:
private double currentPrice;
public SpaceFrom = 1; // OnStateChange -> State.SetDefaults
protected override void OnBarUpdate()
{
currentPrice = Close[0];
}
private void OnTimerTick(object sender, EventArgs e)
{
// Draw.TextFixed was replaced with Draw.Text
Draw.TextFixed(this, "NinjaScriptInfo", NinjaTrader.Custom.Resource.BarTimerTimeRemaining + timeLeft, TextPosition.BottomRight, ChartControl.Properties.ChartText, ChartControl.Properties.LabelFont, Brushes.Transparent, Brushes.Transparent, 0); // removed
Draw.Text(this, "MyIndicator", false, timeLeft, -SpaceFrom, currentPrice, 0, ChartControl.Properties.ChartText, ChartControl.Properties.LabelFont, TextAlignment.Left, Brushes.Transparent, Brushes.Transparent, 0); //added
}
How can I fix it?
Same happens with Drawing Tools. The "OnRender" function is delayed compering to current price changes.

Comment