Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Showing time remaining to the right

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Showing time remaining to the right

    Hi,
    I created custom copy of BarTimer indicator where I want to show time remaining not on the current bar but to the right, like on the attached image. How can I do it?


    Draw.Text(this, "NinjaScriptInfo1", true, timeLeft, Bars.GetTime(CurrentBar), Bars.GetClose(Bars.Count-1), 0, Brushes.Blue, ChartControl.Properties.LabelFont, System.Windows.TextAlignment.Left, Brushes.Transparent, Brushes.Transparent, 0);


    if (connected)
    {
    if (SessionIterator.IsInSession(Now, false, true))
    {
    if (hasRealtimeData)
    {
    TimeSpan barTimeLeft = Bars.GetTime(Bars.Count - 1).Subtract(Now);

    timeLeft = (barTimeLeft.Ticks < 0
    ? "00:00:00"
    : barTimeLeft.Hours.ToString("00") + ":" + barTimeLeft.Minutes.ToString("00") + ":" + barTimeLeft.Seconds.ToString("00"));

    Draw.TextFixed(this, "NinjaScriptInfo", NinjaTrader.Custom.Resource.BarTimerTimeRemaining + timeLeft, TextPosition.BottomRight, ChartControl.Properties.ChartText, ChartControl.Properties.LabelFont, Brushes.Transparent, Brushes.Transparent, 0);
    Draw.Text(this, "NinjaScriptInfo1", true, timeLeft, Bars.GetTime(CurrentBar), Bars.GetClose(Bars.Count-1), 0, Brushes.Blue, ChartControl.Properties.LabelFont, System.Windows.TextAlignment.Left, Brushes.Transparent, Brushes.Transparent, 0);
    }
    else
    Draw.TextFixed(this, "NinjaScriptInfo", NinjaTrader.Custom.Resource.BarTimerWaitingOnDataE rror, TextPosition.BottomRight, ChartControl.Properties.ChartText, ChartControl.Properties.LabelFont, Brushes.Transparent, Brushes.Transparent, 0);
    }
    else
    Draw.TextFixed(this, "NinjaScriptInfo", NinjaTrader.Custom.Resource.BarTimerSessionTimeErr or, TextPosition.BottomRight, ChartControl.Properties.ChartText, ChartControl.Properties.LabelFont, Brushes.Transparent, Brushes.Transparent, 0);​

    Click image for larger version

Name:	image.png
Views:	179
Size:	9.2 KB
ID:	1310692

    #2
    Hello tkaboris,

    You would need to change from using Draw.TextFixed to Draw.Text and then specify a negative bars ago as its anchor point. While that is unsupported it should work to push the text past the current bar. There is no way to make the chart automatically move to include that but you can manually scroll the chart to see it. If you wanted to accomplish that in a way that does not require manually scrolling you could use OnRender to display text at specific X and Y coordinates and then use the charts right side margin property in its property menu to push the bars back past the text.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CaptainJack, 05-29-2026, 05:09 AM
    0 responses
    229 views
    0 likes
    Last Post CaptainJack  
    Started by CaptainJack, 05-29-2026, 12:02 AM
    0 responses
    148 views
    0 likes
    Last Post CaptainJack  
    Started by charlesugo_1, 05-26-2026, 05:03 PM
    0 responses
    160 views
    1 like
    Last Post charlesugo_1  
    Started by DannyP96, 05-18-2026, 02:38 PM
    1 response
    240 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    198 views
    0 likes
    Last Post CarlTrading  
    Working...
    X